summaryrefslogtreecommitdiffstats
path: root/views/widget/widget_win.cc
diff options
context:
space:
mode:
authorjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-01 15:57:26 +0000
committerjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-01 15:57:26 +0000
commit7f14e1fd31ddd510b19e2d9f6942c45435c9a8c6 (patch)
tree33fa783fff0459a26f38979a80c1e8b9aac8cad2 /views/widget/widget_win.cc
parent32a54416beeeda33978af7816f4135bf7dfa7e95 (diff)
downloadchromium_src-7f14e1fd31ddd510b19e2d9f6942c45435c9a8c6.zip
chromium_src-7f14e1fd31ddd510b19e2d9f6942c45435c9a8c6.tar.gz
chromium_src-7f14e1fd31ddd510b19e2d9f6942c45435c9a8c6.tar.bz2
Relanding focus traversal on Linux toolkit views.
It was previously breaking the interactive UI tests. That was because I changed the button base class to be focusable by default which led to many button beings added to the tab traversal order. I now explicitly make these buttons non focusable. Also because of the way we clear the native focus on Gtk (by setting focus to NULL on the top level window), views now default to clearing the focus when focused (so that views non backed by a native window don't leave the native focus on the previously native window). On Windows we used to focus the WidgetWin's HWND, and now we focus the top-level HWND. The WidgetWin class had to be changed to forward the key events to the root view that contains the focused view because of that. (otherwise it would send it to the top-level root-view, and if the focused view was in a child root-view it would not recieve the keyboard messages). Note that the mouse wheel does not need that, as the mouse-wheel Windows messages are sent to the HWND under the cursor. See: http://codereview.chromium.org/246030/show TEST=Run the tests BUG=NONE Review URL: http://codereview.chromium.org/255008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27723 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/widget/widget_win.cc')
-rw-r--r--views/widget/widget_win.cc24
1 files changed, 22 insertions, 2 deletions
diff --git a/views/widget/widget_win.cc b/views/widget/widget_win.cc
index 3017e05..d272e1f 100644
--- a/views/widget/widget_win.cc
+++ b/views/widget/widget_win.cc
@@ -573,13 +573,21 @@ void WidgetWin::OnInitMenuPopup(HMENU menu,
void WidgetWin::OnKeyDown(TCHAR c, UINT rep_cnt, UINT flags) {
KeyEvent event(Event::ET_KEY_PRESSED,
win_util::WinToKeyboardCode(c), rep_cnt, flags);
- SetMsgHandled(root_view_->ProcessKeyEvent(event));
+ RootView* root_view = GetFocusedViewRootView();
+ if (!root_view)
+ root_view = root_view_.get();
+
+ SetMsgHandled(root_view->ProcessKeyEvent(event));
}
void WidgetWin::OnKeyUp(TCHAR c, UINT rep_cnt, UINT flags) {
KeyEvent event(Event::ET_KEY_RELEASED,
win_util::WinToKeyboardCode(c), rep_cnt, flags);
- SetMsgHandled(root_view_->ProcessKeyEvent(event));
+ RootView* root_view = GetFocusedViewRootView();
+ if (!root_view)
+ root_view = root_view_.get();
+
+ SetMsgHandled(root_view->ProcessKeyEvent(event));
}
// TODO(pkasting): ORing the pressed/released button into the flags is _wrong_.
@@ -1028,6 +1036,18 @@ void WidgetWin::UpdateWindowFromContents(HDC dib_dc) {
}
}
+RootView* WidgetWin::GetFocusedViewRootView() {
+ FocusManager* focus_manager = GetFocusManager();
+ if (!focus_manager) {
+ NOTREACHED();
+ return NULL;
+ }
+ View* focused_view = focus_manager->GetFocusedView();
+ if (!focused_view)
+ return NULL;
+ return focused_view->GetRootView();
+}
+
// Get the source HWND of the specified message. Depending on the message, the
// source HWND is encoded in either the WPARAM or the LPARAM value.
HWND GetControlHWNDForMessage(UINT message, WPARAM w_param, LPARAM l_param) {