OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef UI_BASE_EVENTS_H_ | 5 #ifndef UI_BASE_EVENTS_H_ |
6 #define UI_BASE_EVENTS_H_ | 6 #define UI_BASE_EVENTS_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
| 9 #include "base/event_types.h" |
9 #include "ui/base/keycodes/keyboard_codes.h" | 10 #include "ui/base/keycodes/keyboard_codes.h" |
10 #include "ui/gfx/native_widget_types.h" | 11 #include "ui/gfx/native_widget_types.h" |
11 | 12 |
12 namespace gfx { | 13 namespace gfx { |
13 class Point; | 14 class Point; |
14 } | 15 } |
15 | 16 |
16 #if defined(USE_X11) | |
17 typedef union _XEvent XEvent; | |
18 #endif | |
19 #if defined(USE_WAYLAND) | |
20 namespace ui { | 17 namespace ui { |
21 union WaylandEvent; | |
22 } | |
23 #endif | |
24 | |
25 namespace ui { | |
26 | |
27 #if defined(OS_WIN) | |
28 typedef MSG NativeEvent; | |
29 #elif defined(USE_WAYLAND) | |
30 typedef ui::WaylandEvent* NativeEvent; | |
31 #elif defined(USE_X11) | |
32 typedef XEvent* NativeEvent; | |
33 #else | |
34 typedef void* NativeEvent; | |
35 #endif | |
36 | 18 |
37 // Event types. (prefixed because of a conflict with windows headers) | 19 // Event types. (prefixed because of a conflict with windows headers) |
38 enum EventType { | 20 enum EventType { |
39 ET_UNKNOWN = 0, | 21 ET_UNKNOWN = 0, |
40 ET_MOUSE_PRESSED, | 22 ET_MOUSE_PRESSED, |
41 ET_MOUSE_DRAGGED, | 23 ET_MOUSE_DRAGGED, |
42 ET_MOUSE_RELEASED, | 24 ET_MOUSE_RELEASED, |
43 ET_MOUSE_MOVED, | 25 ET_MOUSE_MOVED, |
44 ET_MOUSE_ENTERED, | 26 ET_MOUSE_ENTERED, |
45 ET_MOUSE_EXITED, | 27 ET_MOUSE_EXITED, |
46 ET_KEY_PRESSED, | 28 ET_KEY_PRESSED, |
47 ET_KEY_RELEASED, | 29 ET_KEY_RELEASED, |
48 ET_MOUSEWHEEL, | 30 ET_MOUSEWHEEL, |
49 ET_TOUCH_RELEASED, | 31 ET_TOUCH_RELEASED, |
50 ET_TOUCH_PRESSED, | 32 ET_TOUCH_PRESSED, |
51 ET_TOUCH_MOVED, | 33 ET_TOUCH_MOVED, |
52 ET_TOUCH_STATIONARY, | 34 ET_TOUCH_STATIONARY, |
53 ET_TOUCH_CANCELLED, | 35 ET_TOUCH_CANCELLED, |
54 ET_DROP_TARGET_EVENT, | 36 ET_DROP_TARGET_EVENT, |
55 ET_FOCUS_CHANGE, | 37 ET_FOCUS_CHANGE, |
56 }; | 38 }; |
57 | 39 |
58 // Event flags currently supported. Although this is a "views" | 40 // Event flags currently supported |
59 // file, this header is used on non-views platforms (e.g. OSX). For | |
60 // example, these EventFlags are used by the automation provider for | |
61 // all platforms. | |
62 enum EventFlags { | 41 enum EventFlags { |
63 EF_CAPS_LOCK_DOWN = 1 << 0, | 42 EF_CAPS_LOCK_DOWN = 1 << 0, |
64 EF_SHIFT_DOWN = 1 << 1, | 43 EF_SHIFT_DOWN = 1 << 1, |
65 EF_CONTROL_DOWN = 1 << 2, | 44 EF_CONTROL_DOWN = 1 << 2, |
66 EF_ALT_DOWN = 1 << 3, | 45 EF_ALT_DOWN = 1 << 3, |
67 EF_LEFT_BUTTON_DOWN = 1 << 4, | 46 EF_LEFT_BUTTON_DOWN = 1 << 4, |
68 EF_MIDDLE_BUTTON_DOWN = 1 << 5, | 47 EF_MIDDLE_BUTTON_DOWN = 1 << 5, |
69 EF_RIGHT_BUTTON_DOWN = 1 << 6, | 48 EF_RIGHT_BUTTON_DOWN = 1 << 6, |
70 EF_COMMAND_DOWN = 1 << 7, // Only useful on OSX | 49 EF_COMMAND_DOWN = 1 << 7, // Only useful on OSX |
71 EF_EXTENDED = 1 << 8, // Windows extended key (see WM_KEYDOWN doc) | 50 EF_EXTENDED = 1 << 8, // Windows extended key (see WM_KEYDOWN doc) |
(...skipping 13 matching lines...) Expand all Loading... |
85 // started touch sequence. | 64 // started touch sequence. |
86 TOUCH_STATUS_END, // The touch event ended the touch sequence. | 65 TOUCH_STATUS_END, // The touch event ended the touch sequence. |
87 TOUCH_STATUS_CANCEL, // The touch event was cancelled, but didn't | 66 TOUCH_STATUS_CANCEL, // The touch event was cancelled, but didn't |
88 // terminate the touch sequence. | 67 // terminate the touch sequence. |
89 TOUCH_STATUS_SYNTH_MOUSE // The touch event was not processed, but a | 68 TOUCH_STATUS_SYNTH_MOUSE // The touch event was not processed, but a |
90 // synthetic mouse event generated from the | 69 // synthetic mouse event generated from the |
91 // unused touch event was handled. | 70 // unused touch event was handled. |
92 }; | 71 }; |
93 | 72 |
94 // Get the EventType from a native event. | 73 // Get the EventType from a native event. |
95 UI_EXPORT EventType EventTypeFromNative(const NativeEvent& native_event); | 74 UI_EXPORT EventType EventTypeFromNative(const base::NativeEvent& native_event); |
96 | 75 |
97 // Get the EventFlags from a native event. | 76 // Get the EventFlags from a native event. |
98 UI_EXPORT int EventFlagsFromNative(const NativeEvent& native_event); | 77 UI_EXPORT int EventFlagsFromNative(const base::NativeEvent& native_event); |
99 | 78 |
100 // Get the location from a native event. | 79 // Get the location from a native event. |
101 UI_EXPORT gfx::Point EventLocationFromNative(const NativeEvent& native_event); | 80 UI_EXPORT gfx::Point EventLocationFromNative( |
| 81 const base::NativeEvent& native_event); |
102 | 82 |
103 // Returns the KeyboardCode from a native event. | 83 // Returns the KeyboardCode from a native event. |
104 UI_EXPORT KeyboardCode KeyboardCodeFromNative(const NativeEvent& native_event); | 84 UI_EXPORT KeyboardCode KeyboardCodeFromNative( |
| 85 const base::NativeEvent& native_event); |
105 | 86 |
106 // Returns true if the message is a mouse event. | 87 // Returns true if the message is a mouse event. |
107 UI_EXPORT bool IsMouseEvent(const NativeEvent& native_event); | 88 UI_EXPORT bool IsMouseEvent(const base::NativeEvent& native_event); |
108 | 89 |
109 // Get the mouse wheel offset from a native event. | 90 // Get the mouse wheel offset from a native event. |
110 UI_EXPORT int GetMouseWheelOffset(const NativeEvent& native_event); | 91 UI_EXPORT int GetMouseWheelOffset(const base::NativeEvent& native_event); |
111 | 92 |
112 } // namespace ui | 93 } // namespace ui |
113 | 94 |
114 #endif // UI_BASE_EVENTS_H_ | 95 #endif // UI_BASE_EVENTS_H_ |
OLD | NEW |