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

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 d2047f32114fbc625ea982aecd0ff7d9a4640528..a89a9480f5a77c1d89919feae323891a56f95af0 100644
--- a/content/browser/renderer_host/render_widget_host_view_win.h
+++ b/content/browser/renderer_host/render_widget_host_view_win.h
@@ -25,6 +25,7 @@
#include "content/common/notification_registrar.h"
#include "ui/base/win/ime_input.h"
#include "ui/gfx/native_widget_types.h"
+#include "ui/gfx/point.h"
#include "webkit/glue/webcursor.h"
class BackingStore;
@@ -180,6 +181,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,
@@ -290,6 +293,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_|.
@@ -385,6 +393,18 @@ 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.
+ gfx::Point last_mouse_position_;
+ // Relative to the upper-left corner of the screen.
+ gfx::Point last_global_mouse_position_;
+
+ // 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