| OLD | NEW |
| 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |