Index: content/browser/renderer_host/render_widget_host_view_gtk.cc |
diff --git a/content/browser/renderer_host/render_widget_host_view_gtk.cc b/content/browser/renderer_host/render_widget_host_view_gtk.cc |
index 15a007381aedb42bfcf0924521bde69bc67accd2..b939faca2a5825cf994741071685e156f8db2b65 100644 |
--- a/content/browser/renderer_host/render_widget_host_view_gtk.cc |
+++ b/content/browser/renderer_host/render_widget_host_view_gtk.cc |
@@ -586,35 +586,42 @@ void RenderWidgetHostViewGtk::InitAsPopup( |
gtk_container_add(GTK_CONTAINER(window), view_.get()); |
DoPopupOrFullscreenInit(window, pos); |
- // The underlying X window needs to be created and mapped by the above code |
- // before we can grab the input devices. |
+ // Grab all input for the app. If a click lands outside the bounds of the |
+ // popup, WebKit will notice and destroy us. The underlying X window needs to |
+ // be created and mapped by the above code before we can grab the input |
+ // devices. |
if (NeedsInputGrab()) { |
- // Grab all input for the app. If a click lands outside the bounds of the |
- // popup, WebKit will notice and destroy us. Before doing this we need |
- // to ensure that the the popup is added to the browser's window group, |
- // to allow for the grabs to work correctly. |
- gtk_window_group_add_window(gtk_window_get_group( |
- GTK_WINDOW(gtk_widget_get_toplevel(parent_))), window); |
- gtk_grab_add(view_.get()); |
- |
- // We need for the application to do an X grab as well. However if the app |
- // already has an X grab (as in the case of extension popup), an app grab |
- // will suffice. |
- do_x_grab_ = !gdk_pointer_is_grabbed(); |
- |
- // Now grab all of X's input. |
- if (do_x_grab_) { |
- gdk_pointer_grab( |
- gtk_widget_get_window(parent_), |
- TRUE, // Only events outside of the window are reported with respect |
- // to |parent_->window|. |
- static_cast<GdkEventMask>(GDK_BUTTON_PRESS_MASK | |
- GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK), |
- NULL, |
- NULL, |
- GDK_CURRENT_TIME); |
- // We grab keyboard events too so things like alt+tab are eaten. |
- gdk_keyboard_grab(gtk_widget_get_window(parent_), TRUE, GDK_CURRENT_TIME); |
+ // If our parent isn't a child of a toplevel window (e.g. it's an inactive |
+ // tab), skip the grab. |
Evan Stade
2012/05/08 00:01:13
how does the popup window know to close if there's
Daniel Erat
2012/05/08 00:11:56
Hmm, it doesn't get closed until I click on an ite
|
+ GtkWidget* toplevel = gtk_widget_get_toplevel(parent_); |
+ if (gtk_widget_is_toplevel(toplevel) && GTK_IS_WINDOW(toplevel)) { |
+ // Ensure that the the popup is added to the browser's window group, to |
+ // allow for the grabs to work correctly. |
+ gtk_window_group_add_window(gtk_window_get_group(GTK_WINDOW(toplevel)), |
+ window); |
+ gtk_grab_add(view_.get()); |
+ |
+ // We need for the application to do an X grab as well. However if the app |
+ // already has an X grab (as in the case of extension popup), an app grab |
+ // will suffice. |
+ do_x_grab_ = !gdk_pointer_is_grabbed(); |
+ |
+ // Now grab all of X's input. |
+ if (do_x_grab_) { |
+ gdk_pointer_grab( |
+ gtk_widget_get_window(parent_), |
+ TRUE, // Only events outside of the window are reported with |
+ // respect to |parent_->window|. |
+ static_cast<GdkEventMask>(GDK_BUTTON_PRESS_MASK | |
+ GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK), |
+ NULL, |
+ NULL, |
+ GDK_CURRENT_TIME); |
+ // We grab keyboard events too so things like alt+tab are eaten. |
+ gdk_keyboard_grab(gtk_widget_get_window(parent_), |
+ TRUE, // owner_events |
+ GDK_CURRENT_TIME); |
+ } |
} |
} |
} |