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

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

Issue 10454013: GTK Render Widget Host View resets cached center location on mouse lock. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 months 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 | Annotate | Revision Log
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_gtk.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 // control the lifetime of, auto disconnecting at our end of our life. 200 // control the lifetime of, auto disconnecting at our end of our life.
201 host_view->signals_.Connect(gtk_widget_get_toplevel(widget), 201 host_view->signals_.Connect(gtk_widget_get_toplevel(widget),
202 "configure-event", 202 "configure-event",
203 G_CALLBACK(OnConfigureEvent), host_view); 203 G_CALLBACK(OnConfigureEvent), host_view);
204 return FALSE; 204 return FALSE;
205 } 205 }
206 206
207 static gboolean OnConfigureEvent(GtkWidget* widget, 207 static gboolean OnConfigureEvent(GtkWidget* widget,
208 GdkEventConfigure* event, 208 GdkEventConfigure* event,
209 RenderWidgetHostViewGtk* host_view) { 209 RenderWidgetHostViewGtk* host_view) {
210 host_view->widget_center_valid_ = false; 210 host_view->MarkCachedWidgetCenterStale();
211 host_view->mouse_has_been_warped_to_new_center_ = false;
212 return FALSE; 211 return FALSE;
213 } 212 }
214 213
215 static gboolean OnKeyPressReleaseEvent(GtkWidget* widget, 214 static gboolean OnKeyPressReleaseEvent(GtkWidget* widget,
216 GdkEventKey* event, 215 GdkEventKey* event,
217 RenderWidgetHostViewGtk* host_view) { 216 RenderWidgetHostViewGtk* host_view) {
218 // Force popups or fullscreen windows to close on Escape so they won't keep 217 // Force popups or fullscreen windows to close on Escape so they won't keep
219 // the keyboard grabbed or be stuck onscreen if the renderer is hanging. 218 // the keyboard grabbed or be stuck onscreen if the renderer is hanging.
220 bool should_close_on_escape = 219 bool should_close_on_escape =
221 (host_view->IsPopup() && host_view->NeedsInputGrab()) || 220 (host_view->IsPopup() && host_view->NeedsInputGrab()) ||
(...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 if (grab_status != GDK_GRAB_SUCCESS) { 1280 if (grab_status != GDK_GRAB_SUCCESS) {
1282 LOG(WARNING) << "Failed to grab pointer for LockMouse. " 1281 LOG(WARNING) << "Failed to grab pointer for LockMouse. "
1283 << "gdk_pointer_grab returned: " << grab_status; 1282 << "gdk_pointer_grab returned: " << grab_status;
1284 mouse_locked_ = false; 1283 mouse_locked_ = false;
1285 return false; 1284 return false;
1286 } 1285 }
1287 1286
1288 // Clear the tooltip window. 1287 // Clear the tooltip window.
1289 SetTooltipText(string16()); 1288 SetTooltipText(string16());
1290 1289
1290 // Ensure that the widget center location will be relevant for this mouse
1291 // lock session. It is updated whenever the window geometry moves
1292 // but may be out of date due to switching tabs.
1293 MarkCachedWidgetCenterStale();
1294
1291 return true; 1295 return true;
1292 } 1296 }
1293 1297
1294 void RenderWidgetHostViewGtk::UnlockMouse() { 1298 void RenderWidgetHostViewGtk::UnlockMouse() {
1295 if (!mouse_locked_) 1299 if (!mouse_locked_)
1296 return; 1300 return;
1297 1301
1298 mouse_locked_ = false; 1302 mouse_locked_ = false;
1299 1303
1300 GtkWidget* widget = view_.get(); 1304 GtkWidget* widget = view_.get();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1358 temp = reinterpret_cast<GdkEventButton*>( 1362 temp = reinterpret_cast<GdkEventButton*>(
1359 gdk_event_copy(reinterpret_cast<GdkEvent*>(event))); 1363 gdk_event_copy(reinterpret_cast<GdkEvent*>(event)));
1360 } 1364 }
1361 1365
1362 if (last_mouse_down_) 1366 if (last_mouse_down_)
1363 gdk_event_free(reinterpret_cast<GdkEvent*>(last_mouse_down_)); 1367 gdk_event_free(reinterpret_cast<GdkEvent*>(last_mouse_down_));
1364 1368
1365 last_mouse_down_ = temp; 1369 last_mouse_down_ = temp;
1366 } 1370 }
1367 1371
1372 void RenderWidgetHostViewGtk::MarkCachedWidgetCenterStale() {
1373 widget_center_valid_ = false;
1374 mouse_has_been_warped_to_new_center_ = false;
1375 }
1376
1368 gfx::Point RenderWidgetHostViewGtk::GetWidgetCenter() { 1377 gfx::Point RenderWidgetHostViewGtk::GetWidgetCenter() {
1369 if (widget_center_valid_) 1378 if (widget_center_valid_)
1370 return widget_center_; 1379 return widget_center_;
1371 1380
1372 GdkWindow* window = gtk_widget_get_window(view_.get()); 1381 GdkWindow* window = gtk_widget_get_window(view_.get());
1373 gint window_x = 0; 1382 gint window_x = 0;
1374 gint window_y = 0; 1383 gint window_y = 0;
1375 gdk_window_get_origin(window, &window_x, &window_y); 1384 gdk_window_get_origin(window, &window_x, &window_y);
1376 gint window_w = gdk_window_get_width(window); 1385 gint window_w = gdk_window_get_width(window);
1377 gint window_h = gdk_window_get_height(window); 1386 gint window_h = gdk_window_get_height(window);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1484 browser_accessibility_manager_.reset( 1493 browser_accessibility_manager_.reset(
1485 BrowserAccessibilityManager::CreateEmptyDocument( 1494 BrowserAccessibilityManager::CreateEmptyDocument(
1486 parent, static_cast<WebAccessibility::State>(0), this)); 1495 parent, static_cast<WebAccessibility::State>(0), this));
1487 } 1496 }
1488 BrowserAccessibilityGtk* root = 1497 BrowserAccessibilityGtk* root =
1489 browser_accessibility_manager_->GetRoot()->ToBrowserAccessibilityGtk(); 1498 browser_accessibility_manager_->GetRoot()->ToBrowserAccessibilityGtk();
1490 1499
1491 atk_object_set_role(root->GetAtkObject(), ATK_ROLE_HTML_CONTAINER); 1500 atk_object_set_role(root->GetAtkObject(), ATK_ROLE_HTML_CONTAINER);
1492 return root->GetAtkObject(); 1501 return root->GetAtkObject();
1493 } 1502 }
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_gtk.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698