From 63d23bb1410837f9fdc300b4b5c0a3470724c8d6 Mon Sep 17 00:00:00 2001 From: "jcampan@chromium.org" Date: Tue, 8 Sep 2009 21:02:16 +0000 Subject: 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 --- views/focus/focus_manager_gtk.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'views') 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; -- cgit v1.1