summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-08 23:33:23 +0000
committerjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-08 23:33:23 +0000
commit3c59ef0629260028c98b9648ee7e6732b24018a0 (patch)
tree3ce67f67d5754b5089628433cdd1298d7ea10b0a /views
parent1f082083982da6f2261a2bc1bb74247a903ba2ee (diff)
downloadchromium_src-3c59ef0629260028c98b9648ee7e6732b24018a0.zip
chromium_src-3c59ef0629260028c98b9648ee7e6732b24018a0.tar.gz
chromium_src-3c59ef0629260028c98b9648ee7e6732b24018a0.tar.bz2
Moving the Windows specific activation code in the FocusManager to the widget_win.
BUG=None TEST=Test that the focus in the browser works well: that windows remember which view had focus when deactivated/reactivated. Make sure focus traversal works as expected. Review URL: http://codereview.chromium.org/118406 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17911 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/focus/focus_manager.cc28
-rw-r--r--views/focus/focus_manager.h3
-rw-r--r--views/widget/widget_win.cc19
-rw-r--r--views/widget/widget_win.h5
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();