summaryrefslogtreecommitdiff
path: root/chromium/ui/events/event_constants.h
blob: 79ca132182b5ef8f5966a24e7cadfd3b2da9f4d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_EVENTS_EVENT_CONSTANTS_H_
#define UI_EVENTS_EVENT_CONSTANTS_H_

namespace ui {

// Event types. (prefixed because of a conflict with windows headers)
enum EventType {
  ET_UNKNOWN = 0,
  ET_MOUSE_PRESSED,
  ET_MOUSE_DRAGGED,
  ET_MOUSE_RELEASED,
  ET_MOUSE_MOVED,
  ET_MOUSE_ENTERED,
  ET_MOUSE_EXITED,
  ET_KEY_PRESSED,
  ET_KEY_RELEASED,
  ET_MOUSEWHEEL,
  ET_MOUSE_CAPTURE_CHANGED,  // Event has no location.
  ET_TOUCH_RELEASED,
  ET_TOUCH_PRESSED,
  // NOTE: This corresponds to a drag and is always preceeded by an
  // ET_TOUCH_PRESSED. GestureRecognizers generally ignore ET_TOUCH_MOVED events
  // without a corresponding ET_TOUCH_PRESSED.
  ET_TOUCH_MOVED,
  ET_TOUCH_CANCELLED,
  ET_DROP_TARGET_EVENT,

  // PointerEvent types
  ET_POINTER_DOWN,
  ET_POINTER_MOVED,
  ET_POINTER_UP,
  ET_POINTER_CANCELLED,
  ET_POINTER_ENTERED,
  ET_POINTER_EXITED,
  ET_POINTER_WHEEL_CHANGED,
  ET_POINTER_CAPTURE_CHANGED,

  // GestureEvent types
  ET_GESTURE_SCROLL_BEGIN,
  ET_GESTURE_TYPE_START = ET_GESTURE_SCROLL_BEGIN,
  ET_GESTURE_SCROLL_END,
  ET_GESTURE_SCROLL_UPDATE,
  ET_GESTURE_TAP,
  ET_GESTURE_TAP_DOWN,
  ET_GESTURE_TAP_CANCEL,
  ET_GESTURE_TAP_UNCONFIRMED,  // User tapped, but the tap delay hasn't expired.
  ET_GESTURE_DOUBLE_TAP,
  ET_GESTURE_BEGIN,  // The first event sent when each finger is pressed.
  ET_GESTURE_END,    // Sent for each released finger.
  ET_GESTURE_TWO_FINGER_TAP,
  ET_GESTURE_PINCH_BEGIN,
  ET_GESTURE_PINCH_END,
  ET_GESTURE_PINCH_UPDATE,
  ET_GESTURE_LONG_PRESS,
  ET_GESTURE_LONG_TAP,
  // A SWIPE gesture can happen at the end of a touch sequence involving one or
  // more fingers if the finger velocity was high enough when the first finger
  // was released.
  ET_GESTURE_SWIPE,
  ET_GESTURE_SHOW_PRESS,

  // Scroll support.
  // TODO[davemoore] we need to unify these events w/ touch and gestures.
  ET_SCROLL,
  ET_SCROLL_FLING_START,
  ET_SCROLL_FLING_CANCEL,
  ET_GESTURE_TYPE_END = ET_SCROLL_FLING_CANCEL,

  // Sent by the system to indicate any modal type operations, such as drag and
  // drop or menus, should stop.
  ET_CANCEL_MODE,

  // Sent by the CrOS gesture library for interesting patterns that we want
  // to track with the UMA system.
  ET_UMA_DATA,

  // Must always be last. User namespace starts above this value.
  // See ui::RegisterCustomEventType().
  ET_LAST
};

// Event flags currently supported.  It is OK to add values to the middle of
// this list and/or reorder it, but make sure you also touch the various other
// enums/constants that want to stay in sync with this.
enum EventFlags {
  EF_NONE                 = 0,       // Used to denote no flags explicitly

  // Universally applicable status bits.
  EF_IS_SYNTHESIZED       = 1 << 0,

