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

Side by Side Diff: content/browser/renderer_host/input/web_input_event_builders_win.cc

Issue 981393002: Second attempt at fixing pointer lock issues with Windows HiDPI. (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 | content/browser/renderer_host/render_widget_host_view_aura.cc » ('j') | 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 #include "ui/gfx/win/dpi.h"
10 10
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 POINT pos = {-1, -1}; 181 POINT pos = {-1, -1};
182 GetCursorPos(&pos); 182 GetCursorPos(&pos);
183 ScreenToClient(hwnd, &pos); 183 ScreenToClient(hwnd, &pos);
184 return MAKELPARAM(pos.x, pos.y); 184 return MAKELPARAM(pos.x, pos.y);
185 } 185 }
186 186
187 WebMouseEvent WebMouseEventBuilder::Build(HWND hwnd, 187 WebMouseEvent WebMouseEventBuilder::Build(HWND hwnd,
188 UINT message, 188 UINT message,
189 WPARAM wparam, 189 WPARAM wparam,
190 LPARAM lparam, 190 LPARAM lparam,
191 DWORD time_ms) { 191 DWORD time_ms) {
scottmg 2015/03/09 21:33:18 I doesn't seem particularly clear whether this sho
ananta 2015/03/09 22:55:59 Added a content_unittest WebInputEventBuilderTest.
192 WebMouseEvent result; 192 WebMouseEvent result;
193 193
194 switch (message) { 194 switch (message) {
195 case WM_MOUSEMOVE: 195 case WM_MOUSEMOVE:
196 result.type = WebInputEvent::MouseMove; 196 result.type = WebInputEvent::MouseMove;
197 if (wparam & MK_LBUTTON) 197 if (wparam & MK_LBUTTON)
198 result.button = WebMouseEvent::ButtonLeft; 198 result.button = WebMouseEvent::ButtonLeft;
199 else if (wparam & MK_MBUTTON) 199 else if (wparam & MK_MBUTTON)
200 result.button = WebMouseEvent::ButtonMiddle; 200 result.button = WebMouseEvent::ButtonMiddle;
201 else if (wparam & MK_RBUTTON) 201 else if (wparam & MK_RBUTTON)
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 DCHECK(time_ms); 244 DCHECK(time_ms);
245 result.timeStampSeconds = time_ms / 1000.0; 245 result.timeStampSeconds = time_ms / 1000.0;
246 246
247 // set position fields: 247 // set position fields:
248 248
249 result.x = static_cast<short>(LOWORD(lparam)); 249 result.x = static_cast<short>(LOWORD(lparam));
250 result.y = static_cast<short>(HIWORD(lparam)); 250 result.y = static_cast<short>(HIWORD(lparam));
251 result.windowX = result.x; 251 result.windowX = result.x;
252 result.windowY = result.y; 252 result.windowY = result.y;
253 253
254 // The mouse coordinates received here are device independent (DIPs). We need 254 POINT global_point = { result.x, result.y };
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() };
261 ClientToScreen(hwnd, &global_point); 255 ClientToScreen(hwnd, &global_point);
262 256
263 scaled_screen_point.set_x(global_point.x); 257 // We need to convert the global point back to DIP before using it.
264 scaled_screen_point.set_y(global_point.y); 258 gfx::Point dip_global_point = gfx::win::ScreenToDIPPoint(
259 gfx::Point(global_point.x, global_point.y));
265 260
266 // We need to convert the point back to DIP before using it. 261 result.globalX = dip_global_point.x();
267 gfx::Point dip_screen_point = gfx::win::ScreenToDIPPoint( 262 result.globalY = dip_global_point.y();
268 scaled_screen_point);
269
270 result.globalX = dip_screen_point.x();
271 result.globalY = dip_screen_point.y();
272 263
273 // calculate number of clicks: 264 // calculate number of clicks:
274 265
275 // This differs slightly from the WebKit code in WebKit/win/WebView.cpp 266 // This differs slightly from the WebKit code in WebKit/win/WebView.cpp
276 // where their original code looks buggy. 267 // where their original code looks buggy.
277 static int last_click_position_x; 268 static int last_click_position_x;
278 static int last_click_position_y; 269 static int last_click_position_y;
279 static WebMouseEvent::Button last_click_button = WebMouseEvent::ButtonLeft; 270 static WebMouseEvent::Button last_click_button = WebMouseEvent::ButtonLeft;
280 271
281 double current_time = result.timeStampSeconds; 272 double current_time = result.timeStampSeconds;
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 result.wheelTicksX = wheel_delta; 459 result.wheelTicksX = wheel_delta;
469 } else { 460 } else {
470 result.deltaY = scroll_delta; 461 result.deltaY = scroll_delta;
471 result.wheelTicksY = wheel_delta; 462 result.wheelTicksY = wheel_delta;
472 } 463 }
473 464
474 return result; 465 return result;
475 } 466 }
476 467
477 } // namespace content 468 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/render_widget_host_view_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698