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

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

Issue 10378081: Merge 135966 - linux: Fix grabs for popups belonging to inactive tabs. (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 // Install an application-level GTK grab to make sure that we receive all of
583 // popup, WebKit will notice and destroy us. Before doing this we need 585 // the app's input.
584 // to ensure that the the popup is added to the browser's window group,
585 // to allow for the grabs to work correctly.
586 gtk_window_group_add_window(gtk_window_get_group(
587 GTK_WINDOW(gtk_widget_get_toplevel(parent_))), window);
588 gtk_grab_add(view_.get()); 586 gtk_grab_add(view_.get());
589 587
590 // We need for the application to do an X grab as well. However if the app 588 // 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 589 // grab (as in the case of extension popup), an app grab will suffice.
592 // will suffice.
593 do_x_grab_ = !gdk_pointer_is_grabbed(); 590 do_x_grab_ = !gdk_pointer_is_grabbed();
591 if (do_x_grab_) {
592 // Install the grab on behalf our parent window if it and all of its
593 // ancestors are mapped; otherwise, just use ourselves (maybe we're being
594 // shown on behalf of an inactive tab).
595 GdkWindow* grab_window = gtk_widget_get_window(parent_);
596 if (!grab_window || !gdk_window_is_viewable(grab_window))
597 grab_window = gtk_widget_get_window(view_.get());
594 598
595 // Now grab all of X's input.
596 if (do_x_grab_) {
597 gdk_pointer_grab( 599 gdk_pointer_grab(
598 gtk_widget_get_window(parent_), 600 grab_window,
599 TRUE, // Only events outside of the window are reported with respect 601 TRUE, // Only events outside of the window are reported with
600 // to |parent_->window|. 602 // respect to |parent_->window|.
601 static_cast<GdkEventMask>(GDK_BUTTON_PRESS_MASK | 603 static_cast<GdkEventMask>(GDK_BUTTON_PRESS_MASK |
602 GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK), 604 GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK),
603 NULL, 605 NULL,
604 NULL, 606 NULL,
605 GDK_CURRENT_TIME); 607 GDK_CURRENT_TIME);
606 // We grab keyboard events too so things like alt+tab are eaten. 608 // 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); 609 gdk_keyboard_grab(grab_window, TRUE, GDK_CURRENT_TIME);
608 } 610 }
609 } 611 }
610 } 612 }
611 613
612 void RenderWidgetHostViewGtk::InitAsFullscreen( 614 void RenderWidgetHostViewGtk::InitAsFullscreen(
613 RenderWidgetHostView* /*reference_host_view*/) { 615 RenderWidgetHostView* /*reference_host_view*/) {
614 DoSharedInit(); 616 DoSharedInit();
615 617
616 is_fullscreen_ = true; 618 is_fullscreen_ = true;
617 GtkWindow* window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); 619 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); 1373 return new RenderWidgetHostViewGtk(widget);
1372 } 1374 }
1373 1375
1374 // static 1376 // static
1375 void content::RenderWidgetHostViewPort::GetDefaultScreenInfo( 1377 void content::RenderWidgetHostViewPort::GetDefaultScreenInfo(
1376 WebKit::WebScreenInfo* results) { 1378 WebKit::WebScreenInfo* results) {
1377 GdkWindow* gdk_window = 1379 GdkWindow* gdk_window =
1378 gdk_display_get_default_group(gdk_display_get_default()); 1380 gdk_display_get_default_group(gdk_display_get_default());
1379 content::GetScreenInfoFromNativeWindow(gdk_window, results); 1381 content::GetScreenInfoFromNativeWindow(gdk_window, results);
1380 } 1382 }
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