1 | /*
|
---|
2 | * Copyright © 2009 Red Hat, Inc.
|
---|
3 | *
|
---|
4 | * Permission is hereby granted, free of charge, to any person obtaining a
|
---|
5 | * copy of this software and associated documentation files (the "Software"),
|
---|
6 | * to deal in the Software without restriction, including without limitation
|
---|
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
---|
8 | * and/or sell copies of the Software, and to permit persons to whom the
|
---|
9 | * Software is furnished to do so, subject to the following conditions:
|
---|
10 | *
|
---|
11 | * The above copyright notice and this permission notice (including the next
|
---|
12 | * paragraph) shall be included in all copies or substantial portions of the
|
---|
13 | * Software.
|
---|
14 | *
|
---|
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
---|
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
---|
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
---|
18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
---|
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
---|
20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
---|
21 | * DEALINGS IN THE SOFTWARE.
|
---|
22 | *
|
---|
23 | */
|
---|
24 |
|
---|
25 | #ifndef EVENTSTR_H
|
---|
26 | #define EVENTSTR_H
|
---|
27 |
|
---|
28 | #include <events.h>
|
---|
29 | /**
|
---|
30 | * @file events.h
|
---|
31 | * This file describes the event structures used internally by the X
|
---|
32 | * server during event generation and event processing.
|
---|
33 | *
|
---|
34 | * When are internal events used?
|
---|
35 | * Events from input devices are stored as internal events in the EQ and
|
---|
36 | * processed as internal events until late in the processing cycle. Only then
|
---|
37 | * do they switch to their respective wire events.
|
---|
38 | */
|
---|
39 |
|
---|
40 | /**
|
---|
41 | * Event types. Used exclusively internal to the server, not visible on the
|
---|
42 | * protocol.
|
---|
43 | *
|
---|
44 | * Note: Keep KeyPress to Motion aligned with the core events.
|
---|
45 | * Keep ET_Raw* in the same order as KeyPress - Motion
|
---|
46 | */
|
---|
47 | enum EventType {
|
---|
48 | ET_KeyPress = 2,
|
---|
49 | ET_KeyRelease,
|
---|
50 | ET_ButtonPress,
|
---|
51 | ET_ButtonRelease,
|
---|
52 | ET_Motion,
|
---|
53 | ET_TouchBegin,
|
---|
54 | ET_TouchUpdate,
|
---|
55 | ET_TouchEnd,
|
---|
56 | ET_TouchOwnership,
|
---|
57 | ET_Enter,
|
---|
58 | ET_Leave,
|
---|
59 | ET_FocusIn,
|
---|
60 | ET_FocusOut,
|
---|
61 | ET_ProximityIn,
|
---|
62 | ET_ProximityOut,
|
---|
63 | ET_DeviceChanged,
|
---|
64 | ET_Hierarchy,
|
---|
65 | ET_DGAEvent,
|
---|
66 | ET_RawKeyPress,
|
---|
67 | ET_RawKeyRelease,
|
---|
68 | ET_RawButtonPress,
|
---|
69 | ET_RawButtonRelease,
|
---|
70 | ET_RawMotion,
|
---|
71 | ET_RawTouchBegin,
|
---|
72 | ET_RawTouchUpdate,
|
---|
73 | ET_RawTouchEnd,
|
---|
74 | ET_XQuartz,
|
---|
75 | ET_Internal = 0xFF /* First byte */
|
---|
76 | };
|
---|
77 |
|
---|
78 | /**
|
---|
79 | * Used for ALL input device events internal in the server until
|
---|
80 | * copied into the matching protocol event.
|
---|
81 | *
|
---|
82 | * Note: We only use the device id because the DeviceIntPtr may become invalid while
|
---|
83 | * the event is in the EQ.
|
---|
84 | */
|
---|
85 | struct _DeviceEvent {
|
---|
86 | unsigned char header; /**< Always ET_Internal */
|
---|
87 | enum EventType type; /**< One of EventType */
|
---|
88 | int length; /**< Length in bytes */
|
---|
89 | Time time; /**< Time in ms */
|
---|
90 | int deviceid; /**< Device to post this event for */
|
---|
91 | int sourceid; /**< The physical source device */
|
---|
92 | union {
|
---|
93 | uint32_t button; /**< Button number (also used in pointer emulating
|
---|
94 | touch events) */
|
---|
95 | uint32_t key; /**< Key code */
|
---|
96 | } detail;
|
---|
97 | uint32_t touchid; /**< Touch ID (client_id) */
|
---|
98 | int16_t root_x; /**< Pos relative to root window in integral data */
|
---|
99 | float root_x_frac; /**< Pos relative to root window in frac part */
|
---|
100 | int16_t root_y; /**< Pos relative to root window in integral part */
|
---|
101 | float root_y_frac; /**< Pos relative to root window in frac part */
|
---|
102 | uint8_t buttons[(MAX_BUTTONS + 7) / 8]; /**< Button mask */
|
---|
103 | struct {
|
---|
104 | uint8_t mask[(MAX_VALUATORS + 7) / 8];/**< Valuator mask */
|
---|
105 | uint8_t mode[(MAX_VALUATORS + 7) / 8];/**< Valuator mode (Abs or Rel)*/
|
---|
106 | double data[MAX_VALUATORS]; /**< Valuator data */
|
---|
107 | } valuators;
|
---|
108 | struct {
|
---|
109 | uint32_t base; /**< XKB base modifiers */
|
---|
110 | uint32_t latched; /**< XKB latched modifiers */
|
---|
111 | uint32_t locked; /**< XKB locked modifiers */
|
---|
112 | uint32_t effective;/**< XKB effective modifiers */
|
---|
113 | } mods;
|
---|
114 | struct {
|
---|
115 | uint8_t base; /**< XKB base group */
|
---|
116 | uint8_t latched; /**< XKB latched group */
|
---|
117 | uint8_t locked; /**< XKB locked group */
|
---|
118 | uint8_t effective;/**< XKB effective group */
|
---|
119 | } group;
|
---|
120 | Window root; /**< Root window of the event */
|
---|
121 | int corestate; /**< Core key/button state BEFORE the event */
|
---|
122 | int key_repeat; /**< Internally-generated key repeat event */
|
---|
123 | uint32_t flags; /**< Flags to be copied into the generated event */
|
---|
124 | };
|
---|
125 |
|
---|
126 | /**
|
---|
127 | * Generated internally whenever a touch ownership chain changes - an owner
|
---|
128 | * has accepted or rejected a touch, or a grab/event selection in the delivery
|
---|
129 | * chain has been removed.
|
---|
130 | */
|
---|
131 | struct _TouchOwnershipEvent {
|
---|
132 | unsigned char header; /**< Always ET_Internal */
|
---|
133 | enum EventType type; /**< One of EventType */
|
---|
134 | int length; /**< Length in bytes */
|
---|
135 | Time time; /**< Time in ms */
|
---|
136 | int deviceid; /**< Device to post this event for */
|
---|
137 | int sourceid; /**< The physical source device */
|
---|
138 | uint32_t touchid; /**< Touch ID (client_id) */
|
---|
139 | uint8_t reason; /**< ::XIAcceptTouch, ::XIRejectTouch */
|
---|
140 | uint32_t resource; /**< Provoking grab or event selection */
|
---|
141 | uint32_t flags; /**< Flags to be copied into the generated event */
|
---|
142 | };
|
---|
143 |
|
---|
144 | /* Flags used in DeviceChangedEvent to signal if the slave has changed */
|
---|
145 | #define DEVCHANGE_SLAVE_SWITCH 0x2
|
---|
146 | /* Flags used in DeviceChangedEvent to signal whether the event was a
|
---|
147 | * pointer event or a keyboard event */
|
---|
148 | #define DEVCHANGE_POINTER_EVENT 0x4
|
---|
149 | #define DEVCHANGE_KEYBOARD_EVENT 0x8
|
---|
150 | /* device capabilities changed */
|
---|
151 | #define DEVCHANGE_DEVICE_CHANGE 0x10
|
---|
152 |
|
---|
153 | /**
|
---|
154 | * Sent whenever a device's capabilities have changed.
|
---|
155 | */
|
---|
156 | struct _DeviceChangedEvent {
|
---|
157 | unsigned char header; /**< Always ET_Internal */
|
---|
158 | enum EventType type; /**< ET_DeviceChanged */
|
---|
159 | int length; /**< Length in bytes */
|
---|
160 | Time time; /**< Time in ms */
|
---|
161 | int deviceid; /**< Device whose capabilities have changed */
|
---|
162 | int flags; /**< Mask of ::HAS_NEW_SLAVE,
|
---|
163 | ::POINTER_EVENT, ::KEYBOARD_EVENT */
|
---|
164 | int masterid; /**< MD when event was generated */
|
---|
165 | int sourceid; /**< The device that caused the change */
|
---|
166 |
|
---|
167 | struct {
|
---|
168 | int num_buttons; /**< Number of buttons */
|
---|
169 | Atom names[MAX_BUTTONS];/**< Button names */
|
---|
170 | } buttons;
|
---|
171 |
|
---|
172 | int num_valuators; /**< Number of axes */
|
---|
173 | struct {
|
---|
174 | uint32_t min; /**< Minimum value */
|
---|
175 | uint32_t max; /**< Maximum value */
|
---|
176 | /* FIXME: frac parts of min/max */
|
---|
177 | uint32_t resolution; /**< Resolution counts/m */
|
---|
178 | uint8_t mode; /**< Relative or Absolute */
|
---|
179 | Atom name; /**< Axis name */
|
---|
180 | ScrollInfo scroll; /**< Smooth scrolling info */
|
---|
181 | } valuators[MAX_VALUATORS];
|
---|
182 |
|
---|
183 | struct {
|
---|
184 | int min_keycode;
|
---|
185 | int max_keycode;
|
---|
186 | } keys;
|
---|
187 | };
|
---|
188 |
|
---|
189 | #if XFreeXDGA
|
---|
190 | /**
|
---|
191 | * DGAEvent, used by DGA to intercept and emulate input events.
|
---|
192 | */
|
---|
193 | struct _DGAEvent {
|
---|
194 | unsigned char header; /**< Always ET_Internal */
|
---|
195 | enum EventType type; /**< ET_DGAEvent */
|
---|
196 | int length; /**< Length in bytes */
|
---|
197 | Time time; /**< Time in ms */
|
---|
198 | int subtype; /**< KeyPress, KeyRelease, ButtonPress,
|
---|
199 | ButtonRelease, MotionNotify */
|
---|
200 | int detail; /**< Button number or key code */
|
---|
201 | int dx; /**< Relative x coordinate */
|
---|
202 | int dy; /**< Relative y coordinate */
|
---|
203 | int screen; /**< Screen number this event applies to */
|
---|
204 | uint16_t state; /**< Core modifier/button state */
|
---|
205 | };
|
---|
206 | #endif
|
---|
207 |
|
---|
208 | /**
|
---|
209 | * Raw event, contains the data as posted by the device.
|
---|
210 | */
|
---|
211 | struct _RawDeviceEvent {
|
---|
212 | unsigned char header; /**< Always ET_Internal */
|
---|
213 | enum EventType type; /**< ET_Raw */
|
---|
214 | int length; /**< Length in bytes */
|
---|
215 | Time time; /**< Time in ms */
|
---|
216 | int deviceid; /**< Device to post this event for */
|
---|
217 | int sourceid; /**< The physical source device */
|
---|
218 | union {
|
---|
219 | uint32_t button; /**< Button number */
|
---|
220 | uint32_t key; /**< Key code */
|
---|
221 | } detail;
|
---|
222 | struct {
|
---|
223 | uint8_t mask[(MAX_VALUATORS + 7) / 8];/**< Valuator mask */
|
---|
224 | double data[MAX_VALUATORS]; /**< Valuator data */
|
---|
225 | double data_raw[MAX_VALUATORS]; /**< Valuator data as posted */
|
---|
226 | } valuators;
|
---|
227 | uint32_t flags; /**< Flags to be copied into the generated event */
|
---|
228 | };
|
---|
229 |
|
---|
230 | #ifdef XQUARTZ
|
---|
231 | #define XQUARTZ_EVENT_MAXARGS 5
|
---|
232 | struct _XQuartzEvent {
|
---|
233 | unsigned char header; /**< Always ET_Internal */
|
---|
234 | enum EventType type; /**< Always ET_XQuartz */
|
---|
235 | int length; /**< Length in bytes */
|
---|
236 | Time time; /**< Time in ms. */
|
---|
237 | int subtype; /**< Subtype defined by XQuartz DDX */
|
---|
238 | uint32_t data[XQUARTZ_EVENT_MAXARGS]; /**< Up to 5 32bit values passed to handler */
|
---|
239 | };
|
---|
240 | #endif
|
---|
241 |
|
---|
242 | /**
|
---|
243 | * Event type used inside the X server for input event
|
---|
244 | * processing.
|
---|
245 | */
|
---|
246 | union _InternalEvent {
|
---|
247 | struct {
|
---|
248 | unsigned char header; /**< Always ET_Internal */
|
---|
249 | enum EventType type; /**< One of ET_* */
|
---|
250 | int length; /**< Length in bytes */
|
---|
251 | Time time; /**< Time in ms. */
|
---|
252 | } any;
|
---|
253 | DeviceEvent device_event;
|
---|
254 | DeviceChangedEvent changed_event;
|
---|
255 | TouchOwnershipEvent touch_ownership_event;
|
---|
256 | #if XFreeXDGA
|
---|
257 | DGAEvent dga_event;
|
---|
258 | #endif
|
---|
259 | RawDeviceEvent raw_event;
|
---|
260 | #ifdef XQUARTZ
|
---|
261 | XQuartzEvent xquartz_event;
|
---|
262 | #endif
|
---|
263 | };
|
---|
264 |
|
---|
265 | #endif
|
---|