diff options
-rw-r--r-- | views/focus/focus_manager.cc | 28 | ||||
-rw-r--r-- | views/focus/focus_manager.h | 3 | ||||
-rw-r--r-- | views/widget/widget_win.cc | 19 | ||||
-rw-r--r-- | views/widget/widget_win.h | 5 |
4 files changed, 26 insertions, 29 deletions
diff --git a/views/focus/focus_manager.cc b/views/focus/focus_manager.cc index 04258bf..046d6ea 100644 --- a/views/focus/focus_manager.cc +++ b/views/focus/focus_manager.cc @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "views/focus/focus_manager.h" + #include <algorithm> #include "build/build_config.h" @@ -13,7 +15,6 @@ #include "base/histogram.h" #include "base/logging.h" #include "views/accelerator.h" -#include "views/focus/focus_manager.h" #include "views/focus/view_storage.h" #include "views/view.h" #include "views/widget/root_view.h" @@ -78,20 +79,6 @@ static LRESULT CALLBACK FocusWindowCallback(HWND window, UINT message, if (!focus_manager->OnNCDestroy(window)) return 0; break; - case WM_ACTIVATE: { - // We call the DefWindowProc before calling OnActivate as some of our - // windows need the OnActivate notifications. The default activation on - // the window causes it to focus the main window, and since - // FocusManager::OnActivate attempts to restore the focused view, it - // needs to be called last so the focus it is setting does not get - // overridden. - LRESULT result = CallWindowProc(original_handler, window, WM_ACTIVATE, - wParam, lParam); - if (!focus_manager->OnPostActivate(window, - LOWORD(wParam), HIWORD(wParam))) - return 0; - return result; - } default: break; } @@ -335,17 +322,6 @@ bool FocusManager::OnKeyUp(HWND window, UINT message, WPARAM wparam, return true; } - -bool FocusManager::OnPostActivate(HWND window, - int activation_state, - int minimized_state) { - if (WA_INACTIVE == LOWORD(activation_state)) { - StoreFocusedView(); - } else { - RestoreFocusedView(); - } - return false; -} #endif void FocusManager::ValidateFocusedView() { diff --git a/views/focus/focus_manager.h b/views/focus/focus_manager.h index 28abcde..4c7f6ce 100644 --- a/views/focus/focus_manager.h +++ b/views/focus/focus_manager.h @@ -189,9 +189,6 @@ class FocusManager { UINT message, WPARAM wparam, LPARAM lparam); - // OnPostActivate is called after WM_ACTIVATE has been propagated to the - // DefWindowProc. - bool OnPostActivate(HWND window, int activation_state, int minimized_state); #endif // Returns true is the specified is part of the hierarchy of the window diff --git a/views/widget/widget_win.cc b/views/widget/widget_win.cc index 353fcbc..41c7309 100644 --- a/views/widget/widget_win.cc +++ b/views/widget/widget_win.cc @@ -1046,7 +1046,26 @@ LRESULT CALLBACK WidgetWin::WndProc(HWND window, UINT message, widget->hwnd_ = NULL; widget->OnFinalMessage(window); } + if (message == WM_ACTIVATE) + PostProcessActivateMessage(widget, LOWORD(w_param)); return result; } +// static +void WidgetWin::PostProcessActivateMessage(WidgetWin* widget, + int activation_state) { + FocusManager* focus_manager = + FocusManager::GetFocusManager(widget->GetNativeView()); + if (!focus_manager) { + NOTREACHED(); + return; + } + if (WA_INACTIVE == activation_state) { + focus_manager->StoreFocusedView(); + } else { + // We must restore the focus after the message has been DefProc'ed as it + // does set the focus to the last focused HWND. + focus_manager->RestoreFocusedView(); + } +} } // namespace views diff --git a/views/widget/widget_win.h b/views/widget/widget_win.h index c57de93..cec2537 100644 --- a/views/widget/widget_win.h +++ b/views/widget/widget_win.h @@ -555,6 +555,11 @@ class WidgetWin : public Widget, WPARAM w_param, LPARAM l_param); + // Called after the WM_ACTIVATE message has been processed by the default + // windows procedure. + static void PostProcessActivateMessage(WidgetWin* widget, + int activation_state); + // Gets the window class name to use when creating the corresponding HWND. // If necessary, this registers the window class. std::wstring GetWindowClassName(); |