1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef UI_EVENTS_EVENT_CONSTANTS_H_ 6 #define UI_EVENTS_EVENT_CONSTANTS_H_ 7 8 #include "build/build_config.h" 9 10 namespace ui { 11 12 // Event flags currently supported. It is OK to add values to the middle of 13 // this list and/or reorder it, but make sure you also touch the various other 14 // enums/constants that want to stay in sync with this. For example, 15 // KeyEventFlags and MouseEventFlags should not overlap EventFlags. 16 enum EventFlags { 17 EF_NONE = 0, // Used to denote no flags explicitly 18 19 // Universally applicable status bits. 20 EF_IS_SYNTHESIZED = 1 << 0, 21 22 // Modifier key state. 23 EF_SHIFT_DOWN = 1 << 1, 24 EF_CONTROL_DOWN = 1 << 2, 25 EF_ALT_DOWN = 1 << 3, 26 EF_COMMAND_DOWN = 1 << 4, // GUI Key (e.g. Command on OS X 27 // keyboards, Search on Chromebook 28 // keyboards, Windows on MS-oriented 29 // keyboards) 30 EF_FUNCTION_DOWN = 1 << 5, // Function key. 31 EF_ALTGR_DOWN = 1 << 6, 32 EF_MOD3_DOWN = 1 << 7, 33 34 // Other keyboard states. 35 EF_NUM_LOCK_ON = 1 << 8, 36 EF_CAPS_LOCK_ON = 1 << 9, 37 EF_SCROLL_LOCK_ON = 1 << 10, 38 39 // Mouse buttons. 40 EF_LEFT_MOUSE_BUTTON = 1 << 11, 41 EF_MIDDLE_MOUSE_BUTTON = 1 << 12, 42 EF_RIGHT_MOUSE_BUTTON = 1 << 13, 43 EF_BACK_MOUSE_BUTTON = 1 << 14, 44 EF_FORWARD_MOUSE_BUTTON = 1 << 15, 45 EF_MOUSE_BUTTON = EF_LEFT_MOUSE_BUTTON | EF_MIDDLE_MOUSE_BUTTON | 46 EF_RIGHT_MOUSE_BUTTON | EF_BACK_MOUSE_BUTTON | 47 EF_FORWARD_MOUSE_BUTTON, 48 49 // An artificial value used to bridge platform differences. 50 // Many commands on Mac as Cmd+Key are the counterparts of 51 // Ctrl+Key on other platforms. 52 #if defined(OS_APPLE) 53 EF_PLATFORM_ACCELERATOR = EF_COMMAND_DOWN, 54 #else 55 EF_PLATFORM_ACCELERATOR = EF_CONTROL_DOWN, 56 #endif 57 }; 58 59 // Flags specific to key events. 60 // WARNING: If you add or remove values make sure traits for serializing these 61 // values are updated. 62 enum KeyEventFlags { 63 EF_IME_FABRICATED_KEY = 1 << 16, // Key event fabricated by the underlying 64 // IME without a user action. 65 // (Linux X11 only) 66 EF_IS_REPEAT = 1 << 17, 67 EF_FINAL = 1 << 18, // Do not remap; the event was created with 68 // the desired final values. 69 EF_IS_EXTENDED_KEY = 1 << 19, // Windows extended key (see WM_KEYDOWN doc) 70 EF_IS_STYLUS_BUTTON = 1 << 20, // Event was generated by a stylus button 71 EF_MAX_KEY_EVENT_FLAGS_VALUE = (1 << 21) - 1, 72 }; 73 74 // Flags specific to mouse events. 75 enum MouseEventFlags { 76 EF_IS_DOUBLE_CLICK = 1 << 16, 77 EF_IS_TRIPLE_CLICK = 1 << 17, 78 EF_IS_NON_CLIENT = 1 << 18, 79 EF_FROM_TOUCH = 1 << 19, // Indicates this mouse event is generated 80 // from an unconsumed touch/gesture event. 81 EF_TOUCH_ACCESSIBILITY = 1 << 20, // Indicates this event was generated from 82 // touch accessibility mode. 83 EF_CURSOR_HIDE = 1 << 21, // Indicates this mouse event is generated 84 // because the cursor was just hidden. This 85 // can be used to update hover state. 86 EF_PRECISION_SCROLLING_DELTA = // Indicates this mouse event is from high 87 1 << 22, // precision touchpad and will come with a 88 // high precision delta. 89 EF_SCROLL_BY_PAGE = 1 << 23, // Indicates this mouse event is generated 90 // when users is requesting to scroll by 91 // pages. 92 EF_UNADJUSTED_MOUSE = 1 << 24, // Indicates this mouse event is unadjusted 93 // mouse events that has unadjusted movement 94 // delta, i.e. is from WM_INPUT on Windows. 95 }; 96 97 // Result of dispatching an event. 98 enum EventResult { 99 ER_UNHANDLED = 0, // The event hasn't been handled. The event can be 100 // propagated to other handlers. 101 ER_HANDLED = 1 << 0, // The event has already been handled, but it can 102 // still be propagated to other handlers. 103 ER_CONSUMED = 1 << 1, // The event has been handled, and it should not be 104 // propagated to other handlers. 105 ER_DISABLE_SYNC_HANDLING = 106 1 << 2, // The event shouldn't be handled synchronously. This 107 // happens if the event is being handled 108 // asynchronously, or if the event is invalid and 109 // shouldn't be handled at all. 110 }; 111 112 // Phase of the event dispatch. 113 enum EventPhase { 114 EP_PREDISPATCH, 115 EP_PRETARGET, 116 EP_TARGET, 117 EP_POSTTARGET, 118 EP_POSTDISPATCH 119 }; 120 121 // Phase information used for a ScrollEvent. ScrollEventPhase is for scroll 122 // stream from user gesture, EventMomentumPhase is for inertia scroll stream 123 // after user gesture. 124 enum class ScrollEventPhase { 125 // Event has no phase information. eg. the Event is not in a scroll stream. 126 kNone, 127 128 // Event is the beginning of a scroll event stream. 129 kBegan, 130 131 // Event is a scroll event with phase information. 132 kUpdate, 133 134 // Event is the end of the current scroll event stream. 135 kEnd, 136 }; 137 138 // Momentum phase information used for a ScrollEvent. 139 enum class EventMomentumPhase { 140 // Event is a non-momentum update to an event stream already begun. 141 NONE, 142 143 // Event is the beginning of an event stream that may result in momentum. 144 // BEGAN vs MAY_BEGIN: 145 // - BEGAN means we already know the inertia scroll stream must happen after 146 // BEGAN event. On Windows touchpad, we sent this when receive the first 147 // inertia scroll event or Direct Manipulation state change to INERTIA. 148 // - MAY_BEGIN means the inertia scroll stream may happen after MAY_BEGIN 149 // event. On Mac, we send this when receive releaseTouches, but we do not 150 // know the inertia scroll stream will happen or not at that time. 151 BEGAN, 152 153 // Event maybe the beginning of an event stream that may result in momentum. 154 // This state used on Mac. 155 MAY_BEGIN, 156 157 // Event is an update while in a momentum phase. A "begin" event for the 158 // momentum phase portion of an event stream uses this also, but the scroll 159 // offsets will be zero. 160 INERTIAL_UPDATE, 161 162 // Event marks the end of the current event stream. Note that this is also set 163 // for events that are not a "stream", but indicate both the start and end of 164 // the event (e.g. a mouse wheel tick). 165 END, 166 167 // EventMomentumPhase can only be BLOCKED when ScrollEventPhase is kEnd. Event 168 // marks the end of the current event stream, when there will be no inertia 169 // scrolling after the user gesture. ScrollEventPhase must simultaneously be 170 // kEnd because that is when it is determined if an event stream that results 171 // in momentum will begin or not. This phase is only used on Windows. 172 BLOCKED, 173 }; 174 175 // Device ID for Touch and Key Events. 176 enum EventDeviceId { 177 ED_UNKNOWN_DEVICE = -1 178 }; 179 180 // Pointing device type. 181 enum class EventPointerType : int { 182 kUnknown, 183 kMouse, 184 kPen, 185 kTouch, 186 kEraser, 187 kMaxValue = kEraser, 188 }; 189 190 // Device type for gesture events. 191 enum class GestureDeviceType : int { 192 DEVICE_UNKNOWN = 0, 193 DEVICE_TOUCHPAD, 194 DEVICE_TOUCHSCREEN, 195 }; 196 197 } // namespace ui 198 199 #endif // UI_EVENTS_EVENT_CONSTANTS_H_