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 <windowsx.h> | 5 #include <windowsx.h> |
6 | 6 |
7 #include "ui/base/events.h" | 7 #include "ui/base/events.h" |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
11 #include "base/win/win_util.h" | 11 #include "base/win/win_util.h" |
12 #include "ui/base/keycodes/keyboard_code_conversion_win.h" | 12 #include "ui/base/keycodes/keyboard_code_conversion_win.h" |
13 #include "ui/gfx/point.h" | 13 #include "ui/gfx/point.h" |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
| 17 // From MSDN. |
| 18 #define MOUSEEVENTF_FROMTOUCH 0xFF515700 |
| 19 |
17 // Get the native mouse key state from the native event message type. | 20 // Get the native mouse key state from the native event message type. |
18 int GetNativeMouseKey(const base::NativeEvent& native_event) { | 21 int GetNativeMouseKey(const base::NativeEvent& native_event) { |
19 switch (native_event.message) { | 22 switch (native_event.message) { |
20 case WM_LBUTTONDBLCLK: | 23 case WM_LBUTTONDBLCLK: |
21 case WM_LBUTTONDOWN: | 24 case WM_LBUTTONDOWN: |
22 case WM_LBUTTONUP: | 25 case WM_LBUTTONUP: |
23 case WM_NCLBUTTONDBLCLK: | 26 case WM_NCLBUTTONDBLCLK: |
24 case WM_NCLBUTTONDOWN: | 27 case WM_NCLBUTTONDOWN: |
25 case WM_NCLBUTTONUP: | 28 case WM_NCLBUTTONUP: |
26 return MK_LBUTTON; | 29 return MK_LBUTTON; |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 int modifiers = ui::EF_NONE; | 308 int modifiers = ui::EF_NONE; |
306 if (accel.fVirt & FSHIFT) | 309 if (accel.fVirt & FSHIFT) |
307 modifiers |= ui::EF_SHIFT_DOWN; | 310 modifiers |= ui::EF_SHIFT_DOWN; |
308 if (accel.fVirt & FCONTROL) | 311 if (accel.fVirt & FCONTROL) |
309 modifiers |= ui::EF_CONTROL_DOWN; | 312 modifiers |= ui::EF_CONTROL_DOWN; |
310 if (accel.fVirt & FALT) | 313 if (accel.fVirt & FALT) |
311 modifiers |= ui::EF_ALT_DOWN; | 314 modifiers |= ui::EF_ALT_DOWN; |
312 return modifiers; | 315 return modifiers; |
313 } | 316 } |
314 | 317 |
| 318 // Windows emulates mouse messages for touch events. |
| 319 bool IsMouseEventFromTouch(UINT message) { |
| 320 return (message == WM_MOUSEMOVE || |
| 321 message == WM_LBUTTONDOWN || message == WM_LBUTTONUP || |
| 322 message == WM_RBUTTONDOWN || message == WM_RBUTTONUP) && |
| 323 (GetMessageExtraInfo() & MOUSEEVENTF_FROMTOUCH) == |
| 324 MOUSEEVENTF_FROMTOUCH; |
| 325 } |
| 326 |
315 } // namespace ui | 327 } // namespace ui |
OLD | NEW |