  // Modifier key state.
  EF_SHIFT_DOWN           = 1 << 1,
  EF_CONTROL_DOWN         = 1 << 2,
  EF_ALT_DOWN             = 1 << 3,
  EF_COMMAND_DOWN         = 1 << 4,  // GUI Key (e.g. Command on OS X
                                     // keyboards, Search on Chromebook
                                     // keyboards, Windows on MS-oriented
                                     // keyboards)
  EF_ALTGR_DOWN           = 1 << 5,
  EF_MOD3_DOWN            = 1 << 6,

  // Other keyboard state.
  EF_NUM_LOCK_ON          = 1 << 7,
  EF_CAPS_LOCK_ON         = 1 << 8,
  EF_SCROLL_LOCK_ON       = 1 << 9,

  // Mouse buttons.
  EF_LEFT_MOUSE_BUTTON    = 1 << 10,
  EF_MIDDLE_MOUSE_BUTTON  = 1 << 11,
  EF_RIGHT_MOUSE_BUTTON   = 1 << 12,
  EF_BACK_MOUSE_BUTTON    = 1 << 13,
  EF_FORWARD_MOUSE_BUTTON = 1 << 14,
};

// Flags specific to key events
enum KeyEventFlags {
  EF_IME_FABRICATED_KEY = 1 << 15,  // Key event fabricated by the underlying
                                    // IME without a user action.
                                    // (Linux X11 only)
  EF_IS_REPEAT          = 1 << 16,
  EF_FINAL              = 1 << 17,  // Do not remap; the event was created with
                                    // the desired final values.
  EF_IS_EXTENDED_KEY    = 1 << 18,  // Windows extended key (see WM_KEYDOWN doc)
};

// Flags specific to mouse events
enum MouseEventFlags {
  EF_IS_DOUBLE_CLICK = 1 << 15,
  EF_IS_TRIPLE_CLICK = 1 << 16,
  EF_IS_NON_CLIENT = 1 << 17,
  EF_FROM_TOUCH = 1 << 18,           // Indicates this mouse event is generated
                                     // from an unconsumed touch/gesture event.
  EF_TOUCH_ACCESSIBILITY = 1 << 19,  // Indicates this event was generated from
                                     // touch accessibility mode.
  EF_CURSOR_HIDE = 1 << 20,          // Indicates this mouse event is generated
                                     // because the cursor was just hidden. This
                                     // can be used to update hover state.
};

// Result of dispatching an event.
enum EventResult {
  ER_UNHANDLED = 0,      // The event hasn't been handled. The event can be
                         // propagated to other handlers.
  ER_HANDLED = 1 << 0,   // The event has already been handled, but it can
                         // still be propagated to other handlers.
  ER_CONSUMED = 1 << 1,  // The event has been handled, and it should not be
                         // propagated to other handlers.
  ER_DISABLE_SYNC_HANDLING =
      1 << 2,  // The event shouldn't be handled synchronously. This
               // happens if the event is being handled
               // asynchronously, or if the event is invalid and
               // shouldn't be handled at all.
};

// Phase of the event dispatch.
enum EventPhase {
  EP_PREDISPATCH,
  EP_PRETARGET,
  EP_TARGET,
  EP_POSTTARGET,
  EP_POSTDISPATCH
};

// Momentum phase information used for a ScrollEvent.
enum class EventMomentumPhase {
  // Event is a non-momentum update to an event stream already begun.
  NONE,

  // Event is the beginning of an event stream that may result in momentum.
  MAY_BEGIN,

  // Event is an update while in a momentum phase. A "begin" event for the
  // momentum phase portion of an event stream uses this also, but the scroll
  // offsets will be zero.
  INERTIAL_UPDATE,

  // Event marks the end of the current event stream. Note that this is also set
  // for events that are not a "stream", but indicate both the start and end of
  // the event (e.g. a mouse wheel tick).
  END,
};

// Device ID for Touch and Key Events.
enum EventDeviceId {
  ED_UNKNOWN_DEVICE = -1
};

// Pointing device type.
enum class EventPointerType : int {
  POINTER_TYPE_UNKNOWN = 0,
  POINTER_TYPE_MOUSE,
  POINTER_TYPE_PEN,
  POINTER_TYPE_TOUCH,
  POINTER_TYPE_ERASER,
};

// Device type for gesture events.
enum class GestureDeviceType : int {
  DEVICE_UNKNOWN = 0,
  DEVICE_TOUCHPAD,
  DEVICE_TOUCHSCREEN,
};

}  // namespace ui

#endif  // UI_EVENTS_EVENT_CONSTANTS_H_