Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(331)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_gtk.cc

Issue 8635018: GTK: Port RenderWidgetHostViewGtk to latest GTK (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ui/base/gtk/gtk_compat.h » ('j') | ui/base/gtk/gtk_compat.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 host_view->im_context_->OnFocusIn(); 233 host_view->im_context_->OnFocusIn();
234 234
235 return TRUE; 235 return TRUE;
236 } 236 }
237 237
238 static gboolean OnFocusOut(GtkWidget* widget, 238 static gboolean OnFocusOut(GtkWidget* widget,
239 GdkEventFocus* focus, 239 GdkEventFocus* focus,
240 RenderWidgetHostViewGtk* host_view) { 240 RenderWidgetHostViewGtk* host_view) {
241 // Whenever we lose focus, set the cursor back to that of our parent window, 241 // Whenever we lose focus, set the cursor back to that of our parent window,
242 // which should be the default arrow. 242 // which should be the default arrow.
243 gdk_window_set_cursor(widget->window, NULL); 243 gdk_window_set_cursor(gtk_widget_get_window(widget), NULL);
244 // If we are showing a context menu, maintain the illusion that webkit has 244 // If we are showing a context menu, maintain the illusion that webkit has
245 // focus. 245 // focus.
246 if (!host_view->is_showing_context_menu_) { 246 if (!host_view->is_showing_context_menu_) {
247 host_view->GetRenderWidgetHost()->SetActive(false); 247 host_view->GetRenderWidgetHost()->SetActive(false);
248 host_view->GetRenderWidgetHost()->Blur(); 248 host_view->GetRenderWidgetHost()->Blur();
249 } 249 }
250 250
251 // Prevents us from stealing input context focus in OnGrabNotify() handler. 251 // Prevents us from stealing input context focus in OnGrabNotify() handler.
252 host_view->was_imcontext_focused_before_grab_ = false; 252 host_view->was_imcontext_focused_before_grab_ = false;
253 253
254 // Disable the GtkIMContext object. 254 // Disable the GtkIMContext object.
255 host_view->im_context_->OnFocusOut(); 255 host_view->im_context_->OnFocusOut();
256 256
257 return TRUE; 257 return TRUE;
258 } 258 }
259 259
260 // Called when we are shadowed or unshadowed by a keyboard grab (which will 260 // 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 261 // 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 262 // 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. 263 // shown, and must rely on this signal instead.
264 static void OnGrabNotify(GtkWidget* widget, gboolean was_grabbed, 264 static void OnGrabNotify(GtkWidget* widget, gboolean was_grabbed,
265 RenderWidgetHostViewGtk* host_view) { 265 RenderWidgetHostViewGtk* host_view) {
266 if (was_grabbed) { 266 if (was_grabbed) {
267 if (host_view->was_imcontext_focused_before_grab_) 267 if (host_view->was_imcontext_focused_before_grab_)
268 host_view->im_context_->OnFocusIn(); 268 host_view->im_context_->OnFocusIn();
269 } else { 269 } else {
270 host_view->was_imcontext_focused_before_grab_ = 270 host_view->was_imcontext_focused_before_grab_ =
271 host_view->im_context_->is_focused(); 271 host_view->im_context_->is_focused();
272 if (host_view->was_imcontext_focused_before_grab_) { 272 if (host_view->was_imcontext_focused_before_grab_) {
273 gdk_window_set_cursor(widget->window, NULL); 273 gdk_window_set_cursor(gtk_widget_get_window(widget), NULL);
274 host_view->im_context_->OnFocusOut(); 274 host_view->im_context_->OnFocusOut();
275 } 275 }
276 } 276 }
277 } 277 }
278 278
279 static gboolean OnButtonPressReleaseEvent( 279 static gboolean OnButtonPressReleaseEvent(
280 GtkWidget* widget, 280 GtkWidget* widget,
281 GdkEventButton* event, 281 GdkEventButton* event,
282 RenderWidgetHostViewGtk* host_view) { 282 RenderWidgetHostViewGtk* host_view) {
283 #if defined (OS_CHROMEOS) 283 #if defined (OS_CHROMEOS)
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 // from this widget to be relative to the top left of the widget. 333 // from this widget to be relative to the top left of the widget.
334 GtkWidget* event_widget = gtk_get_event_widget( 334 GtkWidget* event_widget = gtk_get_event_widget(
335 reinterpret_cast<GdkEvent*>(event)); 335 reinterpret_cast<GdkEvent*>(event));
336 if (event_widget != widget) { 336 if (event_widget != widget) {
337 int x = 0; 337 int x = 0;
338 int y = 0; 338 int y = 0;
339 gtk_widget_get_pointer(widget, &x, &y); 339 gtk_widget_get_pointer(widget, &x, &y);
340 // If the mouse event happens outside our popup, force the popup to 340 // 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 341 // close. We do this so a hung renderer doesn't prevent us from
342 // releasing the x pointer grab. 342 // releasing the x pointer grab.
343 bool click_in_popup = x >= 0 && y >= 0 && x < widget->allocation.width && 343 GtkAllocation allocation;
344 y < widget->allocation.height; 344 gtk_widget_get_allocation(widget, &allocation);
345 bool click_in_popup = x >= 0 && y >= 0 && x < allocation.width &&
346 y < allocation.height;
345 // Only Shutdown on mouse downs. Mouse ups can occur outside the render 347 // 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 348 // 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. 349 // dropdown. Don't shutdown if we are not a popup.
348 if (event->type != GDK_BUTTON_RELEASE && host_view->IsPopup() && 350 if (event->type != GDK_BUTTON_RELEASE && host_view->IsPopup() &&
349 !host_view->is_popup_first_mouse_release_ && !click_in_popup) { 351 !host_view->is_popup_first_mouse_release_ && !click_in_popup) {
350 host_view->host_->Shutdown(); 352 host_view->host_->Shutdown();
351 return FALSE; 353 return FALSE;
352 } 354 }
353 event->x = x; 355 event->x = x;
354 event->y = y; 356 event->y = y;
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 gtk_grab_add(view_.get()); 617 gtk_grab_add(view_.get());
616 618
617 // We need for the application to do an X grab as well. However if the app 619 // 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 620 // already has an X grab (as in the case of extension popup), an app grab
619 // will suffice. 621 // will suffice.
620 do_x_grab_ = !gdk_pointer_is_grabbed(); 622 do_x_grab_ = !gdk_pointer_is_grabbed();
621 623
622 // Now grab all of X's input. 624 // Now grab all of X's input.
623 if (do_x_grab_) { 625 if (do_x_grab_) {
624 gdk_pointer_grab( 626 gdk_pointer_grab(
625 parent_->window, 627 gtk_widget_get_window(parent_),
626 TRUE, // Only events outside of the window are reported with respect 628 TRUE, // Only events outside of the window are reported with respect
627 // to |parent_->window|. 629 // to |parent_->window|.
628 static_cast<GdkEventMask>(GDK_BUTTON_PRESS_MASK | 630 static_cast<GdkEventMask>(GDK_BUTTON_PRESS_MASK |
629 GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK), 631 GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK),
630 NULL, 632 NULL,
631 NULL, 633 NULL,
632 GDK_CURRENT_TIME); 634 GDK_CURRENT_TIME);
633 // We grab keyboard events too so things like alt+tab are eaten. 635 // We grab keyboard events too so things like alt+tab are eaten.
634 gdk_keyboard_grab(parent_->window, TRUE, GDK_CURRENT_TIME); 636 gdk_keyboard_grab(gtk_widget_get_window(parent_), TRUE, GDK_CURRENT_TIME);
635 } 637 }
636 } 638 }
637 } 639 }
638 640
639 void RenderWidgetHostViewGtk::InitAsFullscreen( 641 void RenderWidgetHostViewGtk::InitAsFullscreen(
640 RenderWidgetHostView* /*reference_host_view*/) { 642 RenderWidgetHostView* /*reference_host_view*/) {
641 DoSharedInit(); 643 DoSharedInit();
642 644
643 is_fullscreen_ = true; 645 is_fullscreen_ = true;
644 GtkWindow* window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); 646 GtkWindow* window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 760
759 void RenderWidgetHostViewGtk::Hide() { 761 void RenderWidgetHostViewGtk::Hide() {
760 gtk_widget_hide(view_.get()); 762 gtk_widget_hide(view_.get());
761 } 763 }
762 764
763 bool RenderWidgetHostViewGtk::IsShowing() { 765 bool RenderWidgetHostViewGtk::IsShowing() {
764 return gtk_widget_get_visible(view_.get()); 766 return gtk_widget_get_visible(view_.get());
765 } 767 }
766 768
767 gfx::Rect RenderWidgetHostViewGtk::GetViewBounds() const { 769 gfx::Rect RenderWidgetHostViewGtk::GetViewBounds() const {
768 GdkWindow* gdk_window = view_.get()->window; 770 GdkWindow* gdk_window = gtk_widget_get_window(view_.get());
769 if (!gdk_window) 771 if (!gdk_window)
770 return gfx::Rect(requested_size_); 772 return gfx::Rect(requested_size_);
771 GdkRectangle window_rect; 773 GdkRectangle window_rect;
772 gdk_window_get_origin(gdk_window, &window_rect.x, &window_rect.y); 774 gdk_window_get_origin(gdk_window, &window_rect.x, &window_rect.y);
773 return gfx::Rect(window_rect.x, window_rect.y, 775 return gfx::Rect(window_rect.x, window_rect.y,
774 requested_size_.width(), requested_size_.height()); 776 requested_size_.width(), requested_size_.height());
775 } 777 }
776 778
777 void RenderWidgetHostViewGtk::UpdateCursor(const WebCursor& cursor) { 779 void RenderWidgetHostViewGtk::UpdateCursor(const WebCursor& cursor) {
778 // Optimize the common case, where the cursor hasn't changed. 780 // Optimize the common case, where the cursor hasn't changed.
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 // shrink down to the size of its child contents. 995 // shrink down to the size of its child contents.
994 gtk_window_set_resizable(window, FALSE); 996 gtk_window_set_resizable(window, FALSE);
995 gtk_window_set_default_size(window, -1, -1); 997 gtk_window_set_default_size(window, -1, -1);
996 gtk_window_move(window, bounds.x(), bounds.y()); 998 gtk_window_move(window, bounds.x(), bounds.y());
997 999
998 gtk_widget_show_all(GTK_WIDGET(window)); 1000 gtk_widget_show_all(GTK_WIDGET(window));
999 } 1001 }
1000 1002
1001 BackingStore* RenderWidgetHostViewGtk::AllocBackingStore( 1003 BackingStore* RenderWidgetHostViewGtk::AllocBackingStore(
1002 const gfx::Size& size) { 1004 const gfx::Size& size) {
1005 gint depth = gdk_visual_get_depth(gtk_widget_get_visual(view_.get()));
1003 return new BackingStoreGtk(host_, size, 1006 return new BackingStoreGtk(host_, size,
1004 ui::GetVisualFromGtkWidget(view_.get()), 1007 ui::GetVisualFromGtkWidget(view_.get()),
1005 gtk_widget_get_visual(view_.get())->depth); 1008 depth);
1006 } 1009 }
1007 1010
1008 void RenderWidgetHostViewGtk::SetBackground(const SkBitmap& background) { 1011 void RenderWidgetHostViewGtk::SetBackground(const SkBitmap& background) {
1009 RenderWidgetHostView::SetBackground(background); 1012 RenderWidgetHostView::SetBackground(background);
1010 host_->Send(new ViewMsg_SetBackground(host_->routing_id(), background)); 1013 host_->Send(new ViewMsg_SetBackground(host_->routing_id(), background));
1011 } 1014 }
1012 1015
1013 void RenderWidgetHostViewGtk::ModifyEventForEdgeDragging( 1016 void RenderWidgetHostViewGtk::ModifyEventForEdgeDragging(
1014 GtkWidget* widget, GdkEventMotion* event) { 1017 GtkWidget* widget, GdkEventMotion* event) {
1015 // If the widget is aligned with an edge of the monitor its on and the user 1018 // If the widget is aligned with an edge of the monitor its on and the user
(...skipping 11 matching lines...) Expand all
1027 if (event->state & GDK_BUTTON1_MASK) { 1030 if (event->state & GDK_BUTTON1_MASK) {
1028 if (drag_monitor_size.IsEmpty()) { 1031 if (drag_monitor_size.IsEmpty()) {
1029 // We can safely cache the monitor size for the duration of a drag. 1032 // We can safely cache the monitor size for the duration of a drag.
1030 GdkScreen* screen = gtk_widget_get_screen(widget); 1033 GdkScreen* screen = gtk_widget_get_screen(widget);
1031 int monitor = 1034 int monitor =
1032 gdk_screen_get_monitor_at_point(screen, event->x_root, event->y_root); 1035 gdk_screen_get_monitor_at_point(screen, event->x_root, event->y_root);
1033 GdkRectangle geometry; 1036 GdkRectangle geometry;
1034 gdk_screen_get_monitor_geometry(screen, monitor, &geometry); 1037 gdk_screen_get_monitor_geometry(screen, monitor, &geometry);
1035 drag_monitor_size.SetSize(geometry.width, geometry.height); 1038 drag_monitor_size.SetSize(geometry.width, geometry.height);
1036 } 1039 }
1037 1040 GtkAllocation allocation;
1041 gtk_widget_get_allocation(widget, &allocation);
1038 // Check X and Y independently, as the user could be dragging into a corner. 1042 // Check X and Y independently, as the user could be dragging into a corner.
1039 if (event->x == 0 && event->x_root == 0) { 1043 if (event->x == 0 && event->x_root == 0) {
1040 new_dragged_at_horizontal_edge = dragged_at_horizontal_edge_ - 1; 1044 new_dragged_at_horizontal_edge = dragged_at_horizontal_edge_ - 1;
1041 } else if (widget->allocation.width - 1 == static_cast<gint>(event->x) && 1045 } else if (allocation.width - 1 == static_cast<gint>(event->x) &&
1042 drag_monitor_size.width() - 1 == static_cast<gint>(event->x_root)) { 1046 drag_monitor_size.width() - 1 == static_cast<gint>(event->x_root)) {
1043 new_dragged_at_horizontal_edge = dragged_at_horizontal_edge_ + 1; 1047 new_dragged_at_horizontal_edge = dragged_at_horizontal_edge_ + 1;
1044 } 1048 }
1045 1049
1046 if (event->y == 0 && event->y_root == 0) { 1050 if (event->y == 0 && event->y_root == 0) {
1047 new_dragged_at_vertical_edge = dragged_at_vertical_edge_ - 1; 1051 new_dragged_at_vertical_edge = dragged_at_vertical_edge_ - 1;
1048 } else if (widget->allocation.height - 1 == static_cast<gint>(event->y) && 1052 } else if (allocation.height - 1 == static_cast<gint>(event->y) &&
1049 drag_monitor_size.height() - 1 == static_cast<gint>(event->y_root)) { 1053 drag_monitor_size.height() - 1 == static_cast<gint>(event->y_root)) {
1050 new_dragged_at_vertical_edge = dragged_at_vertical_edge_ + 1; 1054 new_dragged_at_vertical_edge = dragged_at_vertical_edge_ + 1;
1051 } 1055 }
1052 1056
1053 event->x_root += new_dragged_at_horizontal_edge; 1057 event->x_root += new_dragged_at_horizontal_edge;
1054 event->x += new_dragged_at_horizontal_edge; 1058 event->x += new_dragged_at_horizontal_edge;
1055 event->y_root += new_dragged_at_vertical_edge; 1059 event->y_root += new_dragged_at_vertical_edge;
1056 event->y += new_dragged_at_vertical_edge; 1060 event->y += new_dragged_at_vertical_edge;
1057 } else { 1061 } else {
1058 // Clear whenever we get a non-drag mouse move. 1062 // Clear whenever we get a non-drag mouse move.
1059 drag_monitor_size.SetSize(0, 0); 1063 drag_monitor_size.SetSize(0, 0);
1060 } 1064 }
1061 dragged_at_horizontal_edge_ = new_dragged_at_horizontal_edge; 1065 dragged_at_horizontal_edge_ = new_dragged_at_horizontal_edge;
1062 dragged_at_vertical_edge_ = new_dragged_at_vertical_edge; 1066 dragged_at_vertical_edge_ = new_dragged_at_vertical_edge;
1063 } 1067 }
1064 1068
1065 void RenderWidgetHostViewGtk::Paint(const gfx::Rect& damage_rect) { 1069 void RenderWidgetHostViewGtk::Paint(const gfx::Rect& damage_rect) {
1066 // If the GPU process is rendering directly into the View, 1070 // If the GPU process is rendering directly into the View,
1067 // call the compositor directly. 1071 // call the compositor directly.
1068 RenderWidgetHost* render_widget_host = GetRenderWidgetHost(); 1072 RenderWidgetHost* render_widget_host = GetRenderWidgetHost();
1069 if (render_widget_host->is_accelerated_compositing_active()) { 1073 if (render_widget_host->is_accelerated_compositing_active()) {
1070 host_->ScheduleComposite(); 1074 host_->ScheduleComposite();
1071 return; 1075 return;
1072 } 1076 }
1073 1077
1074 GdkWindow* window = view_.get()->window; 1078 GdkWindow* window = gtk_widget_get_window(view_.get());
1075 DCHECK(!about_to_validate_and_paint_); 1079 DCHECK(!about_to_validate_and_paint_);
1076 1080
1077 invalid_rect_ = damage_rect; 1081 invalid_rect_ = damage_rect;
1078 about_to_validate_and_paint_ = true; 1082 about_to_validate_and_paint_ = true;
1079 1083
1080 // If the size of our canvas is (0,0), then we don't want to block here. We 1084 // If the size of our canvas is (0,0), then we don't want to block here. We
1081 // are doing one of our first paints and probably have animations going on. 1085 // are doing one of our first paints and probably have animations going on.
1082 bool force_create = !host_->empty(); 1086 bool force_create = !host_->empty();
1083 BackingStoreGtk* backing_store = static_cast<BackingStoreGtk*>( 1087 BackingStoreGtk* backing_store = static_cast<BackingStoreGtk*>(
1084 host_->GetBackingStore(force_create)); 1088 host_->GetBackingStore(force_create));
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 if (window) 1159 if (window)
1156 gdk_window_clear(window); 1160 gdk_window_clear(window);
1157 if (whiteout_start_time_.is_null()) 1161 if (whiteout_start_time_.is_null())
1158 whiteout_start_time_ = base::TimeTicks::Now(); 1162 whiteout_start_time_ = base::TimeTicks::Now();
1159 } 1163 }
1160 } 1164 }
1161 1165
1162 void RenderWidgetHostViewGtk::ShowCurrentCursor() { 1166 void RenderWidgetHostViewGtk::ShowCurrentCursor() {
1163 // The widget may not have a window. If that's the case, abort mission. This 1167 // The widget may not have a window. If that's the case, abort mission. This
1164 // is the same issue as that explained above in Paint(). 1168 // is the same issue as that explained above in Paint().
1165 if (!view_.get()->window) 1169 if (!gtk_widget_get_window(view_.get()))
1166 return; 1170 return;
1167 1171
1168 // TODO(port): WebKit bug https://bugs.webkit.org/show_bug.cgi?id=16388 is 1172 // TODO(port): WebKit bug https://bugs.webkit.org/show_bug.cgi?id=16388 is
1169 // that calling gdk_window_set_cursor repeatedly is expensive. We should 1173 // that calling gdk_window_set_cursor repeatedly is expensive. We should
1170 // avoid it here where possible. 1174 // avoid it here where possible.
1171 GdkCursor* gdk_cursor; 1175 GdkCursor* gdk_cursor;
1172 if (current_cursor_.GetCursorType() == GDK_LAST_CURSOR) { 1176 if (current_cursor_.GetCursorType() == GDK_LAST_CURSOR) {
1173 // Use MOZ_CURSOR_SPINNING if we are showing the default cursor and 1177 // Use MOZ_CURSOR_SPINNING if we are showing the default cursor and
1174 // the page is loading. 1178 // the page is loading.
1175 gdk_cursor = is_loading_ ? GetMozSpinningCursor() : NULL; 1179 gdk_cursor = is_loading_ ? GetMozSpinningCursor() : NULL;
1176 } else { 1180 } else {
1177 gdk_cursor = current_cursor_.GetNativeCursor(); 1181 gdk_cursor = current_cursor_.GetNativeCursor();
1178 } 1182 }
1179 gdk_window_set_cursor(view_.get()->window, gdk_cursor); 1183 gdk_window_set_cursor(gtk_widget_get_window(view_.get()), gdk_cursor);
1180 } 1184 }
1181 1185
1182 void RenderWidgetHostViewGtk::CreatePluginContainer( 1186 void RenderWidgetHostViewGtk::CreatePluginContainer(
1183 gfx::PluginWindowHandle id) { 1187 gfx::PluginWindowHandle id) {
1184 plugin_container_manager_.CreatePluginContainer(id); 1188 plugin_container_manager_.CreatePluginContainer(id);
1185 } 1189 }
1186 1190
1187 void RenderWidgetHostViewGtk::DestroyPluginContainer( 1191 void RenderWidgetHostViewGtk::DestroyPluginContainer(
1188 gfx::PluginWindowHandle id) { 1192 gfx::PluginWindowHandle id) {
1189 plugin_container_manager_.DestroyPluginContainer(id); 1193 plugin_container_manager_.DestroyPluginContainer(id);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1221 1225
1222 1226
1223 void RenderWidgetHostViewGtk::OnAcceleratedCompositingStateChange() { 1227 void RenderWidgetHostViewGtk::OnAcceleratedCompositingStateChange() {
1224 bool activated = host_->is_accelerated_compositing_active(); 1228 bool activated = host_->is_accelerated_compositing_active();
1225 GtkPreserveWindow* widget = reinterpret_cast<GtkPreserveWindow*>(view_.get()); 1229 GtkPreserveWindow* widget = reinterpret_cast<GtkPreserveWindow*>(view_.get());
1226 1230
1227 gtk_preserve_window_delegate_resize(widget, activated); 1231 gtk_preserve_window_delegate_resize(widget, activated);
1228 } 1232 }
1229 1233
1230 void RenderWidgetHostViewGtk::GetScreenInfo(WebKit::WebScreenInfo* results) { 1234 void RenderWidgetHostViewGtk::GetScreenInfo(WebKit::WebScreenInfo* results) {
1231 GdkWindow* gdk_window = view_.get()->window; 1235 GdkWindow* gdk_window = gtk_widget_get_window(view_.get());
1232 if (!gdk_window) { 1236 if (!gdk_window) {
1233 GdkDisplay* display = gdk_display_get_default(); 1237 GdkDisplay* display = gdk_display_get_default();
1234 gdk_window = gdk_display_get_default_group(display); 1238 gdk_window = gdk_display_get_default_group(display);
1235 } 1239 }
1236 if (!gdk_window) 1240 if (!gdk_window)
1237 return; 1241 return;
1238 content::GetScreenInfoFromNativeWindow(gdk_window, results); 1242 content::GetScreenInfoFromNativeWindow(gdk_window, results);
1239 } 1243 }
1240 1244
1241 gfx::Rect RenderWidgetHostViewGtk::GetRootWindowBounds() { 1245 gfx::Rect RenderWidgetHostViewGtk::GetRootWindowBounds() {
1242 GtkWidget* toplevel = gtk_widget_get_toplevel(view_.get()); 1246 GtkWidget* toplevel = gtk_widget_get_toplevel(view_.get());
1243 if (!toplevel) 1247 if (!toplevel)
1244 return gfx::Rect(); 1248 return gfx::Rect();
1245 1249
1246 GdkRectangle frame_extents; 1250 GdkRectangle frame_extents;
1247 GdkWindow* gdk_window = toplevel->window; 1251 GdkWindow* gdk_window = gtk_widget_get_window(toplevel);
1248 if (!gdk_window) 1252 if (!gdk_window)
1249 return gfx::Rect(); 1253 return gfx::Rect();
1250 1254
1251 gdk_window_get_frame_extents(gdk_window, &frame_extents); 1255 gdk_window_get_frame_extents(gdk_window, &frame_extents);
1252 return gfx::Rect(frame_extents.x, frame_extents.y, 1256 return gfx::Rect(frame_extents.x, frame_extents.y,
1253 frame_extents.width, frame_extents.height); 1257 frame_extents.width, frame_extents.height);
1254 } 1258 }
1255 1259
1256 gfx::PluginWindowHandle RenderWidgetHostViewGtk::GetCompositingSurface() { 1260 gfx::PluginWindowHandle RenderWidgetHostViewGtk::GetCompositingSurface() {
1257 if (compositing_surface_ == gfx::kNullPluginWindow) { 1261 if (compositing_surface_ == gfx::kNullPluginWindow) {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1376 gfx::Point RenderWidgetHostViewGtk::GetWidgetCenter() { 1380 gfx::Point RenderWidgetHostViewGtk::GetWidgetCenter() {
1377 if (widget_center_valid_) 1381 if (widget_center_valid_)
1378 return widget_center_; 1382 return widget_center_;
1379 1383
1380 GdkWindow* window = gtk_widget_get_window(view_.get()); 1384 GdkWindow* window = gtk_widget_get_window(view_.get());
1381 gint window_x = 0; 1385 gint window_x = 0;
1382 gint window_y = 0; 1386 gint window_y = 0;
1383 gdk_window_get_origin(window, &window_x, &window_y); 1387 gdk_window_get_origin(window, &window_x, &window_y);
1384 gint window_w = 0; 1388 gint window_w = 0;
1385 gint window_h = 0; 1389 gint window_h = 0;
1386 gdk_window_get_size(window, &window_w, &window_h); 1390 window_w = gdk_window_get_width(window);
Elliot Glaysher 2011/11/28 18:35:42 nit: we aren't using c here; it's ok to compress t
robert.bradford 2011/11/29 12:02:49 Done and similarly for window_h too.
1387 1391 window_h = gdk_window_get_height(window);
1388 widget_center_.SetPoint(window_x + window_w / 2, 1392 widget_center_.SetPoint(window_x + window_w / 2,
1389 window_y + window_h / 2); 1393 window_y + window_h / 2);
1390 widget_center_valid_ = true; 1394 widget_center_valid_ = true;
1391 return widget_center_; 1395 return widget_center_;
1392 } 1396 }
1393 1397
1394 void RenderWidgetHostViewGtk::ModifyEventMovementAndCoords( 1398 void RenderWidgetHostViewGtk::ModifyEventMovementAndCoords(
1395 WebKit::WebMouseEvent* event) { 1399 WebKit::WebMouseEvent* event) {
1396 // Movement is computed by taking the difference of the new cursor position 1400 // Movement is computed by taking the difference of the new cursor position
1397 // and the previous. Under mouse lock the cursor will be warped back to the 1401 // and the previous. Under mouse lock the cursor will be warped back to the
(...skipping 21 matching lines...) Expand all
1419 } 1423 }
1420 } 1424 }
1421 1425
1422 // static 1426 // static
1423 void RenderWidgetHostView::GetDefaultScreenInfo( 1427 void RenderWidgetHostView::GetDefaultScreenInfo(
1424 WebKit::WebScreenInfo* results) { 1428 WebKit::WebScreenInfo* results) {
1425 GdkWindow* gdk_window = 1429 GdkWindow* gdk_window =
1426 gdk_display_get_default_group(gdk_display_get_default()); 1430 gdk_display_get_default_group(gdk_display_get_default());
1427 content::GetScreenInfoFromNativeWindow(gdk_window, results); 1431 content::GetScreenInfoFromNativeWindow(gdk_window, results);
1428 } 1432 }
OLDNEW
« no previous file with comments | « no previous file | ui/base/gtk/gtk_compat.h » ('j') | ui/base/gtk/gtk_compat.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698