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 // (0 = pen, 1 = touch). | |
24 #define MOUSEEVENTF_FROMTOUCH (0xFF515700 | 0x80) | 25 #define MOUSEEVENTF_FROMTOUCH (0xFF515700 | 0x80) |
26 #define MOUSEEVENTF_FROMTOUCHPEN 0xFF515700 | |
mustaq
2016/06/02 15:28:24
Please move FROMTOUCHPEN above FROMTOUCH to avoid
lanwei
2016/06/02 16:07:06
Done.
| |
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 LPARAM message = ::GetMessageExtraInfo(); |
Navid Zolghadr
2016/06/01 19:15:29
Do we have any sort of unique id for each pen devi
lanwei
2016/06/01 22:54:31
"The lower 8 bits returned from GetMessageExtraInf
Navid Zolghadr
2016/06/02 14:29:37
Although it is not complete and that does not diff
| |
299 if ((message & SIGNATURE_MASK) != MOUSEEVENTF_FROMTOUCHPEN) | |
300 return PointerDetails(EventPointerType::POINTER_TYPE_MOUSE); | |
301 | |
302 if ((message & MOUSEEVENTF_FROMTOUCH) == MOUSEEVENTF_FROMTOUCH) | |
303 return PointerDetails(EventPointerType::POINTER_TYPE_TOUCH); | |
Navid Zolghadr
2016/06/01 19:15:29
Is this possible for this touch if to run? I mean
lanwei
2016/06/01 22:54:31
I am not sure if there are some cases the events a
tdresser
2016/06/02 13:40:40
https://code.google.com/p/chromium/codesearch#chro
lanwei
2016/06/02 16:07:06
The mouseevent from touch will set a flag EF_FROM_
| |
304 | |
305 return PointerDetails(EventPointerType::POINTER_TYPE_PEN); | |
296 } | 306 } |
297 | 307 |
298 gfx::Vector2d GetMouseWheelOffset(const base::NativeEvent& native_event) { | 308 gfx::Vector2d GetMouseWheelOffset(const base::NativeEvent& native_event) { |
299 DCHECK(native_event.message == WM_MOUSEWHEEL || | 309 DCHECK(native_event.message == WM_MOUSEWHEEL || |
300 native_event.message == WM_MOUSEHWHEEL); | 310 native_event.message == WM_MOUSEHWHEEL); |
301 if (native_event.message == WM_MOUSEWHEEL) | 311 if (native_event.message == WM_MOUSEWHEEL) |
302 return gfx::Vector2d(0, GET_WHEEL_DELTA_WPARAM(native_event.wParam)); | 312 return gfx::Vector2d(0, GET_WHEEL_DELTA_WPARAM(native_event.wParam)); |
303 return gfx::Vector2d(GET_WHEEL_DELTA_WPARAM(native_event.wParam), 0); | 313 return gfx::Vector2d(GET_WHEEL_DELTA_WPARAM(native_event.wParam), 0); |
304 } | 314 } |
305 | 315 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
405 } | 415 } |
406 | 416 |
407 LPARAM GetLParamFromScanCode(uint16_t scan_code) { | 417 LPARAM GetLParamFromScanCode(uint16_t scan_code) { |
408 LPARAM l_param = static_cast<LPARAM>(scan_code & 0x00FF) << 16; | 418 LPARAM l_param = static_cast<LPARAM>(scan_code & 0x00FF) << 16; |
409 if ((scan_code & 0xE000) == 0xE000) | 419 if ((scan_code & 0xE000) == 0xE000) |
410 l_param |= (1 << 24); | 420 l_param |= (1 << 24); |
411 return l_param; | 421 return l_param; |
412 } | 422 } |
413 | 423 |
414 } // namespace ui | 424 } // namespace ui |
OLD | NEW |