[email protected] | 6084b45 | 2012-01-17 15:03:00 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 8d577a70 | 2011-02-10 04:56:36 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | 86ccbd4 | 2013-09-18 18:11:54 | [diff] [blame] | 5 | #ifndef UI_EVENTS_EVENT_CONSTANTS_H_ |
| 6 | #define UI_EVENTS_EVENT_CONSTANTS_H_ |
[email protected] | 8d577a70 | 2011-02-10 04:56:36 | [diff] [blame] | 7 | |
| 8 | namespace ui { |
| 9 | |
| 10 | // Event types. (prefixed because of a conflict with windows headers) |
| 11 | enum EventType { |
| 12 | ET_UNKNOWN = 0, |
| 13 | ET_MOUSE_PRESSED, |
| 14 | ET_MOUSE_DRAGGED, |
| 15 | ET_MOUSE_RELEASED, |
| 16 | ET_MOUSE_MOVED, |
| 17 | ET_MOUSE_ENTERED, |
| 18 | ET_MOUSE_EXITED, |
| 19 | ET_KEY_PRESSED, |
| 20 | ET_KEY_RELEASED, |
| 21 | ET_MOUSEWHEEL, |
[email protected] | 759017e0 | 2012-02-11 20:46:11 | [diff] [blame] | 22 | ET_MOUSE_CAPTURE_CHANGED, // Event has no location. |
[email protected] | 8d577a70 | 2011-02-10 04:56:36 | [diff] [blame] | 23 | ET_TOUCH_RELEASED, |
| 24 | ET_TOUCH_PRESSED, |
sky | a1b5036 | 2016-08-16 00:24:09 | [diff] [blame] | 25 | // NOTE: This corresponds to a drag and is always preceeded by an |
| 26 | // ET_TOUCH_PRESSED. GestureRecognizers generally ignore ET_TOUCH_MOVED events |
| 27 | // without a corresponding ET_TOUCH_PRESSED. |
[email protected] | 8d577a70 | 2011-02-10 04:56:36 | [diff] [blame] | 28 | ET_TOUCH_MOVED, |
[email protected] | 8d577a70 | 2011-02-10 04:56:36 | [diff] [blame] | 29 | ET_TOUCH_CANCELLED, |
[email protected] | e0f17f9 | 2011-09-08 17:29:58 | [diff] [blame] | 30 | ET_DROP_TARGET_EVENT, |
[email protected] | 6084b45 | 2012-01-17 15:03:00 | [diff] [blame] | 31 | |
moshayedi | 6a948a7 | 2016-02-11 21:14:17 | [diff] [blame] | 32 | // PointerEvent types |
| 33 | ET_POINTER_DOWN, |
| 34 | ET_POINTER_MOVED, |
| 35 | ET_POINTER_UP, |
| 36 | ET_POINTER_CANCELLED, |
| 37 | ET_POINTER_ENTERED, |
| 38 | ET_POINTER_EXITED, |
riajiang | 70fa957 | 2016-08-26 21:30:49 | [diff] [blame] | 39 | ET_POINTER_WHEEL_CHANGED, |
| 40 | ET_POINTER_CAPTURE_CHANGED, |
moshayedi | 6a948a7 | 2016-02-11 21:14:17 | [diff] [blame] | 41 | |
[email protected] | 6084b45 | 2012-01-17 15:03:00 | [diff] [blame] | 42 | // GestureEvent types |
| 43 | ET_GESTURE_SCROLL_BEGIN, |
[email protected] | 8fd82b8c | 2014-03-05 18:50:00 | [diff] [blame] | 44 | ET_GESTURE_TYPE_START = ET_GESTURE_SCROLL_BEGIN, |
[email protected] | 6084b45 | 2012-01-17 15:03:00 | [diff] [blame] | 45 | ET_GESTURE_SCROLL_END, |
| 46 | ET_GESTURE_SCROLL_UPDATE, |
| 47 | ET_GESTURE_TAP, |
[email protected] | f884a00 | 2012-06-07 15:33:05 | [diff] [blame] | 48 | ET_GESTURE_TAP_DOWN, |
[email protected] | 7696c408 | 2012-09-11 16:37:59 | [diff] [blame] | 49 | ET_GESTURE_TAP_CANCEL, |
moshayedi | 6a948a7 | 2016-02-11 21:14:17 | [diff] [blame] | 50 | ET_GESTURE_TAP_UNCONFIRMED, // User tapped, but the tap delay hasn't expired. |
[email protected] | 3cb7be4 | 2014-03-04 21:43:35 | [diff] [blame] | 51 | ET_GESTURE_DOUBLE_TAP, |
[email protected] | d476bfa | 2014-06-02 18:02:51 | [diff] [blame] | 52 | ET_GESTURE_BEGIN, // The first event sent when each finger is pressed. |
| 53 | ET_GESTURE_END, // Sent for each released finger. |
[email protected] | d1f9a25a | 2012-06-05 21:48:01 | [diff] [blame] | 54 | ET_GESTURE_TWO_FINGER_TAP, |
[email protected] | 6998956 | 2012-02-08 15:57:33 | [diff] [blame] | 55 | ET_GESTURE_PINCH_BEGIN, |
| 56 | ET_GESTURE_PINCH_END, |
| 57 | ET_GESTURE_PINCH_UPDATE, |
[email protected] | 4448d2c | 2012-02-21 19:08:27 | [diff] [blame] | 58 | ET_GESTURE_LONG_PRESS, |
[email protected] | dd5b9cf9 | 2012-11-02 02:49:35 | [diff] [blame] | 59 | ET_GESTURE_LONG_TAP, |
[email protected] | e9ea140 | 2014-05-28 01:13:35 | [diff] [blame] | 60 | // A SWIPE gesture can happen at the end of a touch sequence involving one or |
| 61 | // more fingers if the finger velocity was high enough when the first finger |
| 62 | // was released. |
| 63 | ET_GESTURE_SWIPE, |
[email protected] | 5fd860ab | 2013-10-22 21:17:16 | [diff] [blame] | 64 | ET_GESTURE_SHOW_PRESS, |
[email protected] | 91e2003 | 2012-03-20 02:47:24 | [diff] [blame] | 65 | |
| 66 | // Scroll support. |
| 67 | // TODO[davemoore] we need to unify these events w/ touch and gestures. |
| 68 | ET_SCROLL, |
| 69 | ET_SCROLL_FLING_START, |
| 70 | ET_SCROLL_FLING_CANCEL, |
[email protected] | 8fd82b8c | 2014-03-05 18:50:00 | [diff] [blame] | 71 | ET_GESTURE_TYPE_END = ET_SCROLL_FLING_CANCEL, |
[email protected] | 8349a20 | 2012-11-20 22:05:15 | [diff] [blame] | 72 | |
[email protected] | af5e2527 | 2013-02-21 01:17:36 | [diff] [blame] | 73 | // Sent by the system to indicate any modal type operations, such as drag and |
| 74 | // drop or menus, should stop. |
| 75 | ET_CANCEL_MODE, |
| 76 | |
[email protected] | 2a21916a | 2013-06-20 02:38:56 | [diff] [blame] | 77 | // Sent by the CrOS gesture library for interesting patterns that we want |
| 78 | // to track with the UMA system. |
| 79 | ET_UMA_DATA, |
| 80 | |
[email protected] | 8349a20 | 2012-11-20 22:05:15 | [diff] [blame] | 81 | // Must always be last. User namespace starts above this value. |
| 82 | // See ui::RegisterCustomEventType(). |
| 83 | ET_LAST |
[email protected] | 8d577a70 | 2011-02-10 04:56:36 | [diff] [blame] | 84 | }; |
| 85 | |
pkasting | cc7f6ac | 2016-01-08 23:38:47 | [diff] [blame] | 86 | // Event flags currently supported. It is OK to add values to the middle of |
| 87 | // this list and/or reorder it, but make sure you also touch the various other |
| 88 | // enums/constants that want to stay in sync with this. |
[email protected] | 8d577a70 | 2011-02-10 04:56:36 | [diff] [blame] | 89 | enum EventFlags { |
pkotwicz | a4e71e69 | 2015-03-06 20:59:03 | [diff] [blame] | 90 | EF_NONE = 0, // Used to denote no flags explicitly |
pkasting | cc7f6ac | 2016-01-08 23:38:47 | [diff] [blame] | 91 | |
| 92 | // Universally applicable status bits. |
| 93 | EF_IS_SYNTHESIZED = 1 << 0, |
| 94 | |
| 95 | // Modifier key state. |
pkotwicz | a4e71e69 | 2015-03-06 20:59:03 | [diff] [blame] | 96 | EF_SHIFT_DOWN = 1 << 1, |
| 97 | EF_CONTROL_DOWN = 1 << 2, |
| 98 | EF_ALT_DOWN = 1 << 3, |
pkasting | cc7f6ac | 2016-01-08 23:38:47 | [diff] [blame] | 99 | EF_COMMAND_DOWN = 1 << 4, // GUI Key (e.g. Command on OS X |
pkotwicz | a4e71e69 | 2015-03-06 20:59:03 | [diff] [blame] | 100 | // keyboards, Search on Chromebook |
| 101 | // keyboards, Windows on MS-oriented |
| 102 | // keyboards) |
pkasting | cc7f6ac | 2016-01-08 23:38:47 | [diff] [blame] | 103 | EF_ALTGR_DOWN = 1 << 5, |
| 104 | EF_MOD3_DOWN = 1 << 6, |
| 105 | |
Joe Downing | a8e74ac | 2018-02-26 17:10:24 | [diff] [blame^] | 106 | // Other keyboard states. |
pkasting | cc7f6ac | 2016-01-08 23:38:47 | [diff] [blame] | 107 | EF_NUM_LOCK_ON = 1 << 7, |
| 108 | EF_CAPS_LOCK_ON = 1 << 8, |
| 109 | EF_SCROLL_LOCK_ON = 1 << 9, |
| 110 | |
| 111 | // Mouse buttons. |
| 112 | EF_LEFT_MOUSE_BUTTON = 1 << 10, |
| 113 | EF_MIDDLE_MOUSE_BUTTON = 1 << 11, |
| 114 | EF_RIGHT_MOUSE_BUTTON = 1 << 12, |
| 115 | EF_BACK_MOUSE_BUTTON = 1 << 13, |
| 116 | EF_FORWARD_MOUSE_BUTTON = 1 << 14, |
[email protected] | 8d577a70 | 2011-02-10 04:56:36 | [diff] [blame] | 117 | }; |
| 118 | |
Joe Downing | a8e74ac | 2018-02-26 17:10:24 | [diff] [blame^] | 119 | // Flags specific to key events. |
[email protected] | 5698964d | 2014-04-16 18:32:49 | [diff] [blame] | 120 | enum KeyEventFlags { |
pkasting | cc7f6ac | 2016-01-08 23:38:47 | [diff] [blame] | 121 | EF_IME_FABRICATED_KEY = 1 << 15, // Key event fabricated by the underlying |
[email protected] | 73749e6a | 2014-04-28 20:49:26 | [diff] [blame] | 122 | // IME without a user action. |
| 123 | // (Linux X11 only) |
pkasting | cc7f6ac | 2016-01-08 23:38:47 | [diff] [blame] | 124 | EF_IS_REPEAT = 1 << 16, |
| 125 | EF_FINAL = 1 << 17, // Do not remap; the event was created with |
[email protected] | 1c64977 | 2014-07-18 14:06:12 | [diff] [blame] | 126 | // the desired final values. |
pkasting | cc7f6ac | 2016-01-08 23:38:47 | [diff] [blame] | 127 | EF_IS_EXTENDED_KEY = 1 << 18, // Windows extended key (see WM_KEYDOWN doc) |
[email protected] | 5698964d | 2014-04-16 18:32:49 | [diff] [blame] | 128 | }; |
| 129 | |
Joe Downing | a8e74ac | 2018-02-26 17:10:24 | [diff] [blame^] | 130 | // Flags specific to mouse events. |
[email protected] | 8d577a70 | 2011-02-10 04:56:36 | [diff] [blame] | 131 | enum MouseEventFlags { |
denniskempin | 6bc51438 | 2016-08-24 01:15:30 | [diff] [blame] | 132 | EF_IS_DOUBLE_CLICK = 1 << 15, |
| 133 | EF_IS_TRIPLE_CLICK = 1 << 16, |
| 134 | EF_IS_NON_CLIENT = 1 << 17, |
| 135 | EF_FROM_TOUCH = 1 << 18, // Indicates this mouse event is generated |
[email protected] | 34538533 | 2014-05-29 19:01:44 | [diff] [blame] | 136 | // from an unconsumed touch/gesture event. |
pkasting | cc7f6ac | 2016-01-08 23:38:47 | [diff] [blame] | 137 | EF_TOUCH_ACCESSIBILITY = 1 << 19, // Indicates this event was generated from |
[email protected] | 34538533 | 2014-05-29 19:01:44 | [diff] [blame] | 138 | // touch accessibility mode. |
Eugene Girard | e8bcc08 | 2017-08-25 05:20:07 | [diff] [blame] | 139 | EF_CURSOR_HIDE = 1 << 20, // Indicates this mouse event is generated |
chaopeng | 8f89459 | 2017-06-29 23:20:45 | [diff] [blame] | 140 | // because the cursor was just hidden. This |
| 141 | // can be used to update hover state. |
[email protected] | 8d577a70 | 2011-02-10 04:56:36 | [diff] [blame] | 142 | }; |
| 143 | |
[email protected] | 5b174e0a | 2012-09-04 01:14:43 | [diff] [blame] | 144 | // Result of dispatching an event. |
| 145 | enum EventResult { |
tdresser | 8879cfc | 2014-12-09 21:00:17 | [diff] [blame] | 146 | ER_UNHANDLED = 0, // The event hasn't been handled. The event can be |
| 147 | // propagated to other handlers. |
| 148 | ER_HANDLED = 1 << 0, // The event has already been handled, but it can |
| 149 | // still be propagated to other handlers. |
| 150 | ER_CONSUMED = 1 << 1, // The event has been handled, and it should not be |
| 151 | // propagated to other handlers. |
| 152 | ER_DISABLE_SYNC_HANDLING = |
| 153 | 1 << 2, // The event shouldn't be handled synchronously. This |
| 154 | // happens if the event is being handled |
| 155 | // asynchronously, or if the event is invalid and |
| 156 | // shouldn't be handled at all. |
[email protected] | 5b174e0a | 2012-09-04 01:14:43 | [diff] [blame] | 157 | }; |
| 158 | |
[email protected] | 1eeb97132 | 2012-09-11 05:56:51 | [diff] [blame] | 159 | // Phase of the event dispatch. |
| 160 | enum EventPhase { |
| 161 | EP_PREDISPATCH, |
| 162 | EP_PRETARGET, |
| 163 | EP_TARGET, |
| 164 | EP_POSTTARGET, |
| 165 | EP_POSTDISPATCH |
| 166 | }; |
| 167 | |
tapted | b94b06c | 2016-09-27 02:16:15 | [diff] [blame] | 168 | // Momentum phase information used for a ScrollEvent. |
| 169 | enum class EventMomentumPhase { |
| 170 | // Event is a non-momentum update to an event stream already begun. |
| 171 | NONE, |
| 172 | |
| 173 | // Event is the beginning of an event stream that may result in momentum. |
| 174 | MAY_BEGIN, |
| 175 | |
| 176 | // Event is an update while in a momentum phase. A "begin" event for the |
| 177 | // momentum phase portion of an event stream uses this also, but the scroll |
| 178 | // offsets will be zero. |
| 179 | INERTIAL_UPDATE, |
| 180 | |
| 181 | // Event marks the end of the current event stream. Note that this is also set |
| 182 | // for events that are not a "stream", but indicate both the start and end of |
| 183 | // the event (e.g. a mouse wheel tick). |
| 184 | END, |
| 185 | }; |
| 186 | |
[email protected] | 595079ce | 2014-07-11 22:25:13 | [diff] [blame] | 187 | // Device ID for Touch and Key Events. |
| 188 | enum EventDeviceId { |
| 189 | ED_UNKNOWN_DEVICE = -1 |
| 190 | }; |
| 191 | |
robert.bradford | f62ea41 | 2015-08-19 16:37:49 | [diff] [blame] | 192 | // Pointing device type. |
| 193 | enum class EventPointerType : int { |
| 194 | POINTER_TYPE_UNKNOWN = 0, |
| 195 | POINTER_TYPE_MOUSE, |
| 196 | POINTER_TYPE_PEN, |
| 197 | POINTER_TYPE_TOUCH, |
denniskempin | 38c0fef | 2016-08-25 21:01:50 | [diff] [blame] | 198 | POINTER_TYPE_ERASER, |
robert.bradford | f62ea41 | 2015-08-19 16:37:49 | [diff] [blame] | 199 | }; |
| 200 | |
mohsen | 7d45a48 | 2016-05-24 21:03:44 | [diff] [blame] | 201 | // Device type for gesture events. |
| 202 | enum class GestureDeviceType : int { |
| 203 | DEVICE_UNKNOWN = 0, |
| 204 | DEVICE_TOUCHPAD, |
| 205 | DEVICE_TOUCHSCREEN, |
| 206 | }; |
| 207 | |
[email protected] | 8d577a70 | 2011-02-10 04:56:36 | [diff] [blame] | 208 | } // namespace ui |
| 209 | |
[email protected] | 86ccbd4 | 2013-09-18 18:11:54 | [diff] [blame] | 210 | #endif // UI_EVENTS_EVENT_CONSTANTS_H_ |