blob: 7d33a0ec20a7dad2b57bfe1ffecf8648e582061c [file] [log] [blame]
Avi Drissman3e1a26c2022-09-15 20:26:031// Copyright 2012 The Chromium Authors
[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
Wei Li1ce0b942018-05-23 20:08:438#include "build/build_config.h"
9
[email protected]8d577a702011-02-10 04:56:3610namespace ui {
11
Jayson Adams75533272021-10-20 20:50:2212// Event flags currently supported. It is OK to add values to the middle of
pkastingcc7f6ac2016-01-08 23:38:4713// this list and/or reorder it, but make sure you also touch the various other
Jayson Adams75533272021-10-20 20:50:2214// enums/constants that want to stay in sync with this. For example,
15// KeyEventFlags and MouseEventFlags should not overlap EventFlags.
Peter Kasting5380f8a72022-05-10 15:41:3616using EventFlags = int;
17// Used to denote no flags explicitly
18constexpr EventFlags EF_NONE = 0;
pkastingcc7f6ac2016-01-08 23:38:4719
Peter Kasting5380f8a72022-05-10 15:41:3620// Universally applicable status bits.
21constexpr EventFlags EF_IS_SYNTHESIZED = 1 << 0;
pkastingcc7f6ac2016-01-08 23:38:4722
Peter Kasting5380f8a72022-05-10 15:41:3623// Modifier key state.
24constexpr EventFlags EF_SHIFT_DOWN = 1 << 1;
25constexpr EventFlags EF_CONTROL_DOWN = 1 << 2;
26constexpr EventFlags EF_ALT_DOWN = 1 << 3;
27// GUI Key (e.g. Command on OS X keyboards, Search on Chromebook keyboards,
28// Windows on MS-oriented keyboards)
29constexpr EventFlags EF_COMMAND_DOWN = 1 << 4;
30// Function key.
31constexpr EventFlags EF_FUNCTION_DOWN = 1 << 5;
32constexpr EventFlags EF_ALTGR_DOWN = 1 << 6;
33constexpr EventFlags EF_MOD3_DOWN = 1 << 7;
pkastingcc7f6ac2016-01-08 23:38:4734
Peter Kasting5380f8a72022-05-10 15:41:3635// Other keyboard states.
36constexpr EventFlags EF_NUM_LOCK_ON = 1 << 8;
37constexpr EventFlags EF_CAPS_LOCK_ON = 1 << 9;
38constexpr EventFlags EF_SCROLL_LOCK_ON = 1 << 10;
pkastingcc7f6ac2016-01-08 23:38:4739
Peter Kasting5380f8a72022-05-10 15:41:3640// Mouse buttons.
41constexpr EventFlags EF_LEFT_MOUSE_BUTTON = 1 << 11;
42constexpr EventFlags EF_MIDDLE_MOUSE_BUTTON = 1 << 12;
43constexpr EventFlags EF_RIGHT_MOUSE_BUTTON = 1 << 13;
44constexpr EventFlags EF_BACK_MOUSE_BUTTON = 1 << 14;
45constexpr EventFlags EF_FORWARD_MOUSE_BUTTON = 1 << 15;
46constexpr EventFlags EF_MOUSE_BUTTON =
47 EF_LEFT_MOUSE_BUTTON | EF_MIDDLE_MOUSE_BUTTON | EF_RIGHT_MOUSE_BUTTON |
48 EF_BACK_MOUSE_BUTTON | EF_FORWARD_MOUSE_BUTTON;
Wei Li1ce0b942018-05-23 20:08:4349
50// An artificial value used to bridge platform differences.
51// Many commands on Mac as Cmd+Key are the counterparts of
52// Ctrl+Key on other platforms.
Xiaohan Wangebf889e62022-01-20 07:21:3653#if BUILDFLAG(IS_APPLE)
Peter Kasting5380f8a72022-05-10 15:41:3654constexpr EventFlags EF_PLATFORM_ACCELERATOR = EF_COMMAND_DOWN;
Wei Li1ce0b942018-05-23 20:08:4355#else
Peter Kasting5380f8a72022-05-10 15:41:3656constexpr EventFlags EF_PLATFORM_ACCELERATOR = EF_CONTROL_DOWN;
Wei Li1ce0b942018-05-23 20:08:4357#endif
[email protected]8d577a702011-02-10 04:56:3658
Joe Downinga8e74ac2018-02-26 17:10:2459// Flags specific to key events.
Scott Violet154ad7d2019-01-18 20:47:5260// WARNING: If you add or remove values make sure traits for serializing these
61// values are updated.
Peter Kasting5380f8a72022-05-10 15:41:3662using KeyEventFlags = EventFlags;
63// Key event fabricated by the underlying IME without a user action. (Linux X11
64// only)
65constexpr KeyEventFlags EF_IME_FABRICATED_KEY = 1 << 16;
66constexpr KeyEventFlags EF_IS_REPEAT = 1 << 17;
67// Do not remap; the event was created with the desired final values.
68constexpr KeyEventFlags EF_FINAL = 1 << 18;
69// Windows extended key (see WM_KEYDOWN doc)
70constexpr KeyEventFlags EF_IS_EXTENDED_KEY = 1 << 19;
71// Event was generated by a stylus button
72constexpr KeyEventFlags EF_IS_STYLUS_BUTTON = 1 << 20;
73constexpr KeyEventFlags EF_MAX_KEY_EVENT_FLAGS_VALUE = (1 << 21) - 1;
[email protected]5698964d2014-04-16 18:32:4974
Joe Downinga8e74ac2018-02-26 17:10:2475// Flags specific to mouse events.
Peter Kasting5380f8a72022-05-10 15:41:3676using MouseEventFlags = EventFlags;
77constexpr MouseEventFlags EF_IS_DOUBLE_CLICK = 1 << 16;
78constexpr MouseEventFlags EF_IS_TRIPLE_CLICK = 1 << 17;
79constexpr MouseEventFlags EF_IS_NON_CLIENT = 1 << 18;
80// Indicates this mouse event is generated from an unconsumed touch/gesture
81// event.
82constexpr MouseEventFlags EF_FROM_TOUCH = 1 << 19;
83// Indicates this event was generated from touch accessibility mode.
84constexpr MouseEventFlags EF_TOUCH_ACCESSIBILITY = 1 << 20;
85// Indicates this mouse event is generated because the cursor was just hidden.
86// This can be used to update hover state.
87constexpr MouseEventFlags EF_CURSOR_HIDE = 1 << 21;
88// Indicates this mouse event is from high precision touchpad and will come with
89// a high precision delta.
90constexpr MouseEventFlags EF_PRECISION_SCROLLING_DELTA = 1 << 22;
91// Indicates this mouse event is generated when users is requesting to scroll by
92// pages.
93constexpr MouseEventFlags EF_SCROLL_BY_PAGE = 1 << 23;
94// Indicates this mouse event is unadjusted mouse events that has unadjusted
95// movement delta, i.e. is from WM_INPUT on Windows.
96constexpr MouseEventFlags EF_UNADJUSTED_MOUSE = 1 << 24;
97// Indicates this mouse event should not trigger mouse warping (which moves the
98// mouse to another display when the mouse hits the window boundaries).
99constexpr MouseEventFlags EF_NOT_SUITABLE_FOR_MOUSE_WARPING = 1 << 25;
[email protected]8d577a702011-02-10 04:56:36100
[email protected]5b174e0a2012-09-04 01:14:43101// Result of dispatching an event.
102enum EventResult {
tdresser8879cfc2014-12-09 21:00:17103 ER_UNHANDLED = 0, // The event hasn't been handled. The event can be
104 // propagated to other handlers.
105 ER_HANDLED = 1 << 0, // The event has already been handled, but it can
106 // still be propagated to other handlers.
107 ER_CONSUMED = 1 << 1, // The event has been handled, and it should not be
108 // propagated to other handlers.
109 ER_DISABLE_SYNC_HANDLING =
110 1 << 2, // The event shouldn't be handled synchronously. This
111 // happens if the event is being handled
112 // asynchronously, or if the event is invalid and
113 // shouldn't be handled at all.
Mitsuru Oshimaab67acc82023-04-13 15:30:06114 ER_FORCE_PROCESS_GESTURE =
115 1 << 3, // The event should be processed by gesture recognizer even if
116 // ER_HANDLED or ER_CONSUMED is set.
[email protected]5b174e0a2012-09-04 01:14:43117};
118
[email protected]1eeb971322012-09-11 05:56:51119// Phase of the event dispatch.
120enum EventPhase {
121 EP_PREDISPATCH,
122 EP_PRETARGET,
123 EP_TARGET,
124 EP_POSTTARGET,
125 EP_POSTDISPATCH
126};
127
chaopenge8f2c032018-04-05 03:11:59128// Phase information used for a ScrollEvent. ScrollEventPhase is for scroll
129// stream from user gesture, EventMomentumPhase is for inertia scroll stream
130// after user gesture.
131enum class ScrollEventPhase {
132 // Event has no phase information. eg. the Event is not in a scroll stream.
133 kNone,
134
135 // Event is the beginning of a scroll event stream.
136 kBegan,
137
138 // Event is a scroll event with phase information.
139 kUpdate,
140
141 // Event is the end of the current scroll event stream.
142 kEnd,
143};
144
taptedb94b06c2016-09-27 02:16:15145// Momentum phase information used for a ScrollEvent.
146enum class EventMomentumPhase {
147 // Event is a non-momentum update to an event stream already begun.
148 NONE,
149
150 // Event is the beginning of an event stream that may result in momentum.
chaopenge8f2c032018-04-05 03:11:59151 // BEGAN vs MAY_BEGIN:
152 // - BEGAN means we already know the inertia scroll stream must happen after
153 // BEGAN event. On Windows touchpad, we sent this when receive the first
154 // inertia scroll event or Direct Manipulation state change to INERTIA.
155 // - MAY_BEGIN means the inertia scroll stream may happen after MAY_BEGIN
156 // event. On Mac, we send this when receive releaseTouches, but we do not
157 // know the inertia scroll stream will happen or not at that time.
158 BEGAN,
159
160 // Event maybe the beginning of an event stream that may result in momentum.
161 // This state used on Mac.
taptedb94b06c2016-09-27 02:16:15162 MAY_BEGIN,
163
164 // Event is an update while in a momentum phase. A "begin" event for the
165 // momentum phase portion of an event stream uses this also, but the scroll
166 // offsets will be zero.
167 INERTIAL_UPDATE,
168
169 // Event marks the end of the current event stream. Note that this is also set
170 // for events that are not a "stream", but indicate both the start and end of
171 // the event (e.g. a mouse wheel tick).
172 END,
Mario Bianucci4da9f93b2019-08-26 19:54:38173
174 // EventMomentumPhase can only be BLOCKED when ScrollEventPhase is kEnd. Event
175 // marks the end of the current event stream, when there will be no inertia
176 // scrolling after the user gesture. ScrollEventPhase must simultaneously be
177 // kEnd because that is when it is determined if an event stream that results
178 // in momentum will begin or not. This phase is only used on Windows.
179 BLOCKED,
taptedb94b06c2016-09-27 02:16:15180};
181
Jeroen Dhollander89e6a4d2022-03-31 02:34:08182enum EventDeviceId {
183 // Device ID for Touch, Mouse and Key Events.
184 ED_UNKNOWN_DEVICE = -1,
185 // Device ID for events injected through a remote connection (like CRD).
186 ED_REMOTE_INPUT_DEVICE = -2,
187};
[email protected]595079ce2014-07-11 22:25:13188
robert.bradfordf62ea412015-08-19 16:37:49189// Pointing device type.
190enum class EventPointerType : int {
Dave Tapuska1621efb2020-04-29 15:39:54191 kUnknown,
192 kMouse,
193 kPen,
194 kTouch,
195 kEraser,
196 kMaxValue = kEraser,
robert.bradfordf62ea412015-08-19 16:37:49197};
198
mohsen7d45a482016-05-24 21:03:44199// Device type for gesture events.
200enum class GestureDeviceType : int {
201 DEVICE_UNKNOWN = 0,
202 DEVICE_TOUCHPAD,
203 DEVICE_TOUCHSCREEN,
204};
205
[email protected]8d577a702011-02-10 04:56:36206} // namespace ui
207
[email protected]86ccbd42013-09-18 18:11:54208#endif // UI_EVENTS_EVENT_CONSTANTS_H_