OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/renderer_host/render_widget_host_view_gtk.h" | 5 #include "chrome/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 "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 #include "chrome/browser/renderer_host/render_view_host.h" | 31 #include "chrome/browser/renderer_host/render_view_host.h" |
32 #include "chrome/browser/renderer_host/render_view_host_delegate.h" | 32 #include "chrome/browser/renderer_host/render_view_host_delegate.h" |
33 #include "chrome/browser/renderer_host/render_widget_host.h" | 33 #include "chrome/browser/renderer_host/render_widget_host.h" |
34 #include "chrome/browser/ui/gtk/gtk_util.h" | 34 #include "chrome/browser/ui/gtk/gtk_util.h" |
35 #include "chrome/common/chrome_switches.h" | 35 #include "chrome/common/chrome_switches.h" |
36 #include "chrome/common/native_web_keyboard_event.h" | 36 #include "chrome/common/native_web_keyboard_event.h" |
37 #include "third_party/WebKit/Source/WebKit/chromium/public/gtk/WebInputEventFact
ory.h" | 37 #include "third_party/WebKit/Source/WebKit/chromium/public/gtk/WebInputEventFact
ory.h" |
38 #include "ui/base/l10n/l10n_util.h" | 38 #include "ui/base/l10n/l10n_util.h" |
39 #include "ui/base/x/x11_util.h" | 39 #include "ui/base/x/x11_util.h" |
40 #include "ui/gfx/gtk_preserve_window.h" | 40 #include "ui/gfx/gtk_preserve_window.h" |
| 41 #include "ui/gfx/gtk_native_view_id_manager.h" |
41 #include "webkit/glue/webaccessibility.h" | 42 #include "webkit/glue/webaccessibility.h" |
42 #include "webkit/glue/webcursor_gtk_data.h" | 43 #include "webkit/glue/webcursor_gtk_data.h" |
43 #include "webkit/plugins/npapi/webplugin.h" | 44 #include "webkit/plugins/npapi/webplugin.h" |
44 | 45 |
45 #if defined(OS_CHROMEOS) | 46 #if defined(OS_CHROMEOS) |
46 #include "views/widget/tooltip_window_gtk.h" | 47 #include "views/widget/tooltip_window_gtk.h" |
47 #endif // defined(OS_CHROMEOS) | 48 #endif // defined(OS_CHROMEOS) |
48 | 49 |
49 namespace { | 50 namespace { |
50 | 51 |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 is_loading_(false), | 489 is_loading_(false), |
489 is_showing_context_menu_(false), | 490 is_showing_context_menu_(false), |
490 overlay_color_(0), | 491 overlay_color_(0), |
491 overlay_animation_(this), | 492 overlay_animation_(this), |
492 parent_(NULL), | 493 parent_(NULL), |
493 is_popup_first_mouse_release_(true), | 494 is_popup_first_mouse_release_(true), |
494 was_focused_before_grab_(false), | 495 was_focused_before_grab_(false), |
495 do_x_grab_(false), | 496 do_x_grab_(false), |
496 is_fullscreen_(false), | 497 is_fullscreen_(false), |
497 dragged_at_horizontal_edge_(0), | 498 dragged_at_horizontal_edge_(0), |
498 dragged_at_vertical_edge_(0) { | 499 dragged_at_vertical_edge_(0), |
| 500 accelerated_surface_acquired_(false) { |
499 host_->set_view(this); | 501 host_->set_view(this); |
500 } | 502 } |
501 | 503 |
502 RenderWidgetHostViewGtk::~RenderWidgetHostViewGtk() { | 504 RenderWidgetHostViewGtk::~RenderWidgetHostViewGtk() { |
503 view_.Destroy(); | 505 view_.Destroy(); |
504 } | 506 } |
505 | 507 |
506 void RenderWidgetHostViewGtk::InitAsChild() { | 508 void RenderWidgetHostViewGtk::InitAsChild() { |
507 DoSharedInit(); | 509 DoSharedInit(); |
508 overlay_animation_.SetDuration(kFadeEffectDuration); | 510 overlay_animation_.SetDuration(kFadeEffectDuration); |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 } | 727 } |
726 } | 728 } |
727 | 729 |
728 void RenderWidgetHostViewGtk::RenderViewGone(base::TerminationStatus status, | 730 void RenderWidgetHostViewGtk::RenderViewGone(base::TerminationStatus status, |
729 int error_code) { | 731 int error_code) { |
730 Destroy(); | 732 Destroy(); |
731 plugin_container_manager_.set_host_widget(NULL); | 733 plugin_container_manager_.set_host_widget(NULL); |
732 } | 734 } |
733 | 735 |
734 void RenderWidgetHostViewGtk::Destroy() { | 736 void RenderWidgetHostViewGtk::Destroy() { |
| 737 if (accelerated_surface_acquired_) { |
| 738 GtkNativeViewManager* manager = GtkNativeViewManager::GetInstance(); |
| 739 gfx::NativeViewId view_id = gfx::IdFromNativeView(GetNativeView()); |
| 740 gfx::PluginWindowHandle surface = manager->GetXIDForId(&surface, view_id); |
| 741 manager->ReleasePermanentXID(surface); |
| 742 } |
| 743 |
735 if (do_x_grab_) { | 744 if (do_x_grab_) { |
736 // Undo the X grab. | 745 // Undo the X grab. |
737 GdkDisplay* display = gtk_widget_get_display(parent_); | 746 GdkDisplay* display = gtk_widget_get_display(parent_); |
738 gdk_display_pointer_ungrab(display, GDK_CURRENT_TIME); | 747 gdk_display_pointer_ungrab(display, GDK_CURRENT_TIME); |
739 gdk_display_keyboard_ungrab(display, GDK_CURRENT_TIME); | 748 gdk_display_keyboard_ungrab(display, GDK_CURRENT_TIME); |
740 } | 749 } |
741 | 750 |
742 // If this is a popup or fullscreen widget, then we need to destroy the window | 751 // If this is a popup or fullscreen widget, then we need to destroy the window |
743 // that we created to hold it. | 752 // that we created to hold it. |
744 if (IsPopup() || is_fullscreen_) | 753 if (IsPopup() || is_fullscreen_) |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1064 return false; | 1073 return false; |
1065 } | 1074 } |
1066 | 1075 |
1067 void RenderWidgetHostViewGtk::AcceleratedCompositingActivated(bool activated) { | 1076 void RenderWidgetHostViewGtk::AcceleratedCompositingActivated(bool activated) { |
1068 GtkPreserveWindow* widget = | 1077 GtkPreserveWindow* widget = |
1069 reinterpret_cast<GtkPreserveWindow*>(view_.get()); | 1078 reinterpret_cast<GtkPreserveWindow*>(view_.get()); |
1070 | 1079 |
1071 gtk_preserve_window_delegate_resize(widget, activated); | 1080 gtk_preserve_window_delegate_resize(widget, activated); |
1072 } | 1081 } |
1073 | 1082 |
| 1083 gfx::PluginWindowHandle RenderWidgetHostViewGtk::AcquireCompositingSurface() { |
| 1084 GtkNativeViewManager* manager = GtkNativeViewManager::GetInstance(); |
| 1085 gfx::PluginWindowHandle surface = gfx::kNullPluginWindow; |
| 1086 gfx::NativeViewId view_id = gfx::IdFromNativeView(GetNativeView()); |
| 1087 |
| 1088 if (!manager->GetPermanentXIDForId(&surface, view_id)) { |
| 1089 DLOG(ERROR) << "Can't find XID for view id " << view_id; |
| 1090 } else { |
| 1091 accelerated_surface_acquired_ = true; |
| 1092 } |
| 1093 return surface; |
| 1094 } |
| 1095 |
| 1096 void RenderWidgetHostViewGtk::ReleaseCompositingSurface( |
| 1097 gfx::PluginWindowHandle surface) { |
| 1098 GtkNativeViewManager* manager = GtkNativeViewManager::GetInstance(); |
| 1099 manager->ReleasePermanentXID(surface); |
| 1100 accelerated_surface_acquired_ = false; |
| 1101 } |
| 1102 |
1074 void RenderWidgetHostViewGtk::ForwardKeyboardEvent( | 1103 void RenderWidgetHostViewGtk::ForwardKeyboardEvent( |
1075 const NativeWebKeyboardEvent& event) { | 1104 const NativeWebKeyboardEvent& event) { |
1076 if (!host_) | 1105 if (!host_) |
1077 return; | 1106 return; |
1078 | 1107 |
1079 EditCommands edit_commands; | 1108 EditCommands edit_commands; |
1080 if (!event.skip_in_browser && | 1109 if (!event.skip_in_browser && |
1081 key_bindings_handler_->Match(event, &edit_commands)) { | 1110 key_bindings_handler_->Match(event, &edit_commands)) { |
1082 host_->ForwardEditCommandsForNextKeyEvent(edit_commands); | 1111 host_->ForwardEditCommandsForNextKeyEvent(edit_commands); |
1083 NativeWebKeyboardEvent copy_event(event); | 1112 NativeWebKeyboardEvent copy_event(event); |
(...skipping 20 matching lines...) Expand all Loading... |
1104 } | 1133 } |
1105 | 1134 |
1106 // static | 1135 // static |
1107 RenderWidgetHostView* | 1136 RenderWidgetHostView* |
1108 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( | 1137 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( |
1109 gfx::NativeView widget) { | 1138 gfx::NativeView widget) { |
1110 gpointer user_data = g_object_get_data(G_OBJECT(widget), | 1139 gpointer user_data = g_object_get_data(G_OBJECT(widget), |
1111 kRenderWidgetHostViewKey); | 1140 kRenderWidgetHostViewKey); |
1112 return reinterpret_cast<RenderWidgetHostView*>(user_data); | 1141 return reinterpret_cast<RenderWidgetHostView*>(user_data); |
1113 } | 1142 } |
OLD | NEW |