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

Unified Diff: content/browser/renderer_host/render_widget_host_view_win.h

Issue 7863003: Mouse lock implementation, including the renderer side and the Windows version of the browser side. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/render_widget_host_view_win.h
diff --git a/content/browser/renderer_host/render_widget_host_view_win.h b/content/browser/renderer_host/render_widget_host_view_win.h
index 0f68b427d2637cec8eb498c1605213a506f61529..2ae7c0ba476aa3431bccbf9bb92798898eb0e273 100644
--- a/content/browser/renderer_host/render_widget_host_view_win.h
+++ b/content/browser/renderer_host/render_widget_host_view_win.h
@@ -178,6 +178,8 @@ class RenderWidgetHostViewWin
virtual void OnAccessibilityNotifications(
const std::vector<ViewHostMsg_AccessibilityNotification_Params>& params
) OVERRIDE;
+ virtual bool LockMouse() OVERRIDE;
+ virtual void UnlockMouse() OVERRIDE;
// Implementation of NotificationObserver:
virtual void Observe(int type,
@@ -288,6 +290,11 @@ class RenderWidgetHostViewWin
const gfx::Rect& pos,
DWORD ex_style);
+ CPoint GetClientCenter() const;
+ void MoveCursorToCenter() const;
+
+ void HandleLockedMouseEvent(UINT message, WPARAM wparam, LPARAM lparam);
+
// The associated Model. While |this| is being Destroyed,
// |render_widget_host_| is NULL and the Windows message loop is run one last
// time. Message handlers must check for a NULL |render_widget_host_|.
@@ -383,6 +390,20 @@ class RenderWidgetHostViewWin
// Is the widget fullscreen?
bool is_fullscreen_;
+ // Used to record the last position of the mouse.
+ // While the mouse is locked, they store the last known position just as mouse
+ // lock was entered.
+ // Relative to the upper-left corner of the view.
+ int last_x_;
+ int last_y_;
+ // Relative to the upper-left corner of the screen.
+ int last_global_x_;
+ int last_global_y_;
+
+ // In the case of the mouse being moved away from the view and then moved
+ // back, we regard the mouse movement as (0, 0).
+ bool ignore_mouse_movement_;
+
DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewWin);
};

Powered by Google App Engine
This is Rietveld 408576698