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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_gtk.cc

Issue 10381117: Merge 136451 - Reland "linux: Fix grabs for popups belonging to ..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1084/src/
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/render_widget_host_view_gtk.h" 5 #include "content/browser/renderer_host/render_widget_host_view_gtk.h"
6 6
7 // If this gets included after the gtk headers, then a bunch of compiler 7 // If this gets included after the gtk headers, then a bunch of compiler
8 // errors happen because of a "#define Status int" in Xlib.h, which interacts 8 // errors happen because of a "#define Status int" in Xlib.h, which interacts
9 // badly with net::URLRequestStatus::Status. 9 // badly with net::URLRequestStatus::Status.
10 #include "content/common/view_messages.h" 10 #include "content/common/view_messages.h"
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 RenderWidgetHostView* parent_host_view, const gfx::Rect& pos) { 569 RenderWidgetHostView* parent_host_view, const gfx::Rect& pos) {
570 // If we aren't a popup, then |window| will be leaked. 570 // If we aren't a popup, then |window| will be leaked.
571 DCHECK(IsPopup()); 571 DCHECK(IsPopup());
572 572
573 DoSharedInit(); 573 DoSharedInit();
574 parent_ = parent_host_view->GetNativeView(); 574 parent_ = parent_host_view->GetNativeView();
575 GtkWindow* window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_POPUP)); 575 GtkWindow* window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_POPUP));
576 gtk_container_add(GTK_CONTAINER(window), view_.get()); 576 gtk_container_add(GTK_CONTAINER(window), view_.get());
577 DoPopupOrFullscreenInit(window, pos); 577 DoPopupOrFullscreenInit(window, pos);
578 578
579 // The underlying X window needs to be created and mapped by the above code 579 // Grab all input for the app. If a click lands outside the bounds of the
580 // before we can grab the input devices. 580 // popup, WebKit will notice and destroy us. The underlying X window needs to
581 // be created and mapped by the above code before we can grab the input
582 // devices.
581 if (NeedsInputGrab()) { 583 if (NeedsInputGrab()) {
582 // Grab all input for the app. If a click lands outside the bounds of the 584 // If our parent is in a widget hierarchy that ends with a window, add
583 // popup, WebKit will notice and destroy us. Before doing this we need 585 // ourselves to the same window group to make sure that our GTK grab
584 // to ensure that the the popup is added to the browser's window group, 586 // covers it.
585 // to allow for the grabs to work correctly. 587 GtkWidget* toplevel = gtk_widget_get_toplevel(parent_);
586 gtk_window_group_add_window(gtk_window_get_group( 588 if (toplevel &&
587 GTK_WINDOW(gtk_widget_get_toplevel(parent_))), window); 589 GTK_WIDGET_TOPLEVEL(toplevel) &&
590 GTK_IS_WINDOW(toplevel)) {
591 gtk_window_group_add_window(
592 gtk_window_get_group(GTK_WINDOW(toplevel)), window);
593 }
594
595 // Install an application-level GTK grab to make sure that we receive all of
596 // the app's input.
588 gtk_grab_add(view_.get()); 597 gtk_grab_add(view_.get());
589 598
590 // We need for the application to do an X grab as well. However if the app 599 // We need to install an X grab as well. However if the app already has an X
591 // already has an X grab (as in the case of extension popup), an app grab 600 // grab (as in the case of extension popup), an app grab will suffice.
592 // will suffice.
593 do_x_grab_ = !gdk_pointer_is_grabbed(); 601 do_x_grab_ = !gdk_pointer_is_grabbed();
602 if (do_x_grab_) {
603 // Install the grab on behalf our parent window if it and all of its
604 // ancestors are mapped; otherwise, just use ourselves (maybe we're being
605 // shown on behalf of an inactive tab).
606 GdkWindow* grab_window = gtk_widget_get_window(parent_);
607 if (!grab_window || !gdk_window_is_viewable(grab_window))
608 grab_window = gtk_widget_get_window(view_.get());
594 609
595 // Now grab all of X's input.
596 if (do_x_grab_) {
597 gdk_pointer_grab( 610 gdk_pointer_grab(
598 gtk_widget_get_window(parent_), 611 grab_window,
599 TRUE, // Only events outside of the window are reported with respect 612 TRUE, // Only events outside of the window are reported with
600 // to |parent_->window|. 613 // respect to |parent_->window|.
601 static_cast<GdkEventMask>(GDK_BUTTON_PRESS_MASK | 614 static_cast<GdkEventMask>(GDK_BUTTON_PRESS_MASK |
602 GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK), 615 GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK),
603 NULL, 616 NULL,
604 NULL, 617 NULL,
605 GDK_CURRENT_TIME); 618 GDK_CURRENT_TIME);
606 // We grab keyboard events too so things like alt+tab are eaten. 619 // We grab keyboard events too so things like alt+tab are eaten.
607 gdk_keyboard_grab(gtk_widget_get_window(parent_), TRUE, GDK_CURRENT_TIME); 620 gdk_keyboard_grab(grab_window, TRUE, GDK_CURRENT_TIME);
608 } 621 }
609 } 622 }
610 } 623 }
611 624
612 void RenderWidgetHostViewGtk::InitAsFullscreen( 625 void RenderWidgetHostViewGtk::InitAsFullscreen(
613 RenderWidgetHostView* /*reference_host_view*/) { 626 RenderWidgetHostView* /*reference_host_view*/) {
614 DoSharedInit(); 627 DoSharedInit();
615 628
616 is_fullscreen_ = true; 629 is_fullscreen_ = true;
617 GtkWindow* window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); 630 GtkWindow* window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
1371 return new RenderWidgetHostViewGtk(widget); 1384 return new RenderWidgetHostViewGtk(widget);
1372 } 1385 }
1373 1386
1374 // static 1387 // static
1375 void content::RenderWidgetHostViewPort::GetDefaultScreenInfo( 1388 void content::RenderWidgetHostViewPort::GetDefaultScreenInfo(
1376 WebKit::WebScreenInfo* results) { 1389 WebKit::WebScreenInfo* results) {
1377 GdkWindow* gdk_window = 1390 GdkWindow* gdk_window =
1378 gdk_display_get_default_group(gdk_display_get_default()); 1391 gdk_display_get_default_group(gdk_display_get_default());
1379 content::GetScreenInfoFromNativeWindow(gdk_window, results); 1392 content::GetScreenInfoFromNativeWindow(gdk_window, results);
1380 } 1393 }
OLDNEW
« 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