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 "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 19 matching lines...) Expand all Loading... |
30 #include "content/browser/renderer_host/gtk_window_utils.h" | 30 #include "content/browser/renderer_host/gtk_window_utils.h" |
31 #include "content/browser/renderer_host/render_view_host.h" | 31 #include "content/browser/renderer_host/render_view_host.h" |
32 #include "content/browser/renderer_host/render_view_host_delegate.h" | 32 #include "content/browser/renderer_host/render_view_host_delegate.h" |
33 #include "content/browser/renderer_host/render_widget_host.h" | 33 #include "content/browser/renderer_host/render_widget_host.h" |
34 #include "content/public/browser/native_web_keyboard_event.h" | 34 #include "content/public/browser/native_web_keyboard_event.h" |
35 #include "content/public/common/content_switches.h" | 35 #include "content/public/common/content_switches.h" |
36 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 36 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
37 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" | 37 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" |
38 #include "third_party/WebKit/Source/WebKit/chromium/public/gtk/WebInputEventFact
ory.h" | 38 #include "third_party/WebKit/Source/WebKit/chromium/public/gtk/WebInputEventFact
ory.h" |
39 #include "third_party/WebKit/Source/WebKit/chromium/public/x11/WebScreenInfoFact
ory.h" | 39 #include "third_party/WebKit/Source/WebKit/chromium/public/x11/WebScreenInfoFact
ory.h" |
| 40 #include "ui/base/gtk/gtk_compat.h" |
40 #include "ui/base/text/text_elider.h" | 41 #include "ui/base/text/text_elider.h" |
41 #include "ui/base/x/x11_util.h" | 42 #include "ui/base/x/x11_util.h" |
42 #include "ui/gfx/gtk_native_view_id_manager.h" | 43 #include "ui/gfx/gtk_native_view_id_manager.h" |
43 #include "ui/gfx/gtk_preserve_window.h" | 44 #include "ui/gfx/gtk_preserve_window.h" |
44 #include "webkit/glue/webaccessibility.h" | 45 #include "webkit/glue/webaccessibility.h" |
45 #include "webkit/glue/webcursor_gtk_data.h" | 46 #include "webkit/glue/webcursor_gtk_data.h" |
46 #include "webkit/plugins/npapi/webplugin.h" | 47 #include "webkit/plugins/npapi/webplugin.h" |
47 | 48 |
48 #if defined(OS_CHROMEOS) | 49 #if defined(OS_CHROMEOS) |
49 #include "ui/base/gtk/tooltip_window_gtk.h" | 50 #include "ui/base/gtk/tooltip_window_gtk.h" |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 host_view->im_context_->OnFocusIn(); | 234 host_view->im_context_->OnFocusIn(); |
234 | 235 |
235 return TRUE; | 236 return TRUE; |
236 } | 237 } |
237 | 238 |
238 static gboolean OnFocusOut(GtkWidget* widget, | 239 static gboolean OnFocusOut(GtkWidget* widget, |
239 GdkEventFocus* focus, | 240 GdkEventFocus* focus, |
240 RenderWidgetHostViewGtk* host_view) { | 241 RenderWidgetHostViewGtk* host_view) { |
241 // Whenever we lose focus, set the cursor back to that of our parent window, | 242 // Whenever we lose focus, set the cursor back to that of our parent window, |
242 // which should be the default arrow. | 243 // which should be the default arrow. |
243 gdk_window_set_cursor(widget->window, NULL); | 244 gdk_window_set_cursor(gtk_widget_get_window(widget), NULL); |
244 // If we are showing a context menu, maintain the illusion that webkit has | 245 // If we are showing a context menu, maintain the illusion that webkit has |
245 // focus. | 246 // focus. |
246 if (!host_view->is_showing_context_menu_) { | 247 if (!host_view->is_showing_context_menu_) { |
247 host_view->GetRenderWidgetHost()->SetActive(false); | 248 host_view->GetRenderWidgetHost()->SetActive(false); |
248 host_view->GetRenderWidgetHost()->Blur(); | 249 host_view->GetRenderWidgetHost()->Blur(); |
249 } | 250 } |
250 | 251 |
251 // Prevents us from stealing input context focus in OnGrabNotify() handler. | 252 // Prevents us from stealing input context focus in OnGrabNotify() handler. |
252 host_view->was_imcontext_focused_before_grab_ = false; | 253 host_view->was_imcontext_focused_before_grab_ = false; |
253 | 254 |
254 // Disable the GtkIMContext object. | 255 // Disable the GtkIMContext object. |
255 host_view->im_context_->OnFocusOut(); | 256 host_view->im_context_->OnFocusOut(); |
256 | 257 |
257 return TRUE; | 258 return TRUE; |
258 } | 259 } |
259 | 260 |
260 // Called when we are shadowed or unshadowed by a keyboard grab (which will | 261 // Called when we are shadowed or unshadowed by a keyboard grab (which will |
261 // occur for activatable popups, such as dropdown menus). Popup windows do not | 262 // occur for activatable popups, such as dropdown menus). Popup windows do not |
262 // take focus, so we never get a focus out or focus in event when they are | 263 // take focus, so we never get a focus out or focus in event when they are |
263 // shown, and must rely on this signal instead. | 264 // shown, and must rely on this signal instead. |
264 static void OnGrabNotify(GtkWidget* widget, gboolean was_grabbed, | 265 static void OnGrabNotify(GtkWidget* widget, gboolean was_grabbed, |
265 RenderWidgetHostViewGtk* host_view) { | 266 RenderWidgetHostViewGtk* host_view) { |
266 if (was_grabbed) { | 267 if (was_grabbed) { |
267 if (host_view->was_imcontext_focused_before_grab_) | 268 if (host_view->was_imcontext_focused_before_grab_) |
268 host_view->im_context_->OnFocusIn(); | 269 host_view->im_context_->OnFocusIn(); |
269 } else { | 270 } else { |
270 host_view->was_imcontext_focused_before_grab_ = | 271 host_view->was_imcontext_focused_before_grab_ = |
271 host_view->im_context_->is_focused(); | 272 host_view->im_context_->is_focused(); |
272 if (host_view->was_imcontext_focused_before_grab_) { | 273 if (host_view->was_imcontext_focused_before_grab_) { |
273 gdk_window_set_cursor(widget->window, NULL); | 274 gdk_window_set_cursor(gtk_widget_get_window(widget), NULL); |
274 host_view->im_context_->OnFocusOut(); | 275 host_view->im_context_->OnFocusOut(); |
275 } | 276 } |
276 } | 277 } |
277 } | 278 } |
278 | 279 |
279 static gboolean OnButtonPressReleaseEvent( | 280 static gboolean OnButtonPressReleaseEvent( |
280 GtkWidget* widget, | 281 GtkWidget* widget, |
281 GdkEventButton* event, | 282 GdkEventButton* event, |
282 RenderWidgetHostViewGtk* host_view) { | 283 RenderWidgetHostViewGtk* host_view) { |
283 #if defined (OS_CHROMEOS) | 284 #if defined (OS_CHROMEOS) |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 // from this widget to be relative to the top left of the widget. | 334 // from this widget to be relative to the top left of the widget. |
334 GtkWidget* event_widget = gtk_get_event_widget( | 335 GtkWidget* event_widget = gtk_get_event_widget( |
335 reinterpret_cast<GdkEvent*>(event)); | 336 reinterpret_cast<GdkEvent*>(event)); |
336 if (event_widget != widget) { | 337 if (event_widget != widget) { |
337 int x = 0; | 338 int x = 0; |
338 int y = 0; | 339 int y = 0; |
339 gtk_widget_get_pointer(widget, &x, &y); | 340 gtk_widget_get_pointer(widget, &x, &y); |
340 // If the mouse event happens outside our popup, force the popup to | 341 // If the mouse event happens outside our popup, force the popup to |
341 // close. We do this so a hung renderer doesn't prevent us from | 342 // close. We do this so a hung renderer doesn't prevent us from |
342 // releasing the x pointer grab. | 343 // releasing the x pointer grab. |
343 bool click_in_popup = x >= 0 && y >= 0 && x < widget->allocation.width && | 344 GtkAllocation allocation; |
344 y < widget->allocation.height; | 345 gtk_widget_get_allocation(widget, &allocation); |
| 346 bool click_in_popup = x >= 0 && y >= 0 && x < allocation.width && |
| 347 y < allocation.height; |
345 // Only Shutdown on mouse downs. Mouse ups can occur outside the render | 348 // Only Shutdown on mouse downs. Mouse ups can occur outside the render |
346 // view if the user drags for DnD or while using the scrollbar on a select | 349 // view if the user drags for DnD or while using the scrollbar on a select |
347 // dropdown. Don't shutdown if we are not a popup. | 350 // dropdown. Don't shutdown if we are not a popup. |
348 if (event->type != GDK_BUTTON_RELEASE && host_view->IsPopup() && | 351 if (event->type != GDK_BUTTON_RELEASE && host_view->IsPopup() && |
349 !host_view->is_popup_first_mouse_release_ && !click_in_popup) { | 352 !host_view->is_popup_first_mouse_release_ && !click_in_popup) { |
350 host_view->host_->Shutdown(); | 353 host_view->host_->Shutdown(); |
351 return FALSE; | 354 return FALSE; |
352 } | 355 } |
353 event->x = x; | 356 event->x = x; |
354 event->y = y; | 357 event->y = y; |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 gtk_grab_add(view_.get()); | 618 gtk_grab_add(view_.get()); |
616 | 619 |
617 // We need for the application to do an X grab as well. However if the app | 620 // We need for the application to do an X grab as well. However if the app |
618 // already has an X grab (as in the case of extension popup), an app grab | 621 // already has an X grab (as in the case of extension popup), an app grab |
619 // will suffice. | 622 // will suffice. |
620 do_x_grab_ = !gdk_pointer_is_grabbed(); | 623 do_x_grab_ = !gdk_pointer_is_grabbed(); |
621 | 624 |
622 // Now grab all of X's input. | 625 // Now grab all of X's input. |
623 if (do_x_grab_) { | 626 if (do_x_grab_) { |
624 gdk_pointer_grab( | 627 gdk_pointer_grab( |
625 parent_->window, | 628 gtk_widget_get_window(parent_), |
626 TRUE, // Only events outside of the window are reported with respect | 629 TRUE, // Only events outside of the window are reported with respect |
627 // to |parent_->window|. | 630 // to |parent_->window|. |
628 static_cast<GdkEventMask>(GDK_BUTTON_PRESS_MASK | | 631 static_cast<GdkEventMask>(GDK_BUTTON_PRESS_MASK | |
629 GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK), | 632 GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK), |
630 NULL, | 633 NULL, |
631 NULL, | 634 NULL, |
632 GDK_CURRENT_TIME); | 635 GDK_CURRENT_TIME); |
633 // We grab keyboard events too so things like alt+tab are eaten. | 636 // We grab keyboard events too so things like alt+tab are eaten. |
634 gdk_keyboard_grab(parent_->window, TRUE, GDK_CURRENT_TIME); | 637 gdk_keyboard_grab(gtk_widget_get_window(parent_), TRUE, GDK_CURRENT_TIME); |
635 } | 638 } |
636 } | 639 } |
637 } | 640 } |
638 | 641 |
639 void RenderWidgetHostViewGtk::InitAsFullscreen( | 642 void RenderWidgetHostViewGtk::InitAsFullscreen( |
640 RenderWidgetHostView* /*reference_host_view*/) { | 643 RenderWidgetHostView* /*reference_host_view*/) { |
641 DoSharedInit(); | 644 DoSharedInit(); |
642 | 645 |
643 is_fullscreen_ = true; | 646 is_fullscreen_ = true; |
644 GtkWindow* window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); | 647 GtkWindow* window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 | 761 |
759 void RenderWidgetHostViewGtk::Hide() { | 762 void RenderWidgetHostViewGtk::Hide() { |
760 gtk_widget_hide(view_.get()); | 763 gtk_widget_hide(view_.get()); |
761 } | 764 } |
762 | 765 |
763 bool RenderWidgetHostViewGtk::IsShowing() { | 766 bool RenderWidgetHostViewGtk::IsShowing() { |
764 return gtk_widget_get_visible(view_.get()); | 767 return gtk_widget_get_visible(view_.get()); |
765 } | 768 } |
766 | 769 |
767 gfx::Rect RenderWidgetHostViewGtk::GetViewBounds() const { | 770 gfx::Rect RenderWidgetHostViewGtk::GetViewBounds() const { |
768 GdkWindow* gdk_window = view_.get()->window; | 771 GdkWindow* gdk_window = gtk_widget_get_window(view_.get()); |
769 if (!gdk_window) | 772 if (!gdk_window) |
770 return gfx::Rect(requested_size_); | 773 return gfx::Rect(requested_size_); |
771 GdkRectangle window_rect; | 774 GdkRectangle window_rect; |
772 gdk_window_get_origin(gdk_window, &window_rect.x, &window_rect.y); | 775 gdk_window_get_origin(gdk_window, &window_rect.x, &window_rect.y); |
773 return gfx::Rect(window_rect.x, window_rect.y, | 776 return gfx::Rect(window_rect.x, window_rect.y, |
774 requested_size_.width(), requested_size_.height()); | 777 requested_size_.width(), requested_size_.height()); |
775 } | 778 } |
776 | 779 |
777 void RenderWidgetHostViewGtk::UpdateCursor(const WebCursor& cursor) { | 780 void RenderWidgetHostViewGtk::UpdateCursor(const WebCursor& cursor) { |
778 // Optimize the common case, where the cursor hasn't changed. | 781 // Optimize the common case, where the cursor hasn't changed. |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
993 // shrink down to the size of its child contents. | 996 // shrink down to the size of its child contents. |
994 gtk_window_set_resizable(window, FALSE); | 997 gtk_window_set_resizable(window, FALSE); |
995 gtk_window_set_default_size(window, -1, -1); | 998 gtk_window_set_default_size(window, -1, -1); |
996 gtk_window_move(window, bounds.x(), bounds.y()); | 999 gtk_window_move(window, bounds.x(), bounds.y()); |
997 | 1000 |
998 gtk_widget_show_all(GTK_WIDGET(window)); | 1001 gtk_widget_show_all(GTK_WIDGET(window)); |
999 } | 1002 } |
1000 | 1003 |
1001 BackingStore* RenderWidgetHostViewGtk::AllocBackingStore( | 1004 BackingStore* RenderWidgetHostViewGtk::AllocBackingStore( |
1002 const gfx::Size& size) { | 1005 const gfx::Size& size) { |
| 1006 gint depth = gdk_visual_get_depth(gtk_widget_get_visual(view_.get())); |
1003 return new BackingStoreGtk(host_, size, | 1007 return new BackingStoreGtk(host_, size, |
1004 ui::GetVisualFromGtkWidget(view_.get()), | 1008 ui::GetVisualFromGtkWidget(view_.get()), |
1005 gtk_widget_get_visual(view_.get())->depth); | 1009 depth); |
1006 } | 1010 } |
1007 | 1011 |
1008 void RenderWidgetHostViewGtk::AcceleratedSurfaceBuffersSwapped( | 1012 void RenderWidgetHostViewGtk::AcceleratedSurfaceBuffersSwapped( |
1009 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, | 1013 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, |
1010 int gpu_host_id) { | 1014 int gpu_host_id) { |
1011 NOTREACHED(); | 1015 NOTREACHED(); |
1012 } | 1016 } |
1013 | 1017 |
1014 void RenderWidgetHostViewGtk::AcceleratedSurfacePostSubBuffer( | 1018 void RenderWidgetHostViewGtk::AcceleratedSurfacePostSubBuffer( |
1015 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, | 1019 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, |
(...skipping 23 matching lines...) Expand all Loading... |
1039 if (event->state & GDK_BUTTON1_MASK) { | 1043 if (event->state & GDK_BUTTON1_MASK) { |
1040 if (drag_monitor_size.IsEmpty()) { | 1044 if (drag_monitor_size.IsEmpty()) { |
1041 // We can safely cache the monitor size for the duration of a drag. | 1045 // We can safely cache the monitor size for the duration of a drag. |
1042 GdkScreen* screen = gtk_widget_get_screen(widget); | 1046 GdkScreen* screen = gtk_widget_get_screen(widget); |
1043 int monitor = | 1047 int monitor = |
1044 gdk_screen_get_monitor_at_point(screen, event->x_root, event->y_root); | 1048 gdk_screen_get_monitor_at_point(screen, event->x_root, event->y_root); |
1045 GdkRectangle geometry; | 1049 GdkRectangle geometry; |
1046 gdk_screen_get_monitor_geometry(screen, monitor, &geometry); | 1050 gdk_screen_get_monitor_geometry(screen, monitor, &geometry); |
1047 drag_monitor_size.SetSize(geometry.width, geometry.height); | 1051 drag_monitor_size.SetSize(geometry.width, geometry.height); |
1048 } | 1052 } |
1049 | 1053 GtkAllocation allocation; |
| 1054 gtk_widget_get_allocation(widget, &allocation); |
1050 // Check X and Y independently, as the user could be dragging into a corner. | 1055 // Check X and Y independently, as the user could be dragging into a corner. |
1051 if (event->x == 0 && event->x_root == 0) { | 1056 if (event->x == 0 && event->x_root == 0) { |
1052 new_dragged_at_horizontal_edge = dragged_at_horizontal_edge_ - 1; | 1057 new_dragged_at_horizontal_edge = dragged_at_horizontal_edge_ - 1; |
1053 } else if (widget->allocation.width - 1 == static_cast<gint>(event->x) && | 1058 } else if (allocation.width - 1 == static_cast<gint>(event->x) && |
1054 drag_monitor_size.width() - 1 == static_cast<gint>(event->x_root)) { | 1059 drag_monitor_size.width() - 1 == static_cast<gint>(event->x_root)) { |
1055 new_dragged_at_horizontal_edge = dragged_at_horizontal_edge_ + 1; | 1060 new_dragged_at_horizontal_edge = dragged_at_horizontal_edge_ + 1; |
1056 } | 1061 } |
1057 | 1062 |
1058 if (event->y == 0 && event->y_root == 0) { | 1063 if (event->y == 0 && event->y_root == 0) { |
1059 new_dragged_at_vertical_edge = dragged_at_vertical_edge_ - 1; | 1064 new_dragged_at_vertical_edge = dragged_at_vertical_edge_ - 1; |
1060 } else if (widget->allocation.height - 1 == static_cast<gint>(event->y) && | 1065 } else if (allocation.height - 1 == static_cast<gint>(event->y) && |
1061 drag_monitor_size.height() - 1 == static_cast<gint>(event->y_root)) { | 1066 drag_monitor_size.height() - 1 == static_cast<gint>(event->y_root)) { |
1062 new_dragged_at_vertical_edge = dragged_at_vertical_edge_ + 1; | 1067 new_dragged_at_vertical_edge = dragged_at_vertical_edge_ + 1; |
1063 } | 1068 } |
1064 | 1069 |
1065 event->x_root += new_dragged_at_horizontal_edge; | 1070 event->x_root += new_dragged_at_horizontal_edge; |
1066 event->x += new_dragged_at_horizontal_edge; | 1071 event->x += new_dragged_at_horizontal_edge; |
1067 event->y_root += new_dragged_at_vertical_edge; | 1072 event->y_root += new_dragged_at_vertical_edge; |
1068 event->y += new_dragged_at_vertical_edge; | 1073 event->y += new_dragged_at_vertical_edge; |
1069 } else { | 1074 } else { |
1070 // Clear whenever we get a non-drag mouse move. | 1075 // Clear whenever we get a non-drag mouse move. |
1071 drag_monitor_size.SetSize(0, 0); | 1076 drag_monitor_size.SetSize(0, 0); |
1072 } | 1077 } |
1073 dragged_at_horizontal_edge_ = new_dragged_at_horizontal_edge; | 1078 dragged_at_horizontal_edge_ = new_dragged_at_horizontal_edge; |
1074 dragged_at_vertical_edge_ = new_dragged_at_vertical_edge; | 1079 dragged_at_vertical_edge_ = new_dragged_at_vertical_edge; |
1075 } | 1080 } |
1076 | 1081 |
1077 void RenderWidgetHostViewGtk::Paint(const gfx::Rect& damage_rect) { | 1082 void RenderWidgetHostViewGtk::Paint(const gfx::Rect& damage_rect) { |
1078 // If the GPU process is rendering directly into the View, | 1083 // If the GPU process is rendering directly into the View, |
1079 // call the compositor directly. | 1084 // call the compositor directly. |
1080 RenderWidgetHost* render_widget_host = GetRenderWidgetHost(); | 1085 RenderWidgetHost* render_widget_host = GetRenderWidgetHost(); |
1081 if (render_widget_host->is_accelerated_compositing_active()) { | 1086 if (render_widget_host->is_accelerated_compositing_active()) { |
1082 host_->ScheduleComposite(); | 1087 host_->ScheduleComposite(); |
1083 return; | 1088 return; |
1084 } | 1089 } |
1085 | 1090 |
1086 GdkWindow* window = view_.get()->window; | 1091 GdkWindow* window = gtk_widget_get_window(view_.get()); |
1087 DCHECK(!about_to_validate_and_paint_); | 1092 DCHECK(!about_to_validate_and_paint_); |
1088 | 1093 |
1089 invalid_rect_ = damage_rect; | 1094 invalid_rect_ = damage_rect; |
1090 about_to_validate_and_paint_ = true; | 1095 about_to_validate_and_paint_ = true; |
1091 | 1096 |
1092 // If the size of our canvas is (0,0), then we don't want to block here. We | 1097 // If the size of our canvas is (0,0), then we don't want to block here. We |
1093 // are doing one of our first paints and probably have animations going on. | 1098 // are doing one of our first paints and probably have animations going on. |
1094 bool force_create = !host_->empty(); | 1099 bool force_create = !host_->empty(); |
1095 BackingStoreGtk* backing_store = static_cast<BackingStoreGtk*>( | 1100 BackingStoreGtk* backing_store = static_cast<BackingStoreGtk*>( |
1096 host_->GetBackingStore(force_create)); | 1101 host_->GetBackingStore(force_create)); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1167 if (window) | 1172 if (window) |
1168 gdk_window_clear(window); | 1173 gdk_window_clear(window); |
1169 if (whiteout_start_time_.is_null()) | 1174 if (whiteout_start_time_.is_null()) |
1170 whiteout_start_time_ = base::TimeTicks::Now(); | 1175 whiteout_start_time_ = base::TimeTicks::Now(); |
1171 } | 1176 } |
1172 } | 1177 } |
1173 | 1178 |
1174 void RenderWidgetHostViewGtk::ShowCurrentCursor() { | 1179 void RenderWidgetHostViewGtk::ShowCurrentCursor() { |
1175 // The widget may not have a window. If that's the case, abort mission. This | 1180 // The widget may not have a window. If that's the case, abort mission. This |
1176 // is the same issue as that explained above in Paint(). | 1181 // is the same issue as that explained above in Paint(). |
1177 if (!view_.get()->window) | 1182 if (!gtk_widget_get_window(view_.get())) |
1178 return; | 1183 return; |
1179 | 1184 |
1180 // TODO(port): WebKit bug https://bugs.webkit.org/show_bug.cgi?id=16388 is | 1185 // TODO(port): WebKit bug https://bugs.webkit.org/show_bug.cgi?id=16388 is |
1181 // that calling gdk_window_set_cursor repeatedly is expensive. We should | 1186 // that calling gdk_window_set_cursor repeatedly is expensive. We should |
1182 // avoid it here where possible. | 1187 // avoid it here where possible. |
1183 GdkCursor* gdk_cursor; | 1188 GdkCursor* gdk_cursor; |
1184 if (current_cursor_.GetCursorType() == GDK_LAST_CURSOR) { | 1189 if (current_cursor_.GetCursorType() == GDK_LAST_CURSOR) { |
1185 // Use MOZ_CURSOR_SPINNING if we are showing the default cursor and | 1190 // Use MOZ_CURSOR_SPINNING if we are showing the default cursor and |
1186 // the page is loading. | 1191 // the page is loading. |
1187 gdk_cursor = is_loading_ ? GetMozSpinningCursor() : NULL; | 1192 gdk_cursor = is_loading_ ? GetMozSpinningCursor() : NULL; |
1188 } else { | 1193 } else { |
1189 gdk_cursor = current_cursor_.GetNativeCursor(); | 1194 gdk_cursor = current_cursor_.GetNativeCursor(); |
1190 } | 1195 } |
1191 gdk_window_set_cursor(view_.get()->window, gdk_cursor); | 1196 gdk_window_set_cursor(gtk_widget_get_window(view_.get()), gdk_cursor); |
1192 } | 1197 } |
1193 | 1198 |
1194 void RenderWidgetHostViewGtk::CreatePluginContainer( | 1199 void RenderWidgetHostViewGtk::CreatePluginContainer( |
1195 gfx::PluginWindowHandle id) { | 1200 gfx::PluginWindowHandle id) { |
1196 plugin_container_manager_.CreatePluginContainer(id); | 1201 plugin_container_manager_.CreatePluginContainer(id); |
1197 } | 1202 } |
1198 | 1203 |
1199 void RenderWidgetHostViewGtk::DestroyPluginContainer( | 1204 void RenderWidgetHostViewGtk::DestroyPluginContainer( |
1200 gfx::PluginWindowHandle id) { | 1205 gfx::PluginWindowHandle id) { |
1201 plugin_container_manager_.DestroyPluginContainer(id); | 1206 plugin_container_manager_.DestroyPluginContainer(id); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1233 | 1238 |
1234 | 1239 |
1235 void RenderWidgetHostViewGtk::OnAcceleratedCompositingStateChange() { | 1240 void RenderWidgetHostViewGtk::OnAcceleratedCompositingStateChange() { |
1236 bool activated = host_->is_accelerated_compositing_active(); | 1241 bool activated = host_->is_accelerated_compositing_active(); |
1237 GtkPreserveWindow* widget = reinterpret_cast<GtkPreserveWindow*>(view_.get()); | 1242 GtkPreserveWindow* widget = reinterpret_cast<GtkPreserveWindow*>(view_.get()); |
1238 | 1243 |
1239 gtk_preserve_window_delegate_resize(widget, activated); | 1244 gtk_preserve_window_delegate_resize(widget, activated); |
1240 } | 1245 } |
1241 | 1246 |
1242 void RenderWidgetHostViewGtk::GetScreenInfo(WebKit::WebScreenInfo* results) { | 1247 void RenderWidgetHostViewGtk::GetScreenInfo(WebKit::WebScreenInfo* results) { |
1243 GdkWindow* gdk_window = view_.get()->window; | 1248 GdkWindow* gdk_window = gtk_widget_get_window(view_.get()); |
1244 if (!gdk_window) { | 1249 if (!gdk_window) { |
1245 GdkDisplay* display = gdk_display_get_default(); | 1250 GdkDisplay* display = gdk_display_get_default(); |
1246 gdk_window = gdk_display_get_default_group(display); | 1251 gdk_window = gdk_display_get_default_group(display); |
1247 } | 1252 } |
1248 if (!gdk_window) | 1253 if (!gdk_window) |
1249 return; | 1254 return; |
1250 content::GetScreenInfoFromNativeWindow(gdk_window, results); | 1255 content::GetScreenInfoFromNativeWindow(gdk_window, results); |
1251 } | 1256 } |
1252 | 1257 |
1253 gfx::Rect RenderWidgetHostViewGtk::GetRootWindowBounds() { | 1258 gfx::Rect RenderWidgetHostViewGtk::GetRootWindowBounds() { |
1254 GtkWidget* toplevel = gtk_widget_get_toplevel(view_.get()); | 1259 GtkWidget* toplevel = gtk_widget_get_toplevel(view_.get()); |
1255 if (!toplevel) | 1260 if (!toplevel) |
1256 return gfx::Rect(); | 1261 return gfx::Rect(); |
1257 | 1262 |
1258 GdkRectangle frame_extents; | 1263 GdkRectangle frame_extents; |
1259 GdkWindow* gdk_window = toplevel->window; | 1264 GdkWindow* gdk_window = gtk_widget_get_window(toplevel); |
1260 if (!gdk_window) | 1265 if (!gdk_window) |
1261 return gfx::Rect(); | 1266 return gfx::Rect(); |
1262 | 1267 |
1263 gdk_window_get_frame_extents(gdk_window, &frame_extents); | 1268 gdk_window_get_frame_extents(gdk_window, &frame_extents); |
1264 return gfx::Rect(frame_extents.x, frame_extents.y, | 1269 return gfx::Rect(frame_extents.x, frame_extents.y, |
1265 frame_extents.width, frame_extents.height); | 1270 frame_extents.width, frame_extents.height); |
1266 } | 1271 } |
1267 | 1272 |
1268 gfx::PluginWindowHandle RenderWidgetHostViewGtk::GetCompositingSurface() { | 1273 gfx::PluginWindowHandle RenderWidgetHostViewGtk::GetCompositingSurface() { |
1269 if (compositing_surface_ == gfx::kNullPluginWindow) { | 1274 if (compositing_surface_ == gfx::kNullPluginWindow) { |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1386 } | 1391 } |
1387 | 1392 |
1388 gfx::Point RenderWidgetHostViewGtk::GetWidgetCenter() { | 1393 gfx::Point RenderWidgetHostViewGtk::GetWidgetCenter() { |
1389 if (widget_center_valid_) | 1394 if (widget_center_valid_) |
1390 return widget_center_; | 1395 return widget_center_; |
1391 | 1396 |
1392 GdkWindow* window = gtk_widget_get_window(view_.get()); | 1397 GdkWindow* window = gtk_widget_get_window(view_.get()); |
1393 gint window_x = 0; | 1398 gint window_x = 0; |
1394 gint window_y = 0; | 1399 gint window_y = 0; |
1395 gdk_window_get_origin(window, &window_x, &window_y); | 1400 gdk_window_get_origin(window, &window_x, &window_y); |
1396 gint window_w = 0; | 1401 gint window_w = gdk_window_get_width(window); |
1397 gint window_h = 0; | 1402 gint window_h = gdk_window_get_height(window); |
1398 gdk_window_get_size(window, &window_w, &window_h); | |
1399 | |
1400 widget_center_.SetPoint(window_x + window_w / 2, | 1403 widget_center_.SetPoint(window_x + window_w / 2, |
1401 window_y + window_h / 2); | 1404 window_y + window_h / 2); |
1402 widget_center_valid_ = true; | 1405 widget_center_valid_ = true; |
1403 return widget_center_; | 1406 return widget_center_; |
1404 } | 1407 } |
1405 | 1408 |
1406 void RenderWidgetHostViewGtk::ModifyEventMovementAndCoords( | 1409 void RenderWidgetHostViewGtk::ModifyEventMovementAndCoords( |
1407 WebKit::WebMouseEvent* event) { | 1410 WebKit::WebMouseEvent* event) { |
1408 // Movement is computed by taking the difference of the new cursor position | 1411 // Movement is computed by taking the difference of the new cursor position |
1409 // and the previous. Under mouse lock the cursor will be warped back to the | 1412 // and the previous. Under mouse lock the cursor will be warped back to the |
(...skipping 21 matching lines...) Expand all Loading... |
1431 } | 1434 } |
1432 } | 1435 } |
1433 | 1436 |
1434 // static | 1437 // static |
1435 void RenderWidgetHostView::GetDefaultScreenInfo( | 1438 void RenderWidgetHostView::GetDefaultScreenInfo( |
1436 WebKit::WebScreenInfo* results) { | 1439 WebKit::WebScreenInfo* results) { |
1437 GdkWindow* gdk_window = | 1440 GdkWindow* gdk_window = |
1438 gdk_display_get_default_group(gdk_display_get_default()); | 1441 gdk_display_get_default_group(gdk_display_get_default()); |
1439 content::GetScreenInfoFromNativeWindow(gdk_window, results); | 1442 content::GetScreenInfoFromNativeWindow(gdk_window, results); |
1440 } | 1443 } |
OLD | NEW |