summaryrefslogtreecommitdiffstats
path: root/views/focus
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/focus
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/focus')
-rw-r--r--views/focus/accelerator_handler_win.cc3
-rw-r--r--views/focus/focus_manager_gtk.cc11
2 files changed, 13 insertions, 1 deletions
diff --git a/views/focus/accelerator_handler_win.cc b/views/focus/accelerator_handler_win.cc
index 8363928..f617c6f 100644
--- a/views/focus/accelerator_handler_win.cc
+++ b/views/focus/accelerator_handler_win.cc
@@ -29,6 +29,9 @@ bool AcceleratorHandler::Dispatch(const MSG& msg) {
msg.lParam & 0xFFFF,
(msg.lParam & 0xFFFF0000) >> 16);
process_message = focus_manager->OnKeyEvent(event);
+ // TODO(jcampan): http://crbug.com/23383 We should not translate and
+ // dispatch the associated WM_KEYUP if process_message
+ // is true.
break;
}
}
diff --git a/views/focus/focus_manager_gtk.cc b/views/focus/focus_manager_gtk.cc
index 93b9cb7..3038d93 100644
--- a/views/focus/focus_manager_gtk.cc
+++ b/views/focus/focus_manager_gtk.cc
@@ -8,11 +8,20 @@
#include "base/logging.h"
#include "views/widget/widget_gtk.h"
+#include "views/window/window_gtk.h"
namespace views {
void FocusManager::ClearNativeFocus() {
- gtk_widget_grab_focus(widget_->GetNativeView());
+ GtkWidget* gtk_widget = widget_->GetNativeView();
+ if (!gtk_widget) {
+ NOTREACHED();
+ return;
+ }
+
+ // Since only top-level WidgetGtk have a focus manager, the native view is
+ // expected to be a GtkWindow.
+ gtk_window_set_focus(GTK_WINDOW(gtk_widget), NULL);
}
void FocusManager::FocusNativeView(gfx::NativeView native_view) {