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 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 579 RenderWidgetHostView* parent_host_view, const gfx::Rect& pos) { | 579 RenderWidgetHostView* parent_host_view, const gfx::Rect& pos) { |
| 580 // If we aren't a popup, then |window| will be leaked. | 580 // If we aren't a popup, then |window| will be leaked. |
| 581 DCHECK(IsPopup()); | 581 DCHECK(IsPopup()); |
| 582 | 582 |
| 583 DoSharedInit(); | 583 DoSharedInit(); |
| 584 parent_ = parent_host_view->GetNativeView(); | 584 parent_ = parent_host_view->GetNativeView(); |
| 585 GtkWindow* window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_POPUP)); | 585 GtkWindow* window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_POPUP)); |
| 586 gtk_container_add(GTK_CONTAINER(window), view_.get()); | 586 gtk_container_add(GTK_CONTAINER(window), view_.get()); |
| 587 DoPopupOrFullscreenInit(window, pos); | 587 DoPopupOrFullscreenInit(window, pos); |
| 588 | 588 |
| 589 // The underlying X window needs to be created and mapped by the above code | 589 // Grab all input for the app. If a click lands outside the bounds of the |
| 590 // before we can grab the input devices. | 590 // popup, WebKit will notice and destroy us. The underlying X window needs to |
| 591 // be created and mapped by the above code before we can grab the input | |
| 592 // devices. | |
| 591 if (NeedsInputGrab()) { | 593 if (NeedsInputGrab()) { |
| 592 // Grab all input for the app. If a click lands outside the bounds of the | 594 // If our parent isn't a child of a toplevel window (e.g. it's an inactive |
| 593 // popup, WebKit will notice and destroy us. Before doing this we need | 595 // tab), skip the grab. |
|
Evan Stade
2012/05/08 00:01:13
how does the popup window know to close if there's
Daniel Erat
2012/05/08 00:11:56
Hmm, it doesn't get closed until I click on an ite
| |
| 594 // to ensure that the the popup is added to the browser's window group, | 596 GtkWidget* toplevel = gtk_widget_get_toplevel(parent_); |
| 595 // to allow for the grabs to work correctly. | 597 if (gtk_widget_is_toplevel(toplevel) && GTK_IS_WINDOW(toplevel)) { |
| 596 gtk_window_group_add_window(gtk_window_get_group( | 598 // Ensure that the the popup is added to the browser's window group, to |
| 597 GTK_WINDOW(gtk_widget_get_toplevel(parent_))), window); | 599 // allow for the grabs to work correctly. |
| 598 gtk_grab_add(view_.get()); | 600 gtk_window_group_add_window(gtk_window_get_group(GTK_WINDOW(toplevel)), |
| 601 window); | |
| 602 gtk_grab_add(view_.get()); | |
| 599 | 603 |
| 600 // We need for the application to do an X grab as well. However if the app | 604 // We need for the application to do an X grab as well. However if the app |
| 601 // already has an X grab (as in the case of extension popup), an app grab | 605 // already has an X grab (as in the case of extension popup), an app grab |
| 602 // will suffice. | 606 // will suffice. |
| 603 do_x_grab_ = !gdk_pointer_is_grabbed(); | 607 do_x_grab_ = !gdk_pointer_is_grabbed(); |
| 604 | 608 |
| 605 // Now grab all of X's input. | 609 // Now grab all of X's input. |
| 606 if (do_x_grab_) { | 610 if (do_x_grab_) { |
| 607 gdk_pointer_grab( | 611 gdk_pointer_grab( |
| 608 gtk_widget_get_window(parent_), | 612 gtk_widget_get_window(parent_), |
| 609 TRUE, // Only events outside of the window are reported with respect | 613 TRUE, // Only events outside of the window are reported with |
| 610 // to |parent_->window|. | 614 // respect to |parent_->window|. |
| 611 static_cast<GdkEventMask>(GDK_BUTTON_PRESS_MASK | | 615 static_cast<GdkEventMask>(GDK_BUTTON_PRESS_MASK | |
| 612 GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK), | 616 GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK), |
| 613 NULL, | 617 NULL, |
| 614 NULL, | 618 NULL, |
| 615 GDK_CURRENT_TIME); | 619 GDK_CURRENT_TIME); |
| 616 // We grab keyboard events too so things like alt+tab are eaten. | 620 // We grab keyboard events too so things like alt+tab are eaten. |
| 617 gdk_keyboard_grab(gtk_widget_get_window(parent_), TRUE, GDK_CURRENT_TIME); | 621 gdk_keyboard_grab(gtk_widget_get_window(parent_), |
| 622 TRUE, // owner_events | |
| 623 GDK_CURRENT_TIME); | |
| 624 } | |
| 618 } | 625 } |
| 619 } | 626 } |
| 620 } | 627 } |
| 621 | 628 |
| 622 void RenderWidgetHostViewGtk::InitAsFullscreen( | 629 void RenderWidgetHostViewGtk::InitAsFullscreen( |
| 623 RenderWidgetHostView* /*reference_host_view*/) { | 630 RenderWidgetHostView* /*reference_host_view*/) { |
| 624 DoSharedInit(); | 631 DoSharedInit(); |
| 625 | 632 |
| 626 is_fullscreen_ = true; | 633 is_fullscreen_ = true; |
| 627 GtkWindow* window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); | 634 GtkWindow* window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); |
| (...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1397 return new RenderWidgetHostViewGtk(widget); | 1404 return new RenderWidgetHostViewGtk(widget); |
| 1398 } | 1405 } |
| 1399 | 1406 |
| 1400 // static | 1407 // static |
| 1401 void content::RenderWidgetHostViewPort::GetDefaultScreenInfo( | 1408 void content::RenderWidgetHostViewPort::GetDefaultScreenInfo( |
| 1402 WebKit::WebScreenInfo* results) { | 1409 WebKit::WebScreenInfo* results) { |
| 1403 GdkWindow* gdk_window = | 1410 GdkWindow* gdk_window = |
| 1404 gdk_display_get_default_group(gdk_display_get_default()); | 1411 gdk_display_get_default_group(gdk_display_get_default()); |
| 1405 content::GetScreenInfoFromNativeWindow(gdk_window, results); | 1412 content::GetScreenInfoFromNativeWindow(gdk_window, results); |
| 1406 } | 1413 } |
| OLD | NEW |