diff options
author | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-08 21:02:16 +0000 |
---|---|---|
committer | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-08 21:02:16 +0000 |
commit | 63d23bb1410837f9fdc300b4b5c0a3470724c8d6 (patch) | |
tree | 4ff1482a4424e429ce4c89d2c6c47d2a6ce7e447 | |
parent | 1784e83a07f691ac0caa78d32eaf527cfe02b834 (diff) | |
download | chromium_src-63d23bb1410837f9fdc300b4b5c0a3470724c8d6.zip chromium_src-63d23bb1410837f9fdc300b4b5c0a3470724c8d6.tar.gz chromium_src-63d23bb1410837f9fdc300b4b5c0a3470724c8d6.tar.bz2 |
Improving the FocusManager::GetFocusManager method on Gtk.
BUG=None
TEST=Run the FocusManager unit tests
Review URL: http://codereview.chromium.org/200020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25660 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/chrome.gyp | 3 | ||||
-rw-r--r-- | views/focus/focus_manager_gtk.cc | 13 |
2 files changed, 9 insertions, 7 deletions
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index 12f3dff..e45cb92 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -98,13 +98,13 @@ # TODO(jcampan): move these vars to views.gyp. 'views_unit_tests_sources': [ '../views/view_unittest.cc', + '../views/focus/focus_manager_unittest.cc', ], 'views_unit_tests_sources_win_specific': [ # TODO(jcampan): make the following tests work on Linux. '../views/controls/label_unittest.cc', '../views/controls/table/table_view_unittest.cc', '../views/grid_layout_unittest.cc', - '../views/focus/focus_manager_unittest.cc', ], 'conditions': [ ['OS=="mac"', { @@ -4221,6 +4221,7 @@ ['exclude', 'browser/gtk/tabs/tab_renderer_gtk_unittest\\.cc$'], ['exclude', 'browser/gtk/options/cookies_view_unittest\\.cc$'], ['exclude', 'browser/gtk/options/languages_page_gtk_unittest\\.cc$'], + ['exclude', 'browser/gtk/gtk_theme_provider_unittest\\.cc$'], ], }], ['OS=="mac"', { diff --git a/views/focus/focus_manager_gtk.cc b/views/focus/focus_manager_gtk.cc index eb25654..6ba1390 100644 --- a/views/focus/focus_manager_gtk.cc +++ b/views/focus/focus_manager_gtk.cc @@ -16,17 +16,18 @@ void FocusManager::ClearNativeFocus() { } void FocusManager::FocusNativeView(gfx::NativeView native_view) { - NOTIMPLEMENTED(); + if (native_view && !gtk_widget_is_focus(native_view)) + gtk_widget_grab_focus(native_view); } // static FocusManager* FocusManager::GetFocusManagerForNativeView( gfx::NativeView native_view) { - GtkWidget* parent; - while ((parent = gtk_widget_get_parent(native_view)) != NULL) { - native_view = parent; - } - WidgetGtk* widget = WidgetGtk::GetViewForNative(native_view); + GtkWidget* root = gtk_widget_get_toplevel(native_view); + if (!root || !GTK_WIDGET_TOPLEVEL(root)) + return NULL; + + WidgetGtk* widget = WidgetGtk::GetViewForNative(root); if (!widget) { NOTREACHED(); return NULL; |