| 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 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 overlay_color_(0), | 506 overlay_color_(0), |
| 507 overlay_animation_(this), | 507 overlay_animation_(this), |
| 508 parent_(NULL), | 508 parent_(NULL), |
| 509 is_popup_first_mouse_release_(true), | 509 is_popup_first_mouse_release_(true), |
| 510 was_focused_before_grab_(false), | 510 was_focused_before_grab_(false), |
| 511 do_x_grab_(false), | 511 do_x_grab_(false), |
| 512 is_fullscreen_(false), | 512 is_fullscreen_(false), |
| 513 destroy_handler_id_(0), | 513 destroy_handler_id_(0), |
| 514 dragged_at_horizontal_edge_(0), | 514 dragged_at_horizontal_edge_(0), |
| 515 dragged_at_vertical_edge_(0), | 515 dragged_at_vertical_edge_(0), |
| 516 accelerated_surface_acquired_(false), | 516 compositing_surface_(gfx::kNullPluginWindow), |
| 517 last_mouse_down_(NULL) { | 517 last_mouse_down_(NULL) { |
| 518 host_->set_view(this); | 518 host_->set_view(this); |
| 519 } | 519 } |
| 520 | 520 |
| 521 RenderWidgetHostViewGtk::~RenderWidgetHostViewGtk() { | 521 RenderWidgetHostViewGtk::~RenderWidgetHostViewGtk() { |
| 522 set_last_mouse_down(NULL); | 522 set_last_mouse_down(NULL); |
| 523 view_.Destroy(); | 523 view_.Destroy(); |
| 524 } | 524 } |
| 525 | 525 |
| 526 void RenderWidgetHostViewGtk::InitAsChild() { | 526 void RenderWidgetHostViewGtk::InitAsChild() { |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 } | 763 } |
| 764 } | 764 } |
| 765 | 765 |
| 766 void RenderWidgetHostViewGtk::RenderViewGone(base::TerminationStatus status, | 766 void RenderWidgetHostViewGtk::RenderViewGone(base::TerminationStatus status, |
| 767 int error_code) { | 767 int error_code) { |
| 768 Destroy(); | 768 Destroy(); |
| 769 plugin_container_manager_.set_host_widget(NULL); | 769 plugin_container_manager_.set_host_widget(NULL); |
| 770 } | 770 } |
| 771 | 771 |
| 772 void RenderWidgetHostViewGtk::Destroy() { | 772 void RenderWidgetHostViewGtk::Destroy() { |
| 773 if (accelerated_surface_acquired_) { | 773 if (compositing_surface_ != gfx::kNullPluginWindow) { |
| 774 GtkNativeViewManager* manager = GtkNativeViewManager::GetInstance(); | 774 GtkNativeViewManager* manager = GtkNativeViewManager::GetInstance(); |
| 775 gfx::NativeViewId view_id = gfx::IdFromNativeView(GetNativeView()); | 775 manager->ReleasePermanentXID(compositing_surface_); |
| 776 gfx::PluginWindowHandle surface = manager->GetXIDForId(&surface, view_id); | |
| 777 manager->ReleasePermanentXID(surface); | |
| 778 } | 776 } |
| 779 | 777 |
| 780 if (do_x_grab_) { | 778 if (do_x_grab_) { |
| 781 // Undo the X grab. | 779 // Undo the X grab. |
| 782 GdkDisplay* display = gtk_widget_get_display(parent_); | 780 GdkDisplay* display = gtk_widget_get_display(parent_); |
| 783 gdk_display_pointer_ungrab(display, GDK_CURRENT_TIME); | 781 gdk_display_pointer_ungrab(display, GDK_CURRENT_TIME); |
| 784 gdk_display_keyboard_ungrab(display, GDK_CURRENT_TIME); | 782 gdk_display_keyboard_ungrab(display, GDK_CURRENT_TIME); |
| 785 } | 783 } |
| 786 | 784 |
| 787 // If this is a popup or fullscreen widget, then we need to destroy the window | 785 // If this is a popup or fullscreen widget, then we need to destroy the window |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1121 return false; | 1119 return false; |
| 1122 } | 1120 } |
| 1123 | 1121 |
| 1124 void RenderWidgetHostViewGtk::AcceleratedCompositingActivated(bool activated) { | 1122 void RenderWidgetHostViewGtk::AcceleratedCompositingActivated(bool activated) { |
| 1125 GtkPreserveWindow* widget = | 1123 GtkPreserveWindow* widget = |
| 1126 reinterpret_cast<GtkPreserveWindow*>(view_.get()); | 1124 reinterpret_cast<GtkPreserveWindow*>(view_.get()); |
| 1127 | 1125 |
| 1128 gtk_preserve_window_delegate_resize(widget, activated); | 1126 gtk_preserve_window_delegate_resize(widget, activated); |
| 1129 } | 1127 } |
| 1130 | 1128 |
| 1131 gfx::PluginWindowHandle RenderWidgetHostViewGtk::AcquireCompositingSurface() { | 1129 gfx::PluginWindowHandle RenderWidgetHostViewGtk::GetCompositingSurface() { |
| 1132 GtkNativeViewManager* manager = GtkNativeViewManager::GetInstance(); | 1130 if (compositing_surface_ == gfx::kNullPluginWindow) { |
| 1133 gfx::PluginWindowHandle surface = gfx::kNullPluginWindow; | 1131 GtkNativeViewManager* manager = GtkNativeViewManager::GetInstance(); |
| 1134 gfx::NativeViewId view_id = gfx::IdFromNativeView(GetNativeView()); | 1132 gfx::NativeViewId view_id = gfx::IdFromNativeView(GetNativeView()); |
| 1135 | 1133 |
| 1136 if (!manager->GetPermanentXIDForId(&surface, view_id)) { | 1134 if (!manager->GetPermanentXIDForId(&compositing_surface_, view_id)) { |
| 1137 DLOG(ERROR) << "Can't find XID for view id " << view_id; | 1135 DLOG(ERROR) << "Can't find XID for view id " << view_id; |
| 1138 } else { | 1136 } |
| 1139 accelerated_surface_acquired_ = true; | |
| 1140 } | 1137 } |
| 1141 return surface; | 1138 return compositing_surface_; |
| 1142 } | |
| 1143 | |
| 1144 void RenderWidgetHostViewGtk::ReleaseCompositingSurface( | |
| 1145 gfx::PluginWindowHandle surface) { | |
| 1146 GtkNativeViewManager* manager = GtkNativeViewManager::GetInstance(); | |
| 1147 manager->ReleasePermanentXID(surface); | |
| 1148 accelerated_surface_acquired_ = false; | |
| 1149 } | 1139 } |
| 1150 | 1140 |
| 1151 void RenderWidgetHostViewGtk::ForwardKeyboardEvent( | 1141 void RenderWidgetHostViewGtk::ForwardKeyboardEvent( |
| 1152 const NativeWebKeyboardEvent& event) { | 1142 const NativeWebKeyboardEvent& event) { |
| 1153 if (!host_) | 1143 if (!host_) |
| 1154 return; | 1144 return; |
| 1155 | 1145 |
| 1156 EditCommands edit_commands; | 1146 EditCommands edit_commands; |
| 1157 if (!event.skip_in_browser && | 1147 if (!event.skip_in_browser && |
| 1158 key_bindings_handler_->Match(event, &edit_commands)) { | 1148 key_bindings_handler_->Match(event, &edit_commands)) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1194 } | 1184 } |
| 1195 | 1185 |
| 1196 // static | 1186 // static |
| 1197 RenderWidgetHostView* | 1187 RenderWidgetHostView* |
| 1198 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( | 1188 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( |
| 1199 gfx::NativeView widget) { | 1189 gfx::NativeView widget) { |
| 1200 gpointer user_data = g_object_get_data(G_OBJECT(widget), | 1190 gpointer user_data = g_object_get_data(G_OBJECT(widget), |
| 1201 kRenderWidgetHostViewKey); | 1191 kRenderWidgetHostViewKey); |
| 1202 return reinterpret_cast<RenderWidgetHostView*>(user_data); | 1192 return reinterpret_cast<RenderWidgetHostView*>(user_data); |
| 1203 } | 1193 } |
| OLD | NEW |