| 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/display/win/screen_win.h" | 9 #include "ui/display/win/screen_win.h" |
| 10 #include "ui/events/blink/blink_event_util.h" | 10 #include "ui/events/blink/blink_event_util.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 static int g_last_click_count = 0; | 83 static int g_last_click_count = 0; |
| 84 static double g_last_click_time = 0; | 84 static double g_last_click_time = 0; |
| 85 | 85 |
| 86 static LPARAM GetRelativeCursorPos(HWND hwnd) { | 86 static LPARAM GetRelativeCursorPos(HWND hwnd) { |
| 87 POINT pos = {-1, -1}; | 87 POINT pos = {-1, -1}; |
| 88 GetCursorPos(&pos); | 88 GetCursorPos(&pos); |
| 89 ScreenToClient(hwnd, &pos); | 89 ScreenToClient(hwnd, &pos); |
| 90 return MAKELPARAM(pos.x, pos.y); | 90 return MAKELPARAM(pos.x, pos.y); |
| 91 } | 91 } |
| 92 | 92 |
| 93 WebMouseEvent WebMouseEventBuilder::Build(HWND hwnd, | 93 WebMouseEvent WebMouseEventBuilder::Build( |
| 94 UINT message, | 94 HWND hwnd, |
| 95 WPARAM wparam, | 95 UINT message, |
| 96 LPARAM lparam, | 96 WPARAM wparam, |
| 97 double time_stamp) { | 97 LPARAM lparam, |
| 98 double time_stamp, |
| 99 blink::WebPointerProperties::PointerType pointer_type) { |
| 98 WebMouseEvent result; | 100 WebMouseEvent result; |
| 99 | 101 |
| 100 switch (message) { | 102 switch (message) { |
| 101 case WM_MOUSEMOVE: | 103 case WM_MOUSEMOVE: |
| 102 result.type = WebInputEvent::MouseMove; | 104 result.type = WebInputEvent::MouseMove; |
| 103 if (wparam & MK_LBUTTON) | 105 if (wparam & MK_LBUTTON) |
| 104 result.button = WebMouseEvent::ButtonLeft; | 106 result.button = WebMouseEvent::ButtonLeft; |
| 105 else if (wparam & MK_MBUTTON) | 107 else if (wparam & MK_MBUTTON) |
| 106 result.button = WebMouseEvent::ButtonMiddle; | 108 result.button = WebMouseEvent::ButtonMiddle; |
| 107 else if (wparam & MK_RBUTTON) | 109 else if (wparam & MK_RBUTTON) |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 break; | 146 break; |
| 145 case WM_RBUTTONUP: | 147 case WM_RBUTTONUP: |
| 146 result.type = WebInputEvent::MouseUp; | 148 result.type = WebInputEvent::MouseUp; |
| 147 result.button = WebMouseEvent::ButtonRight; | 149 result.button = WebMouseEvent::ButtonRight; |
| 148 break; | 150 break; |
| 149 default: | 151 default: |
| 150 NOTREACHED(); | 152 NOTREACHED(); |
| 151 } | 153 } |
| 152 | 154 |
| 153 result.timeStampSeconds = time_stamp; | 155 result.timeStampSeconds = time_stamp; |
| 156 result.pointerType = pointer_type; |
| 154 | 157 |
| 155 // set position fields: | 158 // set position fields: |
| 156 | 159 |
| 157 result.x = static_cast<short>(LOWORD(lparam)); | 160 result.x = static_cast<short>(LOWORD(lparam)); |
| 158 result.y = static_cast<short>(HIWORD(lparam)); | 161 result.y = static_cast<short>(HIWORD(lparam)); |
| 159 result.windowX = result.x; | 162 result.windowX = result.x; |
| 160 result.windowY = result.y; | 163 result.windowY = result.y; |
| 161 | 164 |
| 162 POINT global_point = { result.x, result.y }; | 165 POINT global_point = { result.x, result.y }; |
| 163 ClientToScreen(hwnd, &global_point); | 166 ClientToScreen(hwnd, &global_point); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 if (wparam & MK_MBUTTON) | 221 if (wparam & MK_MBUTTON) |
| 219 result.modifiers |= WebInputEvent::MiddleButtonDown; | 222 result.modifiers |= WebInputEvent::MiddleButtonDown; |
| 220 if (wparam & MK_RBUTTON) | 223 if (wparam & MK_RBUTTON) |
| 221 result.modifiers |= WebInputEvent::RightButtonDown; | 224 result.modifiers |= WebInputEvent::RightButtonDown; |
| 222 | 225 |
| 223 return result; | 226 return result; |
| 224 } | 227 } |
| 225 | 228 |
| 226 // WebMouseWheelEvent --------------------------------------------------------- | 229 // WebMouseWheelEvent --------------------------------------------------------- |
| 227 | 230 |
| 228 WebMouseWheelEvent WebMouseWheelEventBuilder::Build(HWND hwnd, | 231 WebMouseWheelEvent WebMouseWheelEventBuilder::Build( |
| 229 UINT message, | 232 HWND hwnd, |
| 230 WPARAM wparam, | 233 UINT message, |
| 231 LPARAM lparam, | 234 WPARAM wparam, |
| 232 double time_stamp) { | 235 LPARAM lparam, |
| 236 double time_stamp, |
| 237 blink::WebPointerProperties::PointerType pointer_type) { |
| 233 WebMouseWheelEvent result; | 238 WebMouseWheelEvent result; |
| 234 | 239 |
| 235 result.type = WebInputEvent::MouseWheel; | 240 result.type = WebInputEvent::MouseWheel; |
| 236 | 241 |
| 237 result.timeStampSeconds = time_stamp; | 242 result.timeStampSeconds = time_stamp; |
| 238 | 243 |
| 239 result.button = WebMouseEvent::ButtonNone; | 244 result.button = WebMouseEvent::ButtonNone; |
| 240 | 245 |
| 246 result.pointerType = pointer_type; |
| 247 |
| 241 // Get key state, coordinates, and wheel delta from event. | 248 // Get key state, coordinates, and wheel delta from event. |
| 242 UINT key_state; | 249 UINT key_state; |
| 243 float wheel_delta; | 250 float wheel_delta; |
| 244 bool horizontal_scroll = false; | 251 bool horizontal_scroll = false; |
| 245 if ((message == WM_VSCROLL) || (message == WM_HSCROLL)) { | 252 if ((message == WM_VSCROLL) || (message == WM_HSCROLL)) { |
| 246 // Synthesize mousewheel event from a scroll event. This is needed to | 253 // Synthesize mousewheel event from a scroll event. This is needed to |
| 247 // simulate middle mouse scrolling in some laptops. Use GetAsyncKeyState | 254 // simulate middle mouse scrolling in some laptops. Use GetAsyncKeyState |
| 248 // for key state since we are synthesizing the input event. | 255 // for key state since we are synthesizing the input event. |
| 249 key_state = 0; | 256 key_state = 0; |
| 250 if (GetAsyncKeyState(VK_SHIFT) & 0x8000) | 257 if (GetAsyncKeyState(VK_SHIFT) & 0x8000) |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 result.wheelTicksX = wheel_delta; | 369 result.wheelTicksX = wheel_delta; |
| 363 } else { | 370 } else { |
| 364 result.deltaY = scroll_delta; | 371 result.deltaY = scroll_delta; |
| 365 result.wheelTicksY = wheel_delta; | 372 result.wheelTicksY = wheel_delta; |
| 366 } | 373 } |
| 367 | 374 |
| 368 return result; | 375 return result; |
| 369 } | 376 } |
| 370 | 377 |
| 371 } // namespace content | 378 } // namespace content |
| OLD | NEW |