Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(791)

Unified Diff: views/focus/focus_manager_gtk.cc

Issue 200020: Improving GetFocusManager on Gtk (Closed)
Patch Set: Added FocusNativeView Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/chrome.gyp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/focus/focus_manager_gtk.cc
diff --git a/views/focus/focus_manager_gtk.cc b/views/focus/focus_manager_gtk.cc
index eb2565447359c554f041c7f5818b4d44a49a7e76..6ba1390dcf0003724909e007065dfbc2daec17ec 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;
« no previous file with comments | « chrome/chrome.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698