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

Unified Diff: content/browser/renderer_host/render_widget_host_view_gtk.cc

Issue 10380044: linux: Fix grabs for popups belonging to inactive tabs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove core file :-( Created 8 years, 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 ce81356fa2c9bbc646e7dfca4f9223b7ded251c2..cc22aa960b1c7dd23a152f58fa789439fc85d2d8 100644
--- a/content/browser/renderer_host/render_widget_host_view_gtk.cc
+++ b/content/browser/renderer_host/render_widget_host_view_gtk.cc
@@ -595,35 +595,37 @@ 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);
+ // Install an application-level GTK grab to make sure that we receive all of
+ // the app's input.
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.
+ // We need to install 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_) {
+ // Install the grab on behalf our parent window if it and all of its
+ // ancestors are mapped; otherwise, just use ourselves (maybe we're being
+ // shown on behalf of an inactive tab).
Evan Stade 2012/05/08 18:04:12 so you might show a popup for inactive tab? wouldn
Daniel Erat 2012/05/08 18:10:13 Yeah, it's weird, but I'm just trying to fix the l
+ GdkWindow* grab_window = gtk_widget_get_window(parent_);
+ if (!grab_window || !gdk_window_is_viewable(grab_window))
+ grab_window = gtk_widget_get_window(view_.get());
+
gdk_pointer_grab(
- gtk_widget_get_window(parent_),
- TRUE, // Only events outside of the window are reported with respect
- // to |parent_->window|.
+ grab_window,
+ 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);
+ gdk_keyboard_grab(grab_window, TRUE, GDK_CURRENT_TIME);
}
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698