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

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

Issue 10389080: Reland "linux: Fix grabs for popups belonging to ..." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/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 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 RenderWidgetHostView* parent_host_view, const gfx::Rect& pos) { 589 RenderWidgetHostView* parent_host_view, const gfx::Rect& pos) {
590 // If we aren't a popup, then |window| will be leaked. 590 // If we aren't a popup, then |window| will be leaked.
591 DCHECK(IsPopup()); 591 DCHECK(IsPopup());
592 592
593 DoSharedInit(); 593 DoSharedInit();
594 parent_ = parent_host_view->GetNativeView(); 594 parent_ = parent_host_view->GetNativeView();
595 GtkWindow* window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_POPUP)); 595 GtkWindow* window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_POPUP));
596 gtk_container_add(GTK_CONTAINER(window), view_.get()); 596 gtk_container_add(GTK_CONTAINER(window), view_.get());
597 DoPopupOrFullscreenInit(window, pos); 597 DoPopupOrFullscreenInit(window, pos);
598 598
599 // The underlying X window needs to be created and mapped by the above code 599 // Grab all input for the app. If a click lands outside the bounds of the
600 // before we can grab the input devices. 600 // popup, WebKit will notice and destroy us. The underlying X window needs to
601 // be created and mapped by the above code before we can grab the input
602 // devices.
601 if (NeedsInputGrab()) { 603 if (NeedsInputGrab()) {
602 // Grab all input for the app. If a click lands outside the bounds of the 604 // If our parent is in a widget hierarchy that ends with a window, add
603 // popup, WebKit will notice and destroy us. Before doing this we need 605 // ourselves to the same window group to make sure that our GTK grab
604 // to ensure that the the popup is added to the browser's window group, 606 // covers it.
605 // to allow for the grabs to work correctly. 607 GtkWidget* toplevel = gtk_widget_get_toplevel(parent_);
606 gtk_window_group_add_window(gtk_window_get_group( 608 if (toplevel &&
607 GTK_WINDOW(gtk_widget_get_toplevel(parent_))), window); 609 GTK_WIDGET_TOPLEVEL(toplevel) &&
610 GTK_IS_WINDOW(toplevel)) {
611 gtk_window_group_add_window(
612 gtk_window_get_group(GTK_WINDOW(toplevel)), window);
613 }
614
615 // Install an application-level GTK grab to make sure that we receive all of
616 // the app's input.
608 gtk_grab_add(view_.get()); 617 gtk_grab_add(view_.get());
609 618
610 // We need for the application to do an X grab as well. However if the app 619 // We need to install an X grab as well. However if the app already has an X
611 // already has an X grab (as in the case of extension popup), an app grab 620 // grab (as in the case of extension popup), an app grab will suffice.
612 // will suffice.
613 do_x_grab_ = !gdk_pointer_is_grabbed(); 621 do_x_grab_ = !gdk_pointer_is_grabbed();
622 if (do_x_grab_) {
623 // Install the grab on behalf our parent window if it and all of its
624 // ancestors are mapped; otherwise, just use ourselves (maybe we're being
625 // shown on behalf of an inactive tab).
626 GdkWindow* grab_window = gtk_widget_get_window(parent_);
627 if (!grab_window || !gdk_window_is_viewable(grab_window))
628 grab_window = gtk_widget_get_window(view_.get());
614 629
615 // Now grab all of X's input.
616 if (do_x_grab_) {
617 gdk_pointer_grab( 630 gdk_pointer_grab(
618 gtk_widget_get_window(parent_), 631 grab_window,
619 TRUE, // Only events outside of the window are reported with respect 632 TRUE, // Only events outside of the window are reported with
620 // to |parent_->window|. 633 // respect to |parent_->window|.
621 static_cast<GdkEventMask>(GDK_BUTTON_PRESS_MASK | 634 static_cast<GdkEventMask>(GDK_BUTTON_PRESS_MASK |
622 GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK), 635 GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK),
623 NULL, 636 NULL,
624 NULL, 637 NULL,
625 GDK_CURRENT_TIME); 638 GDK_CURRENT_TIME);
626 // We grab keyboard events too so things like alt+tab are eaten. 639 // We grab keyboard events too so things like alt+tab are eaten.
627 gdk_keyboard_grab(gtk_widget_get_window(parent_), TRUE, GDK_CURRENT_TIME); 640 gdk_keyboard_grab(grab_window, TRUE, GDK_CURRENT_TIME);
628 } 641 }
629 } 642 }
630 } 643 }
631 644
632 void RenderWidgetHostViewGtk::InitAsFullscreen( 645 void RenderWidgetHostViewGtk::InitAsFullscreen(
633 RenderWidgetHostView* /*reference_host_view*/) { 646 RenderWidgetHostView* /*reference_host_view*/) {
634 DoSharedInit(); 647 DoSharedInit();
635 648
636 is_fullscreen_ = true; 649 is_fullscreen_ = true;
637 GtkWindow* window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); 650 GtkWindow* window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after
1470 browser_accessibility_manager_.reset( 1483 browser_accessibility_manager_.reset(
1471 BrowserAccessibilityManager::CreateEmptyDocument( 1484 BrowserAccessibilityManager::CreateEmptyDocument(
1472 parent, static_cast<WebAccessibility::State>(0), this)); 1485 parent, static_cast<WebAccessibility::State>(0), this));
1473 } 1486 }
1474 BrowserAccessibilityGtk* root = 1487 BrowserAccessibilityGtk* root =
1475 browser_accessibility_manager_->GetRoot()->ToBrowserAccessibilityGtk(); 1488 browser_accessibility_manager_->GetRoot()->ToBrowserAccessibilityGtk();
1476 1489
1477 atk_object_set_role(root->GetAtkObject(), ATK_ROLE_HTML_CONTAINER); 1490 atk_object_set_role(root->GetAtkObject(), ATK_ROLE_HTML_CONTAINER);
1478 return root->GetAtkObject(); 1491 return root->GetAtkObject();
1479 } 1492 }
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