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

Unified Diff: content/browser/renderer_host/input/web_input_event_builders_win.cc

Issue 973123003: Ensure that pointer lock works correctly in Windows 7+ with HiDPI scale factors above 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/input/web_input_event_builders_win.cc
diff --git a/content/browser/renderer_host/input/web_input_event_builders_win.cc b/content/browser/renderer_host/input/web_input_event_builders_win.cc
index 73c9174bfe4d946f77b160f93fe54f3146aa57b6..831f4034b279f2187ac12f9473dba6ed56c025e9 100644
--- a/content/browser/renderer_host/input/web_input_event_builders_win.cc
+++ b/content/browser/renderer_host/input/web_input_event_builders_win.cc
@@ -6,6 +6,7 @@
#include "base/logging.h"
#include "content/browser/renderer_host/input/web_input_event_util.h"
+#include "ui/gfx/win/dpi.h"
using blink::WebInputEvent;
using blink::WebKeyboardEvent;
@@ -250,11 +251,24 @@ WebMouseEvent WebMouseEventBuilder::Build(HWND hwnd,
result.windowX = result.x;
result.windowY = result.y;
- POINT global_point = { result.x, result.y };
+ // The mouse coordinates received here are device independent (DIPs). We need
+ // to convert them to physical coordinates before calling Windows APIs like
+ // ClientToScreen, etc.
+ gfx::Point scaled_screen_point(result.x, result.y);
+ scaled_screen_point = gfx::win::DIPToScreenPoint(scaled_screen_point);
+
+ POINT global_point = { scaled_screen_point.x(), scaled_screen_point.y() };
ClientToScreen(hwnd, &global_point);
- result.globalX = global_point.x;
- result.globalY = global_point.y;
+ scaled_screen_point.set_x(global_point.x);
+ scaled_screen_point.set_y(global_point.y);
+
+ // We need to convert the point back to DIP before using it.
+ gfx::Point dip_screen_point = gfx::win::ScreenToDIPPoint(
+ scaled_screen_point);
+
+ result.globalX = dip_screen_point.x();
+ result.globalY = dip_screen_point.y();
// calculate number of clicks:
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698