Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 588 RenderWidgetHostView* parent_host_view, const gfx::Rect& pos) { | 588 RenderWidgetHostView* parent_host_view, const gfx::Rect& pos) { |
| 589 // If we aren't a popup, then |window| will be leaked. | 589 // If we aren't a popup, then |window| will be leaked. |
| 590 DCHECK(IsPopup()); | 590 DCHECK(IsPopup()); |
| 591 | 591 |
| 592 DoSharedInit(); | 592 DoSharedInit(); |
| 593 parent_ = parent_host_view->GetNativeView(); | 593 parent_ = parent_host_view->GetNativeView(); |
| 594 GtkWindow* window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_POPUP)); | 594 GtkWindow* window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_POPUP)); |
| 595 gtk_container_add(GTK_CONTAINER(window), view_.get()); | 595 gtk_container_add(GTK_CONTAINER(window), view_.get()); |
| 596 DoPopupOrFullscreenInit(window, pos); | 596 DoPopupOrFullscreenInit(window, pos); |
| 597 | 597 |
| 598 // The underlying X window needs to be created and mapped by the above code | 598 // Grab all input for the app. If a click lands outside the bounds of the |
| 599 // before we can grab the input devices. | 599 // popup, WebKit will notice and destroy us. The underlying X window needs to |
| 600 // be created and mapped by the above code before we can grab the input | |
| 601 // devices. | |
| 600 if (NeedsInputGrab()) { | 602 if (NeedsInputGrab()) { |
| 601 // Grab all input for the app. If a click lands outside the bounds of the | 603 // Install an application-level GTK grab to make sure that we receive all of |
| 602 // popup, WebKit will notice and destroy us. Before doing this we need | 604 // the app's input. |
| 603 // to ensure that the the popup is added to the browser's window group, | |
| 604 // to allow for the grabs to work correctly. | |
| 605 gtk_window_group_add_window(gtk_window_get_group( | |
| 606 GTK_WINDOW(gtk_widget_get_toplevel(parent_))), window); | |
| 607 gtk_grab_add(view_.get()); | 605 gtk_grab_add(view_.get()); |
| 608 | 606 |
| 609 // We need for the application to do an X grab as well. However if the app | 607 // We need to install an X grab as well. However if the app already has an X |
| 610 // already has an X grab (as in the case of extension popup), an app grab | 608 // grab (as in the case of extension popup), an app grab will suffice. |
| 611 // will suffice. | |
| 612 do_x_grab_ = !gdk_pointer_is_grabbed(); | 609 do_x_grab_ = !gdk_pointer_is_grabbed(); |
| 610 if (do_x_grab_) { | |
| 611 // Install the grab on behalf our parent window if it and all of its | |
| 612 // ancestors are mapped; otherwise, just use ourselves (maybe we're being | |
| 613 // 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
| |
| 614 GdkWindow* grab_window = gtk_widget_get_window(parent_); | |
| 615 if (!grab_window || !gdk_window_is_viewable(grab_window)) | |
| 616 grab_window = gtk_widget_get_window(view_.get()); | |
| 613 | 617 |
| 614 // Now grab all of X's input. | |
| 615 if (do_x_grab_) { | |
| 616 gdk_pointer_grab( | 618 gdk_pointer_grab( |
| 617 gtk_widget_get_window(parent_), | 619 grab_window, |
| 618 TRUE, // Only events outside of the window are reported with respect | 620 TRUE, // Only events outside of the window are reported with |
| 619 // to |parent_->window|. | 621 // respect to |parent_->window|. |
| 620 static_cast<GdkEventMask>(GDK_BUTTON_PRESS_MASK | | 622 static_cast<GdkEventMask>(GDK_BUTTON_PRESS_MASK | |
| 621 GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK), | 623 GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK), |
| 622 NULL, | 624 NULL, |
| 623 NULL, | 625 NULL, |
| 624 GDK_CURRENT_TIME); | 626 GDK_CURRENT_TIME); |
| 625 // We grab keyboard events too so things like alt+tab are eaten. | 627 // We grab keyboard events too so things like alt+tab are eaten. |
| 626 gdk_keyboard_grab(gtk_widget_get_window(parent_), TRUE, GDK_CURRENT_TIME); | 628 gdk_keyboard_grab(grab_window, TRUE, GDK_CURRENT_TIME); |
| 627 } | 629 } |
| 628 } | 630 } |
| 629 } | 631 } |
| 630 | 632 |
| 631 void RenderWidgetHostViewGtk::InitAsFullscreen( | 633 void RenderWidgetHostViewGtk::InitAsFullscreen( |
| 632 RenderWidgetHostView* /*reference_host_view*/) { | 634 RenderWidgetHostView* /*reference_host_view*/) { |
| 633 DoSharedInit(); | 635 DoSharedInit(); |
| 634 | 636 |
| 635 is_fullscreen_ = true; | 637 is_fullscreen_ = true; |
| 636 GtkWindow* window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); | 638 GtkWindow* window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); |
| (...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1398 return new RenderWidgetHostViewGtk(widget); | 1400 return new RenderWidgetHostViewGtk(widget); |
| 1399 } | 1401 } |
| 1400 | 1402 |
| 1401 // static | 1403 // static |
| 1402 void content::RenderWidgetHostViewPort::GetDefaultScreenInfo( | 1404 void content::RenderWidgetHostViewPort::GetDefaultScreenInfo( |
| 1403 WebKit::WebScreenInfo* results) { | 1405 WebKit::WebScreenInfo* results) { |
| 1404 GdkWindow* gdk_window = | 1406 GdkWindow* gdk_window = |
| 1405 gdk_display_get_default_group(gdk_display_get_default()); | 1407 gdk_display_get_default_group(gdk_display_get_default()); |
| 1406 content::GetScreenInfoFromNativeWindow(gdk_window, results); | 1408 content::GetScreenInfoFromNativeWindow(gdk_window, results); |
| 1407 } | 1409 } |
| OLD | NEW |