diff options
author | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-10 23:43:32 +0000 |
---|---|---|
committer | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-10 23:43:32 +0000 |
commit | a6fd68e5303ecb4700de8775ca1ed09dcfb00948 (patch) | |
tree | bf5a4aea19448e9e1a6d8f1dcf01cfddecae0126 /content/browser/renderer_host | |
parent | 18104187a4272017b6c2f81f48bee29525b81a07 (diff) | |
download | chromium_src-a6fd68e5303ecb4700de8775ca1ed09dcfb00948.zip chromium_src-a6fd68e5303ecb4700de8775ca1ed09dcfb00948.tar.gz chromium_src-a6fd68e5303ecb4700de8775ca1ed09dcfb00948.tar.bz2 |
Reland "linux: Fix grabs for popups belonging to ..."
This relands r135966, which was reverted by r136293. By
adding the popup to its parent's window group, the DevTools
profiler heap snapshot combobox receives mouse input again.
I'm still not sure why this is necessary.
Original description:
When displaying a popup for an inactive tab, grab input on
behalf of the popup's window rather than its parent window.
[snip obsolete, now-removed window group change]
BUG=126296
TEST=manual: original test case is still fine; dev tool regression described in r136293 is gone
Review URL: https://chromiumcodereview.appspot.com/10389080
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@136451 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/renderer_host')
-rw-r--r-- | content/browser/renderer_host/render_widget_host_view_gtk.cc | 47 |
1 files changed, 30 insertions, 17 deletions
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 e8010b7..7e93e84 100644 --- a/content/browser/renderer_host/render_widget_host_view_gtk.cc +++ b/content/browser/renderer_host/render_widget_host_view_gtk.cc @@ -596,35 +596,48 @@ 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); + // If our parent is in a widget hierarchy that ends with a window, add + // ourselves to the same window group to make sure that our GTK grab + // covers it. + GtkWidget* toplevel = gtk_widget_get_toplevel(parent_); + if (toplevel && + GTK_WIDGET_TOPLEVEL(toplevel) && + GTK_IS_WINDOW(toplevel)) { + gtk_window_group_add_window( + gtk_window_get_group(GTK_WINDOW(toplevel)), 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). + 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); } } } |