| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stdint.h> | 5 #include <stdint.h> |
| 6 #include <windowsx.h> | 6 #include <windowsx.h> |
| 7 | 7 |
| 8 #include "ui/events/event_constants.h" | 8 #include "ui/events/event_constants.h" |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "ui/events/event_utils.h" | 12 #include "ui/events/event_utils.h" |
| 13 #include "ui/events/keycodes/keyboard_code_conversion_win.h" | 13 #include "ui/events/keycodes/keyboard_code_conversion_win.h" |
| 14 #include "ui/events/win/system_event_state_lookup.h" | 14 #include "ui/events/win/system_event_state_lookup.h" |
| 15 #include "ui/gfx/geometry/point.h" | 15 #include "ui/gfx/geometry/point.h" |
| 16 | 16 |
| 17 namespace ui { | 17 namespace ui { |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 // From MSDN: "Mouse" events are flagged with 0xFF515700 if they come | 21 // From MSDN: "Mouse" events are flagged with 0xFF515700 if they come |
| 22 // from a touch or stylus device. In Vista or later, they are also flagged | 22 // from a touch or stylus device. In Vista or later, the eighth bit, |
| 23 // with 0x80 if they come from touch. | 23 // masked by 0x80, is used to differentiate touch input from pen input |
| 24 #define MOUSEEVENTF_FROMTOUCH (0xFF515700 | 0x80) | 24 // (0 = pen, 1 = touch). |
| 25 #define MOUSEEVENTF_FROMTOUCHPEN 0xFF515700 |
| 26 #define MOUSEEVENTF_FROMTOUCH (MOUSEEVENTF_FROMTOUCHPEN | 0x80) |
| 27 #define SIGNATURE_MASK 0xFFFFFF00 |
| 25 | 28 |
| 26 // Get the native mouse key state from the native event message type. | 29 // Get the native mouse key state from the native event message type. |
| 27 int GetNativeMouseKey(const base::NativeEvent& native_event) { | 30 int GetNativeMouseKey(const base::NativeEvent& native_event) { |
| 28 switch (native_event.message) { | 31 switch (native_event.message) { |
| 29 case WM_LBUTTONDBLCLK: | 32 case WM_LBUTTONDBLCLK: |
| 30 case WM_LBUTTONDOWN: | 33 case WM_LBUTTONDOWN: |
| 31 case WM_LBUTTONUP: | 34 case WM_LBUTTONUP: |
| 32 case WM_NCLBUTTONDBLCLK: | 35 case WM_NCLBUTTONDBLCLK: |
| 33 case WM_NCLBUTTONDOWN: | 36 case WM_NCLBUTTONDOWN: |
| 34 case WM_NCLBUTTONUP: | 37 case WM_NCLBUTTONUP: |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 return EF_RIGHT_MOUSE_BUTTON; | 288 return EF_RIGHT_MOUSE_BUTTON; |
| 286 // TODO: add support for MK_XBUTTON1. | 289 // TODO: add support for MK_XBUTTON1. |
| 287 default: | 290 default: |
| 288 break; | 291 break; |
| 289 } | 292 } |
| 290 return 0; | 293 return 0; |
| 291 } | 294 } |
| 292 | 295 |
| 293 PointerDetails GetMousePointerDetailsFromNative( | 296 PointerDetails GetMousePointerDetailsFromNative( |
| 294 const base::NativeEvent& native_event) { | 297 const base::NativeEvent& native_event) { |
| 295 return PointerDetails(EventPointerType::POINTER_TYPE_MOUSE); | 298 // We should filter out all the mouse events Synthesized from touch events. |
| 299 // TODO(lanwei): Will set the pointer ID, see https://crbug.com/616771. |
| 300 if ((GetMessageExtraInfo() & SIGNATURE_MASK) != MOUSEEVENTF_FROMTOUCHPEN) |
| 301 return PointerDetails(EventPointerType::POINTER_TYPE_MOUSE); |
| 302 |
| 303 return PointerDetails(EventPointerType::POINTER_TYPE_PEN); |
| 296 } | 304 } |
| 297 | 305 |
| 298 gfx::Vector2d GetMouseWheelOffset(const base::NativeEvent& native_event) { | 306 gfx::Vector2d GetMouseWheelOffset(const base::NativeEvent& native_event) { |
| 299 DCHECK(native_event.message == WM_MOUSEWHEEL || | 307 DCHECK(native_event.message == WM_MOUSEWHEEL || |
| 300 native_event.message == WM_MOUSEHWHEEL); | 308 native_event.message == WM_MOUSEHWHEEL); |
| 301 if (native_event.message == WM_MOUSEWHEEL) | 309 if (native_event.message == WM_MOUSEWHEEL) |
| 302 return gfx::Vector2d(0, GET_WHEEL_DELTA_WPARAM(native_event.wParam)); | 310 return gfx::Vector2d(0, GET_WHEEL_DELTA_WPARAM(native_event.wParam)); |
| 303 return gfx::Vector2d(GET_WHEEL_DELTA_WPARAM(native_event.wParam), 0); | 311 return gfx::Vector2d(GET_WHEEL_DELTA_WPARAM(native_event.wParam), 0); |
| 304 } | 312 } |
| 305 | 313 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 } | 413 } |
| 406 | 414 |
| 407 LPARAM GetLParamFromScanCode(uint16_t scan_code) { | 415 LPARAM GetLParamFromScanCode(uint16_t scan_code) { |
| 408 LPARAM l_param = static_cast<LPARAM>(scan_code & 0x00FF) << 16; | 416 LPARAM l_param = static_cast<LPARAM>(scan_code & 0x00FF) << 16; |
| 409 if ((scan_code & 0xE000) == 0xE000) | 417 if ((scan_code & 0xE000) == 0xE000) |
| 410 l_param |= (1 << 24); | 418 l_param |= (1 << 24); |
| 411 return l_param; | 419 return l_param; |
| 412 } | 420 } |
| 413 | 421 |
| 414 } // namespace ui | 422 } // namespace ui |
| OLD | NEW |