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 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 // Grab all input for the app. If a click lands outside the bounds of the | 599 // The underlying X window needs to be created and mapped by the above code |
600 // popup, WebKit will notice and destroy us. The underlying X window needs to | 600 // before we can grab the input devices. |
601 // be created and mapped by the above code before we can grab the input | |
602 // devices. | |
603 if (NeedsInputGrab()) { | 601 if (NeedsInputGrab()) { |
604 // Install an application-level GTK grab to make sure that we receive all of | 602 // Grab all input for the app. If a click lands outside the bounds of the |
605 // the app's input. | 603 // popup, WebKit will notice and destroy us. Before doing this we need |
| 604 // to ensure that the the popup is added to the browser's window group, |
| 605 // to allow for the grabs to work correctly. |
| 606 gtk_window_group_add_window(gtk_window_get_group( |
| 607 GTK_WINDOW(gtk_widget_get_toplevel(parent_))), window); |
606 gtk_grab_add(view_.get()); | 608 gtk_grab_add(view_.get()); |
607 | 609 |
608 // We need to install an X grab as well. However if the app already has an X | 610 // We need for the application to do an X grab as well. However if the app |
609 // grab (as in the case of extension popup), an app grab will suffice. | 611 // already has an X grab (as in the case of extension popup), an app grab |
| 612 // will suffice. |
610 do_x_grab_ = !gdk_pointer_is_grabbed(); | 613 do_x_grab_ = !gdk_pointer_is_grabbed(); |
| 614 |
| 615 // Now grab all of X's input. |
611 if (do_x_grab_) { | 616 if (do_x_grab_) { |
612 // Install the grab on behalf our parent window if it and all of its | |
613 // ancestors are mapped; otherwise, just use ourselves (maybe we're being | |
614 // shown on behalf of an inactive tab). | |
615 GdkWindow* grab_window = gtk_widget_get_window(parent_); | |
616 if (!grab_window || !gdk_window_is_viewable(grab_window)) | |
617 grab_window = gtk_widget_get_window(view_.get()); | |
618 | |
619 gdk_pointer_grab( | 617 gdk_pointer_grab( |
620 grab_window, | 618 gtk_widget_get_window(parent_), |
621 TRUE, // Only events outside of the window are reported with | 619 TRUE, // Only events outside of the window are reported with respect |
622 // respect to |parent_->window|. | 620 // to |parent_->window|. |
623 static_cast<GdkEventMask>(GDK_BUTTON_PRESS_MASK | | 621 static_cast<GdkEventMask>(GDK_BUTTON_PRESS_MASK | |
624 GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK), | 622 GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK), |
625 NULL, | 623 NULL, |
626 NULL, | 624 NULL, |
627 GDK_CURRENT_TIME); | 625 GDK_CURRENT_TIME); |
628 // We grab keyboard events too so things like alt+tab are eaten. | 626 // We grab keyboard events too so things like alt+tab are eaten. |
629 gdk_keyboard_grab(grab_window, TRUE, GDK_CURRENT_TIME); | 627 gdk_keyboard_grab(gtk_widget_get_window(parent_), TRUE, GDK_CURRENT_TIME); |
630 } | 628 } |
631 } | 629 } |
632 } | 630 } |
633 | 631 |
634 void RenderWidgetHostViewGtk::InitAsFullscreen( | 632 void RenderWidgetHostViewGtk::InitAsFullscreen( |
635 RenderWidgetHostView* /*reference_host_view*/) { | 633 RenderWidgetHostView* /*reference_host_view*/) { |
636 DoSharedInit(); | 634 DoSharedInit(); |
637 | 635 |
638 is_fullscreen_ = true; | 636 is_fullscreen_ = true; |
639 GtkWindow* window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); | 637 GtkWindow* window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); |
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1472 browser_accessibility_manager_.reset( | 1470 browser_accessibility_manager_.reset( |
1473 BrowserAccessibilityManager::CreateEmptyDocument( | 1471 BrowserAccessibilityManager::CreateEmptyDocument( |
1474 parent, static_cast<WebAccessibility::State>(0), this)); | 1472 parent, static_cast<WebAccessibility::State>(0), this)); |
1475 } | 1473 } |
1476 BrowserAccessibilityGtk* root = | 1474 BrowserAccessibilityGtk* root = |
1477 browser_accessibility_manager_->GetRoot()->ToBrowserAccessibilityGtk(); | 1475 browser_accessibility_manager_->GetRoot()->ToBrowserAccessibilityGtk(); |
1478 | 1476 |
1479 atk_object_set_role(root->GetAtkObject(), ATK_ROLE_HTML_CONTAINER); | 1477 atk_object_set_role(root->GetAtkObject(), ATK_ROLE_HTML_CONTAINER); |
1480 return root->GetAtkObject(); | 1478 return root->GetAtkObject(); |
1481 } | 1479 } |
OLD | NEW |