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