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

Side by Side 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, 9 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
« no previous file with comments | « no previous file | 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/input/web_input_event_builders_win.h" 5 #include "content/browser/renderer_host/input/web_input_event_builders_win.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "content/browser/renderer_host/input/web_input_event_util.h" 8 #include "content/browser/renderer_host/input/web_input_event_util.h"
9 #include "ui/gfx/win/dpi.h"
9 10
10 using blink::WebInputEvent; 11 using blink::WebInputEvent;
11 using blink::WebKeyboardEvent; 12 using blink::WebKeyboardEvent;
12 using blink::WebMouseEvent; 13 using blink::WebMouseEvent;
13 using blink::WebMouseWheelEvent; 14 using blink::WebMouseWheelEvent;
14 15
15 namespace content { 16 namespace content {
16 17
17 static const unsigned long kDefaultScrollLinesPerWheelDelta = 3; 18 static const unsigned long kDefaultScrollLinesPerWheelDelta = 3;
18 static const unsigned long kDefaultScrollCharsPerWheelDelta = 1; 19 static const unsigned long kDefaultScrollCharsPerWheelDelta = 1;
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 DCHECK(time_ms); 244 DCHECK(time_ms);
244 result.timeStampSeconds = time_ms / 1000.0; 245 result.timeStampSeconds = time_ms / 1000.0;
245 246
246 // set position fields: 247 // set position fields:
247 248
248 result.x = static_cast<short>(LOWORD(lparam)); 249 result.x = static_cast<short>(LOWORD(lparam));
249 result.y = static_cast<short>(HIWORD(lparam)); 250 result.y = static_cast<short>(HIWORD(lparam));
250 result.windowX = result.x; 251 result.windowX = result.x;
251 result.windowY = result.y; 252 result.windowY = result.y;
252 253
253 POINT global_point = { result.x, result.y }; 254 // The mouse coordinates received here are device independent (DIPs). We need
255 // to convert them to physical coordinates before calling Windows APIs like
256 // ClientToScreen, etc.
257 gfx::Point scaled_screen_point(result.x, result.y);
258 scaled_screen_point = gfx::win::DIPToScreenPoint(scaled_screen_point);
259
260 POINT global_point = { scaled_screen_point.x(), scaled_screen_point.y() };
254 ClientToScreen(hwnd, &global_point); 261 ClientToScreen(hwnd, &global_point);
255 262
256 result.globalX = global_point.x; 263 scaled_screen_point.set_x(global_point.x);
257 result.globalY = global_point.y; 264 scaled_screen_point.set_y(global_point.y);
265
266 // We need to convert the point back to DIP before using it.
267 gfx::Point dip_screen_point = gfx::win::ScreenToDIPPoint(
268 scaled_screen_point);
269
270 result.globalX = dip_screen_point.x();
271 result.globalY = dip_screen_point.y();
258 272
259 // calculate number of clicks: 273 // calculate number of clicks:
260 274
261 // This differs slightly from the WebKit code in WebKit/win/WebView.cpp 275 // This differs slightly from the WebKit code in WebKit/win/WebView.cpp
262 // where their original code looks buggy. 276 // where their original code looks buggy.
263 static int last_click_position_x; 277 static int last_click_position_x;
264 static int last_click_position_y; 278 static int last_click_position_y;
265 static WebMouseEvent::Button last_click_button = WebMouseEvent::ButtonLeft; 279 static WebMouseEvent::Button last_click_button = WebMouseEvent::ButtonLeft;
266 280
267 double current_time = result.timeStampSeconds; 281 double current_time = result.timeStampSeconds;
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 result.wheelTicksX = wheel_delta; 468 result.wheelTicksX = wheel_delta;
455 } else { 469 } else {
456 result.deltaY = scroll_delta; 470 result.deltaY = scroll_delta;
457 result.wheelTicksY = wheel_delta; 471 result.wheelTicksY = wheel_delta;
458 } 472 }
459 473
460 return result; 474 return result;
461 } 475 }
462 476
463 } // namespace content 477 } // namespace content
OLDNEW
« 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