Blame


1 0206bd51 2008-01-30 rsc #include <X11/Intrinsic.h>
2 0206bd51 2008-01-30 rsc #include <X11/Xproto.h>
3 0206bd51 2008-01-30 rsc
4 0206bd51 2008-01-30 rsc Boolean use_separate_lines = True;
5 0206bd51 2008-01-30 rsc static char *sep;
6 0206bd51 2008-01-30 rsc
7 0206bd51 2008-01-30 rsc /******************************************************************************/
8 0206bd51 2008-01-30 rsc /**** Miscellaneous routines to convert values to their string equivalents ****/
9 0206bd51 2008-01-30 rsc /******************************************************************************/
10 0206bd51 2008-01-30 rsc
11 0206bd51 2008-01-30 rsc /* Returns the string equivalent of a boolean parameter */
12 0206bd51 2008-01-30 rsc static char *TorF(bool)
13 0206bd51 2008-01-30 rsc int bool;
14 0206bd51 2008-01-30 rsc {
15 0cfb3760 2012-10-21 rsc switch (bool) {
16 0cfb3760 2012-10-21 rsc case True:
17 0cfb3760 2012-10-21 rsc return ("True");
18 0206bd51 2008-01-30 rsc
19 0cfb3760 2012-10-21 rsc case False:
20 0cfb3760 2012-10-21 rsc return ("False");
21 0206bd51 2008-01-30 rsc
22 0cfb3760 2012-10-21 rsc default:
23 0cfb3760 2012-10-21 rsc return ("?");
24 0cfb3760 2012-10-21 rsc }
25 0206bd51 2008-01-30 rsc }
26 0206bd51 2008-01-30 rsc
27 0206bd51 2008-01-30 rsc /* Returns the string equivalent of a property notify state */
28 0206bd51 2008-01-30 rsc static char *PropertyState(state)
29 0206bd51 2008-01-30 rsc int state;
30 0206bd51 2008-01-30 rsc {
31 0cfb3760 2012-10-21 rsc switch (state) {
32 0cfb3760 2012-10-21 rsc case PropertyNewValue:
33 0cfb3760 2012-10-21 rsc return ("PropertyNewValue");
34 0206bd51 2008-01-30 rsc
35 0cfb3760 2012-10-21 rsc case PropertyDelete:
36 0cfb3760 2012-10-21 rsc return ("PropertyDelete");
37 0206bd51 2008-01-30 rsc
38 0cfb3760 2012-10-21 rsc default:
39 0cfb3760 2012-10-21 rsc return ("?");
40 0cfb3760 2012-10-21 rsc }
41 0206bd51 2008-01-30 rsc }
42 0206bd51 2008-01-30 rsc
43 0206bd51 2008-01-30 rsc /* Returns the string equivalent of a visibility notify state */
44 0206bd51 2008-01-30 rsc static char *VisibilityState(state)
45 0206bd51 2008-01-30 rsc int state;
46 0206bd51 2008-01-30 rsc {
47 0cfb3760 2012-10-21 rsc switch (state) {
48 0cfb3760 2012-10-21 rsc case VisibilityUnobscured:
49 0cfb3760 2012-10-21 rsc return ("VisibilityUnobscured");
50 0206bd51 2008-01-30 rsc
51 0cfb3760 2012-10-21 rsc case VisibilityPartiallyObscured:
52 0cfb3760 2012-10-21 rsc return ("VisibilityPartiallyObscured");
53 0206bd51 2008-01-30 rsc
54 0cfb3760 2012-10-21 rsc case VisibilityFullyObscured:
55 0cfb3760 2012-10-21 rsc return ("VisibilityFullyObscured");
56 0206bd51 2008-01-30 rsc
57 0cfb3760 2012-10-21 rsc default:
58 0cfb3760 2012-10-21 rsc return ("?");
59 0cfb3760 2012-10-21 rsc }
60 0206bd51 2008-01-30 rsc }
61 0206bd51 2008-01-30 rsc
62 0206bd51 2008-01-30 rsc /* Returns the string equivalent of a timestamp */
63 0206bd51 2008-01-30 rsc static char *ServerTime(time)
64 0206bd51 2008-01-30 rsc Time time;
65 0206bd51 2008-01-30 rsc {
66 0cfb3760 2012-10-21 rsc unsigned long msec;
67 0cfb3760 2012-10-21 rsc unsigned long sec;
68 0cfb3760 2012-10-21 rsc unsigned long min;
69 0cfb3760 2012-10-21 rsc unsigned long hr;
70 0cfb3760 2012-10-21 rsc unsigned long day;
71 fafa622a 2020-01-12 rsc static char buffer[50];
72 0206bd51 2008-01-30 rsc
73 0cfb3760 2012-10-21 rsc msec = time % 1000;
74 0cfb3760 2012-10-21 rsc time /= 1000;
75 0cfb3760 2012-10-21 rsc sec = time % 60;
76 0cfb3760 2012-10-21 rsc time /= 60;
77 0cfb3760 2012-10-21 rsc min = time % 60;
78 0cfb3760 2012-10-21 rsc time /= 60;
79 0cfb3760 2012-10-21 rsc hr = time % 24;
80 0cfb3760 2012-10-21 rsc time /= 24;
81 0cfb3760 2012-10-21 rsc day = time;
82 0206bd51 2008-01-30 rsc
83 0cfb3760 2012-10-21 rsc sprintf(buffer, "%ld day%s %02ld:%02ld:%02ld.%03ld",
84 0cfb3760 2012-10-21 rsc day, day == 1 ? "" : "(s)", hr, min, sec, msec);
85 0cfb3760 2012-10-21 rsc return (buffer);
86 0206bd51 2008-01-30 rsc }
87 0206bd51 2008-01-30 rsc
88 0206bd51 2008-01-30 rsc /* Simple structure to ease the interpretation of masks */
89 0206bd51 2008-01-30 rsc typedef struct _MaskType {
90 0cfb3760 2012-10-21 rsc unsigned int value;
91 0cfb3760 2012-10-21 rsc char *string;
92 0206bd51 2008-01-30 rsc } MaskType;
93 0206bd51 2008-01-30 rsc
94 0206bd51 2008-01-30 rsc /* Returns the string equivalent of a mask of buttons and/or modifier keys */
95 0206bd51 2008-01-30 rsc static char *ButtonAndOrModifierState(state)
96 0206bd51 2008-01-30 rsc unsigned int state;
97 0206bd51 2008-01-30 rsc {
98 0cfb3760 2012-10-21 rsc static char buffer[256];
99 0cfb3760 2012-10-21 rsc static MaskType masks[] = {
100 0cfb3760 2012-10-21 rsc {Button1Mask, "Button1Mask"},
101 0cfb3760 2012-10-21 rsc {Button2Mask, "Button2Mask"},
102 0cfb3760 2012-10-21 rsc {Button3Mask, "Button3Mask"},
103 0cfb3760 2012-10-21 rsc {Button4Mask, "Button4Mask"},
104 0cfb3760 2012-10-21 rsc {Button5Mask, "Button5Mask"},
105 0cfb3760 2012-10-21 rsc {ShiftMask, "ShiftMask"},
106 0cfb3760 2012-10-21 rsc {LockMask, "LockMask"},
107 0cfb3760 2012-10-21 rsc {ControlMask, "ControlMask"},
108 0cfb3760 2012-10-21 rsc {Mod1Mask, "Mod1Mask"},
109 0cfb3760 2012-10-21 rsc {Mod2Mask, "Mod2Mask"},
110 0cfb3760 2012-10-21 rsc {Mod3Mask, "Mod3Mask"},
111 0cfb3760 2012-10-21 rsc {Mod4Mask, "Mod4Mask"},
112 0cfb3760 2012-10-21 rsc {Mod5Mask, "Mod5Mask"},
113 0cfb3760 2012-10-21 rsc };
114 0cfb3760 2012-10-21 rsc int num_masks = sizeof(masks) / sizeof(MaskType);
115 0cfb3760 2012-10-21 rsc int i;
116 0cfb3760 2012-10-21 rsc Boolean first = True;
117 0206bd51 2008-01-30 rsc
118 0cfb3760 2012-10-21 rsc buffer[0] = 0;
119 0206bd51 2008-01-30 rsc
120 0cfb3760 2012-10-21 rsc for (i = 0; i < num_masks; i++)
121 0cfb3760 2012-10-21 rsc if (state & masks[i].value)
122 0cfb3760 2012-10-21 rsc if (first) {
123 0cfb3760 2012-10-21 rsc first = False;
124 0cfb3760 2012-10-21 rsc strcpy(buffer, masks[i].string);
125 0cfb3760 2012-10-21 rsc } else {
126 0cfb3760 2012-10-21 rsc strcat(buffer, " | ");
127 0cfb3760 2012-10-21 rsc strcat(buffer, masks[i].string);
128 0cfb3760 2012-10-21 rsc }
129 0cfb3760 2012-10-21 rsc return (buffer);
130 0206bd51 2008-01-30 rsc }
131 0206bd51 2008-01-30 rsc
132 0206bd51 2008-01-30 rsc /* Returns the string equivalent of a mask of configure window values */
133 0206bd51 2008-01-30 rsc static char *ConfigureValueMask(valuemask)
134 0206bd51 2008-01-30 rsc unsigned int valuemask;
135 0206bd51 2008-01-30 rsc {
136 0cfb3760 2012-10-21 rsc static char buffer[256];
137 0cfb3760 2012-10-21 rsc static MaskType masks[] = {
138 0cfb3760 2012-10-21 rsc {CWX, "CWX"},
139 0cfb3760 2012-10-21 rsc {CWY, "CWY"},
140 0cfb3760 2012-10-21 rsc {CWWidth, "CWWidth"},
141 0cfb3760 2012-10-21 rsc {CWHeight, "CWHeight"},
142 0cfb3760 2012-10-21 rsc {CWBorderWidth, "CWBorderWidth"},
143 0cfb3760 2012-10-21 rsc {CWSibling, "CWSibling"},
144 0cfb3760 2012-10-21 rsc {CWStackMode, "CWStackMode"},
145 0cfb3760 2012-10-21 rsc };
146 0cfb3760 2012-10-21 rsc int num_masks = sizeof(masks) / sizeof(MaskType);
147 0cfb3760 2012-10-21 rsc int i;
148 0cfb3760 2012-10-21 rsc Boolean first = True;
149 0206bd51 2008-01-30 rsc
150 0cfb3760 2012-10-21 rsc buffer[0] = 0;
151 0206bd51 2008-01-30 rsc
152 0cfb3760 2012-10-21 rsc for (i = 0; i < num_masks; i++)
153 0cfb3760 2012-10-21 rsc if (valuemask & masks[i].value)
154 0cfb3760 2012-10-21 rsc if (first) {
155 0cfb3760 2012-10-21 rsc first = False;
156 0cfb3760 2012-10-21 rsc strcpy(buffer, masks[i].string);
157 0cfb3760 2012-10-21 rsc } else {
158 0cfb3760 2012-10-21 rsc strcat(buffer, " | ");
159 0cfb3760 2012-10-21 rsc strcat(buffer, masks[i].string);
160 0cfb3760 2012-10-21 rsc }
161 0cfb3760 2012-10-21 rsc
162 0cfb3760 2012-10-21 rsc return (buffer);
163 0206bd51 2008-01-30 rsc }
164 0206bd51 2008-01-30 rsc
165 0206bd51 2008-01-30 rsc /* Returns the string equivalent of a motion hint */
166 0206bd51 2008-01-30 rsc static char *IsHint(is_hint)
167 0206bd51 2008-01-30 rsc char is_hint;
168 0206bd51 2008-01-30 rsc {
169 0cfb3760 2012-10-21 rsc switch (is_hint) {
170 0cfb3760 2012-10-21 rsc case NotifyNormal:
171 0cfb3760 2012-10-21 rsc return ("NotifyNormal");
172 0206bd51 2008-01-30 rsc
173 0cfb3760 2012-10-21 rsc case NotifyHint:
174 0cfb3760 2012-10-21 rsc return ("NotifyHint");
175 0206bd51 2008-01-30 rsc
176 0cfb3760 2012-10-21 rsc default:
177 0cfb3760 2012-10-21 rsc return ("?");
178 0cfb3760 2012-10-21 rsc }
179 0206bd51 2008-01-30 rsc }
180 0206bd51 2008-01-30 rsc
181 0206bd51 2008-01-30 rsc /* Returns the string equivalent of an id or the value "None" */
182 0206bd51 2008-01-30 rsc static char *MaybeNone(value)
183 0206bd51 2008-01-30 rsc int value;
184 0206bd51 2008-01-30 rsc {
185 0cfb3760 2012-10-21 rsc static char buffer[16];
186 0206bd51 2008-01-30 rsc
187 0cfb3760 2012-10-21 rsc if (value == None)
188 0cfb3760 2012-10-21 rsc return ("None");
189 0cfb3760 2012-10-21 rsc else {
190 0cfb3760 2012-10-21 rsc sprintf(buffer, "0x%x", value);
191 0cfb3760 2012-10-21 rsc return (buffer);
192 0cfb3760 2012-10-21 rsc }
193 0206bd51 2008-01-30 rsc }
194 0206bd51 2008-01-30 rsc
195 0206bd51 2008-01-30 rsc /* Returns the string equivalent of a colormap state */
196 0206bd51 2008-01-30 rsc static char *ColormapState(state)
197 0206bd51 2008-01-30 rsc int state;
198 0206bd51 2008-01-30 rsc {
199 0cfb3760 2012-10-21 rsc switch (state) {
200 0cfb3760 2012-10-21 rsc case ColormapInstalled:
201 0cfb3760 2012-10-21 rsc return ("ColormapInstalled");
202 0206bd51 2008-01-30 rsc
203 0cfb3760 2012-10-21 rsc case ColormapUninstalled:
204 0cfb3760 2012-10-21 rsc return ("ColormapUninstalled");
205 0206bd51 2008-01-30 rsc
206 0cfb3760 2012-10-21 rsc default:
207 0cfb3760 2012-10-21 rsc return ("?");
208 0cfb3760 2012-10-21 rsc }
209 0206bd51 2008-01-30 rsc }
210 0206bd51 2008-01-30 rsc
211 0206bd51 2008-01-30 rsc /* Returns the string equivalent of a crossing detail */
212 0206bd51 2008-01-30 rsc static char *CrossingDetail(detail)
213 0206bd51 2008-01-30 rsc int detail;
214 0206bd51 2008-01-30 rsc {
215 0cfb3760 2012-10-21 rsc switch (detail) {
216 0cfb3760 2012-10-21 rsc case NotifyAncestor:
217 0cfb3760 2012-10-21 rsc return ("NotifyAncestor");
218 0206bd51 2008-01-30 rsc
219 0cfb3760 2012-10-21 rsc case NotifyInferior:
220 0cfb3760 2012-10-21 rsc return ("NotifyInferior");
221 0206bd51 2008-01-30 rsc
222 0cfb3760 2012-10-21 rsc case NotifyVirtual:
223 0cfb3760 2012-10-21 rsc return ("NotifyVirtual");
224 0206bd51 2008-01-30 rsc
225 0cfb3760 2012-10-21 rsc case NotifyNonlinear:
226 0cfb3760 2012-10-21 rsc return ("NotifyNonlinear");
227 0206bd51 2008-01-30 rsc
228 0cfb3760 2012-10-21 rsc case NotifyNonlinearVirtual:
229 0cfb3760 2012-10-21 rsc return ("NotifyNonlinearVirtual");
230 0206bd51 2008-01-30 rsc
231 0cfb3760 2012-10-21 rsc default:
232 0cfb3760 2012-10-21 rsc return ("?");
233 0cfb3760 2012-10-21 rsc }
234 0206bd51 2008-01-30 rsc }
235 0206bd51 2008-01-30 rsc
236 0206bd51 2008-01-30 rsc /* Returns the string equivalent of a focus change detail */
237 0206bd51 2008-01-30 rsc static char *FocusChangeDetail(detail)
238 0206bd51 2008-01-30 rsc int detail;
239 0206bd51 2008-01-30 rsc {
240 0cfb3760 2012-10-21 rsc switch (detail) {
241 0cfb3760 2012-10-21 rsc case NotifyAncestor:
242 0cfb3760 2012-10-21 rsc return ("NotifyAncestor");
243 0206bd51 2008-01-30 rsc
244 0cfb3760 2012-10-21 rsc case NotifyInferior:
245 0cfb3760 2012-10-21 rsc return ("NotifyInferior");
246 0206bd51 2008-01-30 rsc
247 0cfb3760 2012-10-21 rsc case NotifyVirtual:
248 0cfb3760 2012-10-21 rsc return ("NotifyVirtual");
249 0206bd51 2008-01-30 rsc
250 0cfb3760 2012-10-21 rsc case NotifyNonlinear:
251 0cfb3760 2012-10-21 rsc return ("NotifyNonlinear");
252 0206bd51 2008-01-30 rsc
253 0cfb3760 2012-10-21 rsc case NotifyNonlinearVirtual:
254 0cfb3760 2012-10-21 rsc return ("NotifyNonlinearVirtual");
255 0206bd51 2008-01-30 rsc
256 0cfb3760 2012-10-21 rsc case NotifyPointer:
257 0cfb3760 2012-10-21 rsc return ("NotifyPointer");
258 0206bd51 2008-01-30 rsc
259 0cfb3760 2012-10-21 rsc case NotifyPointerRoot:
260 0cfb3760 2012-10-21 rsc return ("NotifyPointerRoot");
261 0206bd51 2008-01-30 rsc
262 0cfb3760 2012-10-21 rsc case NotifyDetailNone:
263 0cfb3760 2012-10-21 rsc return ("NotifyDetailNone");
264 0206bd51 2008-01-30 rsc
265 0cfb3760 2012-10-21 rsc default:
266 0cfb3760 2012-10-21 rsc return ("?");
267 0cfb3760 2012-10-21 rsc }
268 0206bd51 2008-01-30 rsc }
269 0206bd51 2008-01-30 rsc
270 0206bd51 2008-01-30 rsc /* Returns the string equivalent of a configure detail */
271 0206bd51 2008-01-30 rsc static char *ConfigureDetail(detail)
272 0206bd51 2008-01-30 rsc int detail;
273 0206bd51 2008-01-30 rsc {
274 0cfb3760 2012-10-21 rsc switch (detail) {
275 0cfb3760 2012-10-21 rsc case Above:
276 0cfb3760 2012-10-21 rsc return ("Above");
277 0206bd51 2008-01-30 rsc
278 0cfb3760 2012-10-21 rsc case Below:
279 0cfb3760 2012-10-21 rsc return ("Below");
280 0206bd51 2008-01-30 rsc
281 0cfb3760 2012-10-21 rsc case TopIf:
282 0cfb3760 2012-10-21 rsc return ("TopIf");
283 0206bd51 2008-01-30 rsc
284 0cfb3760 2012-10-21 rsc case BottomIf:
285 0cfb3760 2012-10-21 rsc return ("BottomIf");
286 0206bd51 2008-01-30 rsc
287 0cfb3760 2012-10-21 rsc case Opposite:
288 0cfb3760 2012-10-21 rsc return ("Opposite");
289 0206bd51 2008-01-30 rsc
290 0cfb3760 2012-10-21 rsc default:
291 0cfb3760 2012-10-21 rsc return ("?");
292 0cfb3760 2012-10-21 rsc }
293 0206bd51 2008-01-30 rsc }
294 0206bd51 2008-01-30 rsc
295 0206bd51 2008-01-30 rsc /* Returns the string equivalent of a grab mode */
296 0206bd51 2008-01-30 rsc static char *GrabMode(mode)
297 0206bd51 2008-01-30 rsc int mode;
298 0206bd51 2008-01-30 rsc {
299 0cfb3760 2012-10-21 rsc switch (mode) {
300 0cfb3760 2012-10-21 rsc case NotifyNormal:
301 0cfb3760 2012-10-21 rsc return ("NotifyNormal");
302 0206bd51 2008-01-30 rsc
303 0cfb3760 2012-10-21 rsc case NotifyGrab:
304 0cfb3760 2012-10-21 rsc return ("NotifyGrab");
305 0206bd51 2008-01-30 rsc
306 0cfb3760 2012-10-21 rsc case NotifyUngrab:
307 0cfb3760 2012-10-21 rsc return ("NotifyUngrab");
308 0206bd51 2008-01-30 rsc
309 0cfb3760 2012-10-21 rsc case NotifyWhileGrabbed:
310 0cfb3760 2012-10-21 rsc return ("NotifyWhileGrabbed");
311 0206bd51 2008-01-30 rsc
312 0cfb3760 2012-10-21 rsc default:
313 0cfb3760 2012-10-21 rsc return ("?");
314 0cfb3760 2012-10-21 rsc }
315 0206bd51 2008-01-30 rsc }
316 0206bd51 2008-01-30 rsc
317 0206bd51 2008-01-30 rsc /* Returns the string equivalent of a mapping request */
318 0206bd51 2008-01-30 rsc static char *MappingRequest(request)
319 0206bd51 2008-01-30 rsc int request;
320 0206bd51 2008-01-30 rsc {
321 0cfb3760 2012-10-21 rsc switch (request) {
322 0cfb3760 2012-10-21 rsc case MappingModifier:
323 0cfb3760 2012-10-21 rsc return ("MappingModifier");
324 0206bd51 2008-01-30 rsc
325 0cfb3760 2012-10-21 rsc case MappingKeyboard:
326 0cfb3760 2012-10-21 rsc return ("MappingKeyboard");
327 0206bd51 2008-01-30 rsc
328 0cfb3760 2012-10-21 rsc case MappingPointer:
329 0cfb3760 2012-10-21 rsc return ("MappingPointer");
330 0206bd51 2008-01-30 rsc
331 0cfb3760 2012-10-21 rsc default:
332 0cfb3760 2012-10-21 rsc return ("?");
333 0cfb3760 2012-10-21 rsc }
334 0206bd51 2008-01-30 rsc }
335 0206bd51 2008-01-30 rsc
336 0206bd51 2008-01-30 rsc /* Returns the string equivalent of a stacking order place */
337 0206bd51 2008-01-30 rsc static char *Place(place)
338 0206bd51 2008-01-30 rsc int place;
339 0206bd51 2008-01-30 rsc {
340 0cfb3760 2012-10-21 rsc switch (place) {
341 0cfb3760 2012-10-21 rsc case PlaceOnTop:
342 0cfb3760 2012-10-21 rsc return ("PlaceOnTop");
343 0206bd51 2008-01-30 rsc
344 0cfb3760 2012-10-21 rsc case PlaceOnBottom:
345 0cfb3760 2012-10-21 rsc return ("PlaceOnBottom");
346 0206bd51 2008-01-30 rsc
347 0cfb3760 2012-10-21 rsc default:
348 0cfb3760 2012-10-21 rsc return ("?");
349 0cfb3760 2012-10-21 rsc }
350 0206bd51 2008-01-30 rsc }
351 0206bd51 2008-01-30 rsc
352 0206bd51 2008-01-30 rsc /* Returns the string equivalent of a major code */
353 0206bd51 2008-01-30 rsc static char *MajorCode(code)
354 0206bd51 2008-01-30 rsc int code;
355 0206bd51 2008-01-30 rsc {
356 0cfb3760 2012-10-21 rsc static char buffer[32];
357 0206bd51 2008-01-30 rsc
358 0cfb3760 2012-10-21 rsc switch (code) {
359 0cfb3760 2012-10-21 rsc case X_CopyArea:
360 0cfb3760 2012-10-21 rsc return ("X_CopyArea");
361 0206bd51 2008-01-30 rsc
362 0cfb3760 2012-10-21 rsc case X_CopyPlane:
363 0cfb3760 2012-10-21 rsc return ("X_CopyPlane");
364 0206bd51 2008-01-30 rsc
365 0cfb3760 2012-10-21 rsc default:
366 0cfb3760 2012-10-21 rsc sprintf(buffer, "0x%x", code);
367 0cfb3760 2012-10-21 rsc return (buffer);
368 0cfb3760 2012-10-21 rsc }
369 0206bd51 2008-01-30 rsc }
370 0206bd51 2008-01-30 rsc
371 0206bd51 2008-01-30 rsc /* Returns the string equivalent the keycode contained in the key event */
372 0206bd51 2008-01-30 rsc static char *Keycode(ev)
373 0206bd51 2008-01-30 rsc XKeyEvent *ev;
374 0206bd51 2008-01-30 rsc {
375 0cfb3760 2012-10-21 rsc static char buffer[256];
376 0cfb3760 2012-10-21 rsc KeySym keysym_str;
377 0cfb3760 2012-10-21 rsc char *keysym_name;
378 0cfb3760 2012-10-21 rsc char string[256];
379 0206bd51 2008-01-30 rsc
380 0cfb3760 2012-10-21 rsc XLookupString(ev, string, 64, &keysym_str, NULL);
381 0206bd51 2008-01-30 rsc
382 0cfb3760 2012-10-21 rsc if (keysym_str == NoSymbol)
383 0cfb3760 2012-10-21 rsc keysym_name = "NoSymbol";
384 0cfb3760 2012-10-21 rsc else if (!(keysym_name = XKeysymToString(keysym_str)))
385 0cfb3760 2012-10-21 rsc keysym_name = "(no name)";
386 0cfb3760 2012-10-21 rsc sprintf(buffer, "%u (keysym 0x%x \"%s\")",
387 0cfb3760 2012-10-21 rsc ev->keycode, (unsigned)keysym_str, keysym_name);
388 0cfb3760 2012-10-21 rsc return (buffer);
389 0206bd51 2008-01-30 rsc }
390 0206bd51 2008-01-30 rsc
391 0206bd51 2008-01-30 rsc /* Returns the string equivalent of an atom or "None"*/
392 e601e525 2008-01-30 rsc static char *AtomName(Display *dpy, Atom atom)
393 0206bd51 2008-01-30 rsc {
394 0cfb3760 2012-10-21 rsc static char buffer[256];
395 0cfb3760 2012-10-21 rsc char *atom_name;
396 0206bd51 2008-01-30 rsc
397 0cfb3760 2012-10-21 rsc if (atom == None)
398 0cfb3760 2012-10-21 rsc return ("None");
399 0206bd51 2008-01-30 rsc
400 0cfb3760 2012-10-21 rsc atom_name = XGetAtomName(dpy, atom);
401 0cfb3760 2012-10-21 rsc strncpy(buffer, atom_name, 256);
402 0cfb3760 2012-10-21 rsc XFree(atom_name);
403 0cfb3760 2012-10-21 rsc return (buffer);
404 0206bd51 2008-01-30 rsc }
405 0206bd51 2008-01-30 rsc
406 0206bd51 2008-01-30 rsc /******************************************************************************/
407 0206bd51 2008-01-30 rsc /**** Routines to print out readable values for the field of various events ***/
408 0206bd51 2008-01-30 rsc /******************************************************************************/
409 0206bd51 2008-01-30 rsc
410 0206bd51 2008-01-30 rsc static void VerbMotion(XMotionEvent *ev)
411 0206bd51 2008-01-30 rsc {
412 0cfb3760 2012-10-21 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
413 0cfb3760 2012-10-21 rsc printf("root=0x%x%s", (unsigned)ev->root, sep);
414 0cfb3760 2012-10-21 rsc printf("subwindow=0x%x%s", (unsigned)ev->subwindow, sep);
415 0cfb3760 2012-10-21 rsc printf("time=%s%s", ServerTime(ev->time), sep);
416 0cfb3760 2012-10-21 rsc printf("x=%d y=%d%s", ev->x, ev->y, sep);
417 0cfb3760 2012-10-21 rsc printf("x_root=%d y_root=%d%s", ev->x_root, ev->y_root, sep);
418 0cfb3760 2012-10-21 rsc printf("state=%s%s", ButtonAndOrModifierState(ev->state), sep);
419 0cfb3760 2012-10-21 rsc printf("is_hint=%s%s", IsHint(ev->is_hint), sep);
420 0cfb3760 2012-10-21 rsc printf("same_screen=%s\n", TorF(ev->same_screen));
421 0206bd51 2008-01-30 rsc }
422 0206bd51 2008-01-30 rsc
423 0206bd51 2008-01-30 rsc static void VerbButton(XButtonEvent *ev)
424 0206bd51 2008-01-30 rsc {
425 0cfb3760 2012-10-21 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
426 0cfb3760 2012-10-21 rsc printf("root=0x%x%s", (unsigned)ev->root, sep);
427 0cfb3760 2012-10-21 rsc printf("subwindow=0x%x%s", (unsigned)ev->subwindow, sep);
428 0cfb3760 2012-10-21 rsc printf("time=%s%s", ServerTime(ev->time), sep);
429 0cfb3760 2012-10-21 rsc printf("x=%d y=%d%s", ev->x, ev->y, sep);
430 0cfb3760 2012-10-21 rsc printf("x_root=%d y_root=%d%s", ev->x_root, ev->y_root, sep);
431 0cfb3760 2012-10-21 rsc printf("state=%s%s", ButtonAndOrModifierState(ev->state), sep);
432 0cfb3760 2012-10-21 rsc printf("button=%s%s", ButtonAndOrModifierState(ev->button), sep);
433 0cfb3760 2012-10-21 rsc printf("same_screen=%s\n", TorF(ev->same_screen));
434 0206bd51 2008-01-30 rsc }
435 0206bd51 2008-01-30 rsc
436 0206bd51 2008-01-30 rsc static void VerbColormap(XColormapEvent *ev)
437 0206bd51 2008-01-30 rsc {
438 0cfb3760 2012-10-21 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
439 0cfb3760 2012-10-21 rsc printf("colormap=%s%s", MaybeNone(ev->colormap), sep);
440 0cfb3760 2012-10-21 rsc printf("new=%s%s", TorF(ev->new), sep);
441 0cfb3760 2012-10-21 rsc printf("state=%s\n", ColormapState(ev->state));
442 0206bd51 2008-01-30 rsc }
443 0206bd51 2008-01-30 rsc
444 0206bd51 2008-01-30 rsc static void VerbCrossing(XCrossingEvent *ev)
445 0206bd51 2008-01-30 rsc {
446 0cfb3760 2012-10-21 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
447 0cfb3760 2012-10-21 rsc printf("root=0x%x%s", (unsigned)ev->root, sep);
448 0cfb3760 2012-10-21 rsc printf("subwindow=0x%x%s", (unsigned)ev->subwindow, sep);
449 0cfb3760 2012-10-21 rsc printf("time=%s%s", ServerTime(ev->time), sep);
450 0cfb3760 2012-10-21 rsc printf("x=%d y=%d%s", ev->x, ev->y, sep);
451 0cfb3760 2012-10-21 rsc printf("x_root=%d y_root=%d%s", ev->x_root, ev->y_root, sep);
452 0cfb3760 2012-10-21 rsc printf("mode=%s%s", GrabMode(ev->mode), sep);
453 0cfb3760 2012-10-21 rsc printf("detail=%s%s", CrossingDetail(ev->detail), sep);
454 0cfb3760 2012-10-21 rsc printf("same_screen=%s%s", TorF(ev->same_screen), sep);
455 0cfb3760 2012-10-21 rsc printf("focus=%s%s", TorF(ev->focus), sep);
456 0cfb3760 2012-10-21 rsc printf("state=%s\n", ButtonAndOrModifierState(ev->state));
457 0206bd51 2008-01-30 rsc }
458 0206bd51 2008-01-30 rsc
459 0206bd51 2008-01-30 rsc static void VerbExpose(XExposeEvent *ev)
460 0206bd51 2008-01-30 rsc {
461 0cfb3760 2012-10-21 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
462 0cfb3760 2012-10-21 rsc printf("x=%d y=%d%s", ev->x, ev->y, sep);
463 0cfb3760 2012-10-21 rsc printf("width=%d height=%d%s", ev->width, ev->height, sep);
464 0cfb3760 2012-10-21 rsc printf("count=%d\n", ev->count);
465 0206bd51 2008-01-30 rsc }
466 0206bd51 2008-01-30 rsc
467 0206bd51 2008-01-30 rsc static void VerbGraphicsExpose(XGraphicsExposeEvent *ev)
468 0206bd51 2008-01-30 rsc {
469 0cfb3760 2012-10-21 rsc printf("drawable=0x%x%s", (unsigned)ev->drawable, sep);
470 0cfb3760 2012-10-21 rsc printf("x=%d y=%d%s", ev->x, ev->y, sep);
471 0cfb3760 2012-10-21 rsc printf("width=%d height=%d%s", ev->width, ev->height, sep);
472 0cfb3760 2012-10-21 rsc printf("major_code=%s%s", MajorCode(ev->major_code), sep);
473 0cfb3760 2012-10-21 rsc printf("minor_code=%d\n", ev->minor_code);
474 0206bd51 2008-01-30 rsc }
475 0206bd51 2008-01-30 rsc
476 0206bd51 2008-01-30 rsc static void VerbNoExpose(XNoExposeEvent *ev)
477 0206bd51 2008-01-30 rsc {
478 0cfb3760 2012-10-21 rsc printf("drawable=0x%x%s", (unsigned)ev->drawable, sep);
479 0cfb3760 2012-10-21 rsc printf("major_code=%s%s", MajorCode(ev->major_code), sep);
480 0cfb3760 2012-10-21 rsc printf("minor_code=%d\n", ev->minor_code);
481 0206bd51 2008-01-30 rsc }
482 0206bd51 2008-01-30 rsc
483 0206bd51 2008-01-30 rsc static void VerbFocus(XFocusChangeEvent *ev)
484 0206bd51 2008-01-30 rsc {
485 0cfb3760 2012-10-21 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
486 0cfb3760 2012-10-21 rsc printf("mode=%s%s", GrabMode(ev->mode), sep);
487 0cfb3760 2012-10-21 rsc printf("detail=%s\n", FocusChangeDetail(ev->detail));
488 0206bd51 2008-01-30 rsc }
489 0206bd51 2008-01-30 rsc
490 0206bd51 2008-01-30 rsc static void VerbKeymap(XKeymapEvent *ev)
491 0206bd51 2008-01-30 rsc {
492 0cfb3760 2012-10-21 rsc int i;
493 0206bd51 2008-01-30 rsc
494 0cfb3760 2012-10-21 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
495 0cfb3760 2012-10-21 rsc printf("key_vector=");
496 0cfb3760 2012-10-21 rsc for (i = 0; i < 32; i++)
497 0cfb3760 2012-10-21 rsc printf("%02x", ev->key_vector[i]);
498 0cfb3760 2012-10-21 rsc printf("\n");
499 0206bd51 2008-01-30 rsc }
500 0206bd51 2008-01-30 rsc
501 0206bd51 2008-01-30 rsc static void VerbKey(XKeyEvent *ev)
502 0206bd51 2008-01-30 rsc {
503 0cfb3760 2012-10-21 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
504 0cfb3760 2012-10-21 rsc printf("root=0x%x%s", (unsigned)ev->root, sep);
505 0cfb3760 2012-10-21 rsc printf("subwindow=0x%x%s", (unsigned)ev->subwindow, sep);
506 0cfb3760 2012-10-21 rsc printf("time=%s%s", ServerTime(ev->time), sep);
507 0cfb3760 2012-10-21 rsc printf("x=%d y=%d%s", ev->x, ev->y, sep);
508 0cfb3760 2012-10-21 rsc printf("x_root=%d y_root=%d%s", ev->x_root, ev->y_root, sep);
509 0cfb3760 2012-10-21 rsc printf("state=%s%s", ButtonAndOrModifierState(ev->state), sep);
510 0cfb3760 2012-10-21 rsc printf("keycode=%s%s", Keycode(ev), sep);
511 0cfb3760 2012-10-21 rsc printf("same_screen=%s\n", TorF(ev->same_screen));
512 0206bd51 2008-01-30 rsc }
513 0206bd51 2008-01-30 rsc
514 0206bd51 2008-01-30 rsc static void VerbProperty(XPropertyEvent *ev)
515 0206bd51 2008-01-30 rsc {
516 0cfb3760 2012-10-21 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
517 0cfb3760 2012-10-21 rsc printf("atom=%s%s", AtomName(ev->display, ev->atom), sep);
518 0cfb3760 2012-10-21 rsc printf("time=%s%s", ServerTime(ev->time), sep);
519 0cfb3760 2012-10-21 rsc printf("state=%s\n", PropertyState(ev->state));
520 0206bd51 2008-01-30 rsc }
521 0206bd51 2008-01-30 rsc
522 0206bd51 2008-01-30 rsc static void VerbResizeRequest(XResizeRequestEvent *ev)
523 0206bd51 2008-01-30 rsc {
524 0cfb3760 2012-10-21 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
525 0cfb3760 2012-10-21 rsc printf("width=%d height=%d\n", ev->width, ev->height);
526 0206bd51 2008-01-30 rsc }
527 0206bd51 2008-01-30 rsc
528 0206bd51 2008-01-30 rsc static void VerbCirculate(XCirculateEvent *ev)
529 0206bd51 2008-01-30 rsc {
530 0cfb3760 2012-10-21 rsc printf("event=0x%x%s", (unsigned)ev->event, sep);
531 0cfb3760 2012-10-21 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
532 0cfb3760 2012-10-21 rsc printf("place=%s\n", Place(ev->place));
533 0206bd51 2008-01-30 rsc }
534 0206bd51 2008-01-30 rsc
535 0206bd51 2008-01-30 rsc static void VerbConfigure(XConfigureEvent *ev)
536 0206bd51 2008-01-30 rsc {
537 0cfb3760 2012-10-21 rsc printf("event=0x%x%s", (unsigned)ev->event, sep);
538 0cfb3760 2012-10-21 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
539 0cfb3760 2012-10-21 rsc printf("x=%d y=%d%s", ev->x, ev->y, sep);
540 0cfb3760 2012-10-21 rsc printf("width=%d height=%d%s", ev->width, ev->height, sep);
541 0cfb3760 2012-10-21 rsc printf("border_width=%d%s", ev->border_width, sep);
542 0cfb3760 2012-10-21 rsc printf("above=%s%s", MaybeNone(ev->above), sep);
543 0cfb3760 2012-10-21 rsc printf("override_redirect=%s\n", TorF(ev->override_redirect));
544 0206bd51 2008-01-30 rsc }
545 0206bd51 2008-01-30 rsc
546 0206bd51 2008-01-30 rsc static void VerbCreateWindow(XCreateWindowEvent *ev)
547 0206bd51 2008-01-30 rsc {
548 0cfb3760 2012-10-21 rsc printf("parent=0x%x%s", (unsigned)ev->parent, sep);
549 0cfb3760 2012-10-21 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
550 0cfb3760 2012-10-21 rsc printf("x=%d y=%d%s", ev->x, ev->y, sep);
551 0cfb3760 2012-10-21 rsc printf("width=%d height=%d%s", ev->width, ev->height, sep);
552 0cfb3760 2012-10-21 rsc printf("border_width=%d%s", ev->border_width, sep);
553 0cfb3760 2012-10-21 rsc printf("override_redirect=%s\n", TorF(ev->override_redirect));
554 0206bd51 2008-01-30 rsc }
555 0206bd51 2008-01-30 rsc
556 0206bd51 2008-01-30 rsc static void VerbDestroyWindow(XDestroyWindowEvent *ev)
557 0206bd51 2008-01-30 rsc {
558 0cfb3760 2012-10-21 rsc printf("event=0x%x%s", (unsigned)ev->event, sep);
559 0cfb3760 2012-10-21 rsc printf("window=0x%x\n", (unsigned)ev->window);
560 0206bd51 2008-01-30 rsc }
561 0206bd51 2008-01-30 rsc
562 0206bd51 2008-01-30 rsc static void VerbGravity(XGravityEvent *ev)
563 0206bd51 2008-01-30 rsc {
564 0cfb3760 2012-10-21 rsc printf("event=0x%x%s", (unsigned)ev->event, sep);
565 0cfb3760 2012-10-21 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
566 0cfb3760 2012-10-21 rsc printf("x=%d y=%d\n", ev->x, ev->y);
567 0206bd51 2008-01-30 rsc }
568 0206bd51 2008-01-30 rsc
569 0206bd51 2008-01-30 rsc static void VerbMap(XMapEvent *ev)
570 0206bd51 2008-01-30 rsc {
571 0cfb3760 2012-10-21 rsc printf("event=0x%x%s", (unsigned)ev->event, sep);
572 0cfb3760 2012-10-21 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
573 0cfb3760 2012-10-21 rsc printf("override_redirect=%s\n", TorF(ev->override_redirect));
574 0206bd51 2008-01-30 rsc }
575 0206bd51 2008-01-30 rsc
576 0206bd51 2008-01-30 rsc static void VerbReparent(XReparentEvent *ev)
577 0206bd51 2008-01-30 rsc {
578 0cfb3760 2012-10-21 rsc printf("event=0x%x%s", (unsigned)ev->event, sep);
579 0cfb3760 2012-10-21 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
580 0cfb3760 2012-10-21 rsc printf("parent=0x%x%s", (unsigned)ev->parent, sep);
581 0cfb3760 2012-10-21 rsc printf("x=%d y=%d%s", ev->x, ev->y, sep);
582 0cfb3760 2012-10-21 rsc printf("override_redirect=%s\n", TorF(ev->override_redirect));
583 0206bd51 2008-01-30 rsc }
584 0206bd51 2008-01-30 rsc
585 0206bd51 2008-01-30 rsc static void VerbUnmap(XUnmapEvent *ev)
586 0206bd51 2008-01-30 rsc {
587 0cfb3760 2012-10-21 rsc printf("event=0x%x%s", (unsigned)ev->event, sep);
588 0cfb3760 2012-10-21 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
589 0cfb3760 2012-10-21 rsc printf("from_configure=%s\n", TorF(ev->from_configure));
590 0206bd51 2008-01-30 rsc }
591 0206bd51 2008-01-30 rsc
592 0206bd51 2008-01-30 rsc static void VerbCirculateRequest(XCirculateRequestEvent *ev)
593 0206bd51 2008-01-30 rsc {
594 0cfb3760 2012-10-21 rsc printf("parent=0x%x%s", (unsigned)ev->parent, sep);
595 0cfb3760 2012-10-21 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
596 0cfb3760 2012-10-21 rsc printf("place=%s\n", Place(ev->place));
597 0206bd51 2008-01-30 rsc }
598 0206bd51 2008-01-30 rsc
599 0206bd51 2008-01-30 rsc static void VerbConfigureRequest(XConfigureRequestEvent *ev)
600 0206bd51 2008-01-30 rsc {
601 0cfb3760 2012-10-21 rsc printf("parent=0x%x%s", (unsigned)ev->parent, sep);
602 0cfb3760 2012-10-21 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
603 0cfb3760 2012-10-21 rsc printf("x=%d y=%d%s", ev->x, ev->y, sep);
604 0cfb3760 2012-10-21 rsc printf("width=%d height=%d%s", ev->width, ev->height, sep);
605 0cfb3760 2012-10-21 rsc printf("border_width=%d%s", ev->border_width, sep);
606 0cfb3760 2012-10-21 rsc printf("above=%s%s", MaybeNone(ev->above), sep);
607 0cfb3760 2012-10-21 rsc printf("detail=%s%s", ConfigureDetail(ev->detail), sep);
608 0cfb3760 2012-10-21 rsc printf("value_mask=%s\n", ConfigureValueMask(ev->value_mask));
609 0206bd51 2008-01-30 rsc }
610 0206bd51 2008-01-30 rsc
611 0206bd51 2008-01-30 rsc static void VerbMapRequest(XMapRequestEvent *ev)
612 0206bd51 2008-01-30 rsc {
613 0cfb3760 2012-10-21 rsc printf("parent=0x%x%s", (unsigned)ev->parent, sep);
614 0cfb3760 2012-10-21 rsc printf("window=0x%x\n", (unsigned)ev->window);
615 0206bd51 2008-01-30 rsc }
616 0206bd51 2008-01-30 rsc
617 0206bd51 2008-01-30 rsc static void VerbClient(XClientMessageEvent *ev)
618 0206bd51 2008-01-30 rsc {
619 0cfb3760 2012-10-21 rsc int i;
620 0206bd51 2008-01-30 rsc
621 0cfb3760 2012-10-21 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
622 0cfb3760 2012-10-21 rsc printf("message_type=%s%s", AtomName(ev->display, ev->message_type), sep);
623 0cfb3760 2012-10-21 rsc printf("format=%d\n", ev->format);
624 0cfb3760 2012-10-21 rsc printf("data (shown as longs)=");
625 0cfb3760 2012-10-21 rsc for (i = 0; i < 5; i++)
626 0cfb3760 2012-10-21 rsc printf(" 0x%08lx", ev->data.l[i]);
627 0cfb3760 2012-10-21 rsc printf("\n");
628 0206bd51 2008-01-30 rsc }
629 0206bd51 2008-01-30 rsc
630 0206bd51 2008-01-30 rsc static void VerbMapping(XMappingEvent *ev)
631 0206bd51 2008-01-30 rsc {
632 0cfb3760 2012-10-21 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
633 0cfb3760 2012-10-21 rsc printf("request=%s%s", MappingRequest(ev->request), sep);
634 0cfb3760 2012-10-21 rsc printf("first_keycode=0x%x%s", ev->first_keycode, sep);
635 0cfb3760 2012-10-21 rsc printf("count=0x%x\n", ev->count);
636 0206bd51 2008-01-30 rsc }
637 0206bd51 2008-01-30 rsc
638 0206bd51 2008-01-30 rsc static void VerbSelectionClear(XSelectionClearEvent *ev)
639 0206bd51 2008-01-30 rsc {
640 0cfb3760 2012-10-21 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
641 0cfb3760 2012-10-21 rsc printf("selection=%s%s", AtomName(ev->display, ev->selection), sep);
642 0cfb3760 2012-10-21 rsc printf("time=%s\n", ServerTime(ev->time));
643 0206bd51 2008-01-30 rsc }
644 0206bd51 2008-01-30 rsc
645 0206bd51 2008-01-30 rsc static void VerbSelection(XSelectionEvent *ev)
646 0206bd51 2008-01-30 rsc {
647 0cfb3760 2012-10-21 rsc printf("requestor=0x%x%s", (unsigned)ev->requestor, sep);
648 0cfb3760 2012-10-21 rsc printf("selection=%s%s", AtomName(ev->display, ev->selection), sep);
649 0cfb3760 2012-10-21 rsc printf("target=%s%s", AtomName(ev->display, ev->target), sep);
650 0cfb3760 2012-10-21 rsc printf("property=%s%s", AtomName(ev->display, ev->property), sep);
651 0cfb3760 2012-10-21 rsc printf("time=%s\n", ServerTime(ev->time));
652 0206bd51 2008-01-30 rsc }
653 0206bd51 2008-01-30 rsc
654 0206bd51 2008-01-30 rsc static void VerbSelectionRequest(XSelectionRequestEvent *ev)
655 0206bd51 2008-01-30 rsc {
656 0cfb3760 2012-10-21 rsc printf("owner=0x%x%s", (unsigned)ev->owner, sep);
657 0cfb3760 2012-10-21 rsc printf("requestor=0x%x%s", (unsigned)ev->requestor, sep);
658 0cfb3760 2012-10-21 rsc printf("selection=%s%s", AtomName(ev->display, ev->selection), sep);
659 0cfb3760 2012-10-21 rsc printf("target=%s%s", AtomName(ev->display, ev->target), sep);
660 0cfb3760 2012-10-21 rsc printf("property=%s%s", AtomName(ev->display, ev->property), sep);
661 0cfb3760 2012-10-21 rsc printf("time=%s\n", ServerTime(ev->time));
662 0206bd51 2008-01-30 rsc }
663 0206bd51 2008-01-30 rsc
664 0206bd51 2008-01-30 rsc static void VerbVisibility(XVisibilityEvent *ev)
665 0206bd51 2008-01-30 rsc {
666 0cfb3760 2012-10-21 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
667 0cfb3760 2012-10-21 rsc printf("state=%s\n", VisibilityState(ev->state));
668 0206bd51 2008-01-30 rsc }
669 0206bd51 2008-01-30 rsc
670 0206bd51 2008-01-30 rsc /******************************************************************************/
671 0206bd51 2008-01-30 rsc /************ Return the string representation for type of an event ***********/
672 0206bd51 2008-01-30 rsc /******************************************************************************/
673 0206bd51 2008-01-30 rsc
674 0206bd51 2008-01-30 rsc char *GetType(ev)
675 0206bd51 2008-01-30 rsc XEvent *ev;
676 0206bd51 2008-01-30 rsc {
677 0cfb3760 2012-10-21 rsc switch (ev->type) {
678 0cfb3760 2012-10-21 rsc case KeyPress:
679 0cfb3760 2012-10-21 rsc return ("KeyPress");
680 0cfb3760 2012-10-21 rsc case KeyRelease:
681 0cfb3760 2012-10-21 rsc return ("KeyRelease");
682 0cfb3760 2012-10-21 rsc case ButtonPress:
683 0cfb3760 2012-10-21 rsc return ("ButtonPress");
684 0cfb3760 2012-10-21 rsc case ButtonRelease:
685 0cfb3760 2012-10-21 rsc return ("ButtonRelease");
686 0cfb3760 2012-10-21 rsc case MotionNotify:
687 0cfb3760 2012-10-21 rsc return ("MotionNotify");
688 0cfb3760 2012-10-21 rsc case EnterNotify:
689 0cfb3760 2012-10-21 rsc return ("EnterNotify");
690 0cfb3760 2012-10-21 rsc case LeaveNotify:
691 0cfb3760 2012-10-21 rsc return ("LeaveNotify");
692 0cfb3760 2012-10-21 rsc case FocusIn:
693 0cfb3760 2012-10-21 rsc return ("FocusIn");
694 0cfb3760 2012-10-21 rsc case FocusOut:
695 0cfb3760 2012-10-21 rsc return ("FocusOut");
696 0cfb3760 2012-10-21 rsc case KeymapNotify:
697 0cfb3760 2012-10-21 rsc return ("KeymapNotify");
698 0cfb3760 2012-10-21 rsc case Expose:
699 0cfb3760 2012-10-21 rsc return ("Expose");
700 0cfb3760 2012-10-21 rsc case GraphicsExpose:
701 0cfb3760 2012-10-21 rsc return ("GraphicsExpose");
702 0cfb3760 2012-10-21 rsc case NoExpose:
703 0cfb3760 2012-10-21 rsc return ("NoExpose");
704 0cfb3760 2012-10-21 rsc case VisibilityNotify:
705 0cfb3760 2012-10-21 rsc return ("VisibilityNotify");
706 0cfb3760 2012-10-21 rsc case CreateNotify:
707 0cfb3760 2012-10-21 rsc return ("CreateNotify");
708 0cfb3760 2012-10-21 rsc case DestroyNotify:
709 0cfb3760 2012-10-21 rsc return ("DestroyNotify");
710 0cfb3760 2012-10-21 rsc case UnmapNotify:
711 0cfb3760 2012-10-21 rsc return ("UnmapNotify");
712 0cfb3760 2012-10-21 rsc case MapNotify:
713 0cfb3760 2012-10-21 rsc return ("MapNotify");
714 0cfb3760 2012-10-21 rsc case MapRequest:
715 0cfb3760 2012-10-21 rsc return ("MapRequest");
716 0cfb3760 2012-10-21 rsc case ReparentNotify:
717 0cfb3760 2012-10-21 rsc return ("ReparentNotify");
718 0cfb3760 2012-10-21 rsc case ConfigureNotify:
719 0cfb3760 2012-10-21 rsc return ("ConfigureNotify");
720 0cfb3760 2012-10-21 rsc case ConfigureRequest:
721 0cfb3760 2012-10-21 rsc return ("ConfigureRequest");
722 0cfb3760 2012-10-21 rsc case GravityNotify:
723 0cfb3760 2012-10-21 rsc return ("GravityNotify");
724 0cfb3760 2012-10-21 rsc case ResizeRequest:
725 0cfb3760 2012-10-21 rsc return ("ResizeRequest");
726 0cfb3760 2012-10-21 rsc case CirculateNotify:
727 0cfb3760 2012-10-21 rsc return ("CirculateNotify");
728 0cfb3760 2012-10-21 rsc case CirculateRequest:
729 0cfb3760 2012-10-21 rsc return ("CirculateRequest");
730 0cfb3760 2012-10-21 rsc case PropertyNotify:
731 0cfb3760 2012-10-21 rsc return ("PropertyNotify");
732 0cfb3760 2012-10-21 rsc case SelectionClear:
733 0cfb3760 2012-10-21 rsc return ("SelectionClear");
734 0cfb3760 2012-10-21 rsc case SelectionRequest:
735 0cfb3760 2012-10-21 rsc return ("SelectionRequest");
736 0cfb3760 2012-10-21 rsc case SelectionNotify:
737 0cfb3760 2012-10-21 rsc return ("SelectionNotify");
738 0cfb3760 2012-10-21 rsc case ColormapNotify:
739 0cfb3760 2012-10-21 rsc return ("ColormapNotify");
740 0cfb3760 2012-10-21 rsc case ClientMessage:
741 0cfb3760 2012-10-21 rsc return ("ClientMessage");
742 0cfb3760 2012-10-21 rsc case MappingNotify:
743 0cfb3760 2012-10-21 rsc return ("MappingNotify");
744 0cfb3760 2012-10-21 rsc }
745 0cfb3760 2012-10-21 rsc return "???";
746 0206bd51 2008-01-30 rsc }
747 0206bd51 2008-01-30 rsc
748 0206bd51 2008-01-30 rsc /******************************************************************************/
749 0206bd51 2008-01-30 rsc /**************** Print the values of all fields for any event ****************/
750 0206bd51 2008-01-30 rsc /******************************************************************************/
751 0206bd51 2008-01-30 rsc
752 0206bd51 2008-01-30 rsc void ShowEvent(XEvent *eev)
753 0206bd51 2008-01-30 rsc {
754 0cfb3760 2012-10-21 rsc XAnyEvent *ev = (XAnyEvent*)eev;
755 0cfb3760 2012-10-21 rsc /* determine which field separator to use */
756 0cfb3760 2012-10-21 rsc if (use_separate_lines)
757 0cfb3760 2012-10-21 rsc sep = "\n";
758 0cfb3760 2012-10-21 rsc else
759 0cfb3760 2012-10-21 rsc sep = " ";
760 0206bd51 2008-01-30 rsc
761 0cfb3760 2012-10-21 rsc printf("type=%s%s", GetType((XEvent*)ev), sep);
762 0cfb3760 2012-10-21 rsc printf("serial=%ld%s", ev->serial, sep);
763 0cfb3760 2012-10-21 rsc printf("send_event=%s%s", TorF(ev->send_event), sep);
764 63002b3e 2014-03-03 0intro printf("display=0x%p%s", ev->display, sep);
765 0206bd51 2008-01-30 rsc
766 0cfb3760 2012-10-21 rsc switch (ev->type) {
767 0cfb3760 2012-10-21 rsc case MotionNotify:
768 0cfb3760 2012-10-21 rsc VerbMotion((void*)ev);
769 0cfb3760 2012-10-21 rsc break;
770 0206bd51 2008-01-30 rsc
771 0cfb3760 2012-10-21 rsc case ButtonPress:
772 0cfb3760 2012-10-21 rsc case ButtonRelease:
773 0cfb3760 2012-10-21 rsc VerbButton((void*)ev);
774 0cfb3760 2012-10-21 rsc break;
775 0206bd51 2008-01-30 rsc
776 0cfb3760 2012-10-21 rsc case ColormapNotify:
777 0cfb3760 2012-10-21 rsc VerbColormap((void*)ev);
778 0cfb3760 2012-10-21 rsc break;
779 0206bd51 2008-01-30 rsc
780 0cfb3760 2012-10-21 rsc case EnterNotify:
781 0cfb3760 2012-10-21 rsc case LeaveNotify:
782 0cfb3760 2012-10-21 rsc VerbCrossing((void*)ev);
783 0cfb3760 2012-10-21 rsc break;
784 0206bd51 2008-01-30 rsc
785 0cfb3760 2012-10-21 rsc case Expose:
786 0cfb3760 2012-10-21 rsc VerbExpose((void*)ev);
787 0cfb3760 2012-10-21 rsc break;
788 0206bd51 2008-01-30 rsc
789 0cfb3760 2012-10-21 rsc case GraphicsExpose:
790 0cfb3760 2012-10-21 rsc VerbGraphicsExpose((void*)ev);
791 0cfb3760 2012-10-21 rsc break;
792 0206bd51 2008-01-30 rsc
793 0cfb3760 2012-10-21 rsc case NoExpose:
794 0cfb3760 2012-10-21 rsc VerbNoExpose((void*)ev);
795 0cfb3760 2012-10-21 rsc break;
796 0206bd51 2008-01-30 rsc
797 0cfb3760 2012-10-21 rsc case FocusIn:
798 0cfb3760 2012-10-21 rsc case FocusOut:
799 0cfb3760 2012-10-21 rsc VerbFocus((void*)ev);
800 0cfb3760 2012-10-21 rsc break;
801 0206bd51 2008-01-30 rsc
802 0cfb3760 2012-10-21 rsc case KeymapNotify:
803 0cfb3760 2012-10-21 rsc VerbKeymap((void*)ev);
804 0cfb3760 2012-10-21 rsc break;
805 0206bd51 2008-01-30 rsc
806 0cfb3760 2012-10-21 rsc case KeyPress:
807 0cfb3760 2012-10-21 rsc case KeyRelease:
808 0cfb3760 2012-10-21 rsc VerbKey((void*)ev);
809 0cfb3760 2012-10-21 rsc break;
810 0206bd51 2008-01-30 rsc
811 0cfb3760 2012-10-21 rsc case PropertyNotify:
812 0cfb3760 2012-10-21 rsc VerbProperty((void*)ev);
813 0cfb3760 2012-10-21 rsc break;
814 0206bd51 2008-01-30 rsc
815 0cfb3760 2012-10-21 rsc case ResizeRequest:
816 0cfb3760 2012-10-21 rsc VerbResizeRequest((void*)ev);
817 0cfb3760 2012-10-21 rsc break;
818 0206bd51 2008-01-30 rsc
819 0cfb3760 2012-10-21 rsc case CirculateNotify:
820 0cfb3760 2012-10-21 rsc VerbCirculate((void*)ev);
821 0cfb3760 2012-10-21 rsc break;
822 0206bd51 2008-01-30 rsc
823 0cfb3760 2012-10-21 rsc case ConfigureNotify:
824 0cfb3760 2012-10-21 rsc VerbConfigure((void*)ev);
825 0cfb3760 2012-10-21 rsc break;
826 0206bd51 2008-01-30 rsc
827 0cfb3760 2012-10-21 rsc case CreateNotify:
828 0cfb3760 2012-10-21 rsc VerbCreateWindow((void*)ev);
829 0cfb3760 2012-10-21 rsc break;
830 0206bd51 2008-01-30 rsc
831 0cfb3760 2012-10-21 rsc case DestroyNotify:
832 0cfb3760 2012-10-21 rsc VerbDestroyWindow((void*)ev);
833 0cfb3760 2012-10-21 rsc break;
834 0206bd51 2008-01-30 rsc
835 0cfb3760 2012-10-21 rsc case GravityNotify:
836 0cfb3760 2012-10-21 rsc VerbGravity((void*)ev);
837 0cfb3760 2012-10-21 rsc break;
838 0206bd51 2008-01-30 rsc
839 0cfb3760 2012-10-21 rsc case MapNotify:
840 0cfb3760 2012-10-21 rsc VerbMap((void*)ev);
841 0cfb3760 2012-10-21 rsc break;
842 0206bd51 2008-01-30 rsc
843 0cfb3760 2012-10-21 rsc case ReparentNotify:
844 0cfb3760 2012-10-21 rsc VerbReparent((void*)ev);
845 0cfb3760 2012-10-21 rsc break;
846 0206bd51 2008-01-30 rsc
847 0cfb3760 2012-10-21 rsc case UnmapNotify:
848 0cfb3760 2012-10-21 rsc VerbUnmap((void*)ev);
849 0cfb3760 2012-10-21 rsc break;
850 0206bd51 2008-01-30 rsc
851 0cfb3760 2012-10-21 rsc case CirculateRequest:
852 0cfb3760 2012-10-21 rsc VerbCirculateRequest((void*)ev);
853 0cfb3760 2012-10-21 rsc break;
854 0206bd51 2008-01-30 rsc
855 0cfb3760 2012-10-21 rsc case ConfigureRequest:
856 0cfb3760 2012-10-21 rsc VerbConfigureRequest((void*)ev);
857 0cfb3760 2012-10-21 rsc break;
858 0206bd51 2008-01-30 rsc
859 0cfb3760 2012-10-21 rsc case MapRequest:
860 0cfb3760 2012-10-21 rsc VerbMapRequest((void*)ev);
861 0cfb3760 2012-10-21 rsc break;
862 0206bd51 2008-01-30 rsc
863 0cfb3760 2012-10-21 rsc case ClientMessage:
864 0cfb3760 2012-10-21 rsc VerbClient((void*)ev);
865 0cfb3760 2012-10-21 rsc break;
866 0206bd51 2008-01-30 rsc
867 0cfb3760 2012-10-21 rsc case MappingNotify:
868 0cfb3760 2012-10-21 rsc VerbMapping((void*)ev);
869 0cfb3760 2012-10-21 rsc break;
870 0206bd51 2008-01-30 rsc
871 0cfb3760 2012-10-21 rsc case SelectionClear:
872 0cfb3760 2012-10-21 rsc VerbSelectionClear((void*)ev);
873 0cfb3760 2012-10-21 rsc break;
874 0206bd51 2008-01-30 rsc
875 0cfb3760 2012-10-21 rsc case SelectionNotify:
876 0cfb3760 2012-10-21 rsc VerbSelection((void*)ev);
877 0cfb3760 2012-10-21 rsc break;
878 0206bd51 2008-01-30 rsc
879 0cfb3760 2012-10-21 rsc case SelectionRequest:
880 0cfb3760 2012-10-21 rsc VerbSelectionRequest((void*)ev);
881 0cfb3760 2012-10-21 rsc break;
882 0206bd51 2008-01-30 rsc
883 0cfb3760 2012-10-21 rsc case VisibilityNotify:
884 0cfb3760 2012-10-21 rsc VerbVisibility((void*)ev);
885 0cfb3760 2012-10-21 rsc break;
886 0206bd51 2008-01-30 rsc
887 0cfb3760 2012-10-21 rsc }
888 0206bd51 2008-01-30 rsc }