blob: 9340ec0b28f49462c27901b3529e1299ec4435c9 [file] [log] [blame]
[email protected]6084b452012-01-17 15:03:001// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]8d577a702011-02-10 04:56:362// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]86ccbd42013-09-18 18:11:545#ifndef UI_EVENTS_EVENT_CONSTANTS_H_
6#define UI_EVENTS_EVENT_CONSTANTS_H_
[email protected]8d577a702011-02-10 04:56:367
8namespace ui {
9
10// Event types. (prefixed because of a conflict with windows headers)
11enum 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]759017e02012-02-11 20:46:1122 ET_MOUSE_CAPTURE_CHANGED, // Event has no location.
[email protected]8d577a702011-02-10 04:56:3623 ET_TOUCH_RELEASED,
24 ET_TOUCH_PRESSED,
skya1b50362016-08-16 00:24:0925 // 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]8d577a702011-02-10 04:56:3628 ET_TOUCH_MOVED,
[email protected]8d577a702011-02-10 04:56:3629 ET_TOUCH_CANCELLED,
[email protected]e0f17f92011-09-08 17:29:5830 ET_DROP_TARGET_EVENT,
[email protected]6084b452012-01-17 15:03:0031
moshayedi6a948a72016-02-11 21:14:1732 // 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,
riajiang70fa9572016-08-26 21:30:4939 ET_POINTER_WHEEL_CHANGED,
40 ET_POINTER_CAPTURE_CHANGED,
moshayedi6a948a72016-02-11 21:14:1741
[email protected]6084b452012-01-17 15:03:0042 // GestureEvent types
43 ET_GESTURE_SCROLL_BEGIN,
[email protected]8fd82b8c2014-03-05 18:50:0044 ET_GESTURE_TYPE_START = ET_GESTURE_SCROLL_BEGIN,
[email protected]6084b452012-01-17 15:03:0045 ET_GESTURE_SCROLL_END,
46 ET_GESTURE_SCROLL_UPDATE,
47 ET_GESTURE_TAP,
[email protected]f884a002012-06-07 15:33:0548 ET_GESTURE_TAP_DOWN,
[email protected]7696c4082012-09-11 16:37:5949 ET_GESTURE_TAP_CANCEL,
moshayedi6a948a72016-02-11 21:14:1750 ET_GESTURE_TAP_UNCONFIRMED, // User tapped, but the tap delay hasn't expired.
[email protected]3cb7be42014-03-04 21:43:3551 ET_GESTURE_DOUBLE_TAP,
[email protected]d476bfa2014-06-02 18:02:5152 ET_GESTURE_BEGIN, // The first event sent when each finger is pressed.
53 ET_GESTURE_END, // Sent for each released finger.
[email protected]d1f9a25a2012-06-05 21:48:0154 ET_GESTURE_TWO_FINGER_TAP,
[email protected]69989562012-02-08 15:57:3355 ET_GESTURE_PINCH_BEGIN,
56 ET_GESTURE_PINCH_END,
57 ET_GESTURE_PINCH_UPDATE,
[email protected]4448d2c2012-02-21 19:08:2758 ET_GESTURE_LONG_PRESS,
[email protected]dd5b9cf92012-11-02 02:49:3559 ET_GESTURE_LONG_TAP,
[email protected]e9ea1402014-05-28 01:13:3560 // 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]5fd860ab2013-10-22 21:17:1664 ET_GESTURE_SHOW_PRESS,
[email protected]91e20032012-03-20 02:47:2465
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]8fd82b8c2014-03-05 18:50:0071 ET_GESTURE_TYPE_END = ET_SCROLL_FLING_CANCEL,
[email protected]8349a202012-11-20 22:05:1572
[email protected]af5e25272013-02-21 01:17:3673 // 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]2a21916a2013-06-20 02:38:5677 // 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]8349a202012-11-20 22:05:1581 // Must always be last. User namespace starts above this value.
82 // See ui::RegisterCustomEventType().
83 ET_LAST
[email protected]8d577a702011-02-10 04:56:3684};
85
pkastingcc7f6ac2016-01-08 23:38:4786// 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]8d577a702011-02-10 04:56:3689enum EventFlags {
pkotwicza4e71e692015-03-06 20:59:0390 EF_NONE = 0, // Used to denote no flags explicitly
pkastingcc7f6ac2016-01-08 23:38:4791
92 // Universally applicable status bits.
93 EF_IS_SYNTHESIZED = 1 << 0,
94
95 // Modifier key state.
pkotwicza4e71e692015-03-06 20:59:0396 EF_SHIFT_DOWN = 1 << 1,
97 EF_CONTROL_DOWN = 1 << 2,
98 EF_ALT_DOWN = 1 << 3,
pkastingcc7f6ac2016-01-08 23:38:4799 EF_COMMAND_DOWN = 1 << 4, // GUI Key (e.g. Command on OS X
pkotwicza4e71e692015-03-06 20:59:03100 // keyboards, Search on Chromebook
101 // keyboards, Windows on MS-oriented
102 // keyboards)
pkastingcc7f6ac2016-01-08 23:38:47103 EF_ALTGR_DOWN = 1 << 5,
104 EF_MOD3_DOWN = 1 << 6,
105
Joe Downinga8e74ac2018-02-26 17:10:24106 // Other keyboard states.
pkastingcc7f6ac2016-01-08 23:38:47107 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]8d577a702011-02-10 04:56:36117};
118
Joe Downinga8e74ac2018-02-26 17:10:24119// Flags specific to key events.
[email protected]5698964d2014-04-16 18:32:49120enum KeyEventFlags {
pkastingcc7f6ac2016-01-08 23:38:47121 EF_IME_FABRICATED_KEY = 1 << 15, // Key event fabricated by the underlying
[email protected]73749e6a2014-04-28 20:49:26122 // IME without a user action.
123 // (Linux X11 only)
pkastingcc7f6ac2016-01-08 23:38:47124 EF_IS_REPEAT = 1 << 16,
125 EF_FINAL = 1 << 17, // Do not remap; the event was created with
[email protected]1c649772014-07-18 14:06:12126 // the desired final values.
pkastingcc7f6ac2016-01-08 23:38:47127 EF_IS_EXTENDED_KEY = 1 << 18, // Windows extended key (see WM_KEYDOWN doc)
[email protected]5698964d2014-04-16 18:32:49128};
129
Joe Downinga8e74ac2018-02-26 17:10:24130// Flags specific to mouse events.
[email protected]8d577a702011-02-10 04:56:36131enum MouseEventFlags {
denniskempin6bc514382016-08-24 01:15:30132 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]345385332014-05-29 19:01:44136 // from an unconsumed touch/gesture event.
pkastingcc7f6ac2016-01-08 23:38:47137 EF_TOUCH_ACCESSIBILITY = 1 << 19, // Indicates this event was generated from
[email protected]345385332014-05-29 19:01:44138 // touch accessibility mode.
Eugene Girarde8bcc082017-08-25 05:20:07139 EF_CURSOR_HIDE = 1 << 20, // Indicates this mouse event is generated
chaopeng8f894592017-06-29 23:20:45140 // because the cursor was just hidden. This
141 // can be used to update hover state.
[email protected]8d577a702011-02-10 04:56:36142};
143
[email protected]5b174e0a2012-09-04 01:14:43144// Result of dispatching an event.
145enum EventResult {
tdresser8879cfc2014-12-09 21:00:17146 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]5b174e0a2012-09-04 01:14:43157};
158
[email protected]1eeb971322012-09-11 05:56:51159// Phase of the event dispatch.
160enum EventPhase {
161 EP_PREDISPATCH,
162 EP_PRETARGET,
163 EP_TARGET,
164 EP_POSTTARGET,
165 EP_POSTDISPATCH
166};
167
taptedb94b06c2016-09-27 02:16:15168// Momentum phase information used for a ScrollEvent.
169enum 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]595079ce2014-07-11 22:25:13187// Device ID for Touch and Key Events.
188enum EventDeviceId {
189 ED_UNKNOWN_DEVICE = -1
190};
191
robert.bradfordf62ea412015-08-19 16:37:49192// Pointing device type.
193enum class EventPointerType : int {
194 POINTER_TYPE_UNKNOWN = 0,
195 POINTER_TYPE_MOUSE,
196 POINTER_TYPE_PEN,
197 POINTER_TYPE_TOUCH,
denniskempin38c0fef2016-08-25 21:01:50198 POINTER_TYPE_ERASER,
robert.bradfordf62ea412015-08-19 16:37:49199};
200
mohsen7d45a482016-05-24 21:03:44201// Device type for gesture events.
202enum class GestureDeviceType : int {
203 DEVICE_UNKNOWN = 0,
204 DEVICE_TOUCHPAD,
205 DEVICE_TOUCHSCREEN,
206};
207
[email protected]8d577a702011-02-10 04:56:36208} // namespace ui
209
[email protected]86ccbd42013-09-18 18:11:54210#endif // UI_EVENTS_EVENT_CONSTANTS_H_