1 0206bd51 2008-01-30 rsc #include <X11/Intrinsic.h>
2 0206bd51 2008-01-30 rsc #include <X11/Xproto.h>
4 0206bd51 2008-01-30 rsc Boolean use_separate_lines = True;
5 0206bd51 2008-01-30 rsc static char *sep;
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 /******************************************************************************/
11 0206bd51 2008-01-30 rsc /* Returns the string equivalent of a boolean parameter */
12 0206bd51 2008-01-30 rsc static char *TorF(bool)
15 0cfb3760 2012-10-21 rsc switch (bool) {
17 0cfb3760 2012-10-21 rsc return ("True");
20 0cfb3760 2012-10-21 rsc return ("False");
23 0cfb3760 2012-10-21 rsc return ("?");
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)
31 0cfb3760 2012-10-21 rsc switch (state) {
32 0cfb3760 2012-10-21 rsc case PropertyNewValue:
33 0cfb3760 2012-10-21 rsc return ("PropertyNewValue");
35 0cfb3760 2012-10-21 rsc case PropertyDelete:
36 0cfb3760 2012-10-21 rsc return ("PropertyDelete");
39 0cfb3760 2012-10-21 rsc return ("?");
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)
47 0cfb3760 2012-10-21 rsc switch (state) {
48 0cfb3760 2012-10-21 rsc case VisibilityUnobscured:
49 0cfb3760 2012-10-21 rsc return ("VisibilityUnobscured");
51 0cfb3760 2012-10-21 rsc case VisibilityPartiallyObscured:
52 0cfb3760 2012-10-21 rsc return ("VisibilityPartiallyObscured");
54 0cfb3760 2012-10-21 rsc case VisibilityFullyObscured:
55 0cfb3760 2012-10-21 rsc return ("VisibilityFullyObscured");
58 0cfb3760 2012-10-21 rsc return ("?");
62 0206bd51 2008-01-30 rsc /* Returns the string equivalent of a timestamp */
63 0206bd51 2008-01-30 rsc static char *ServerTime(time)
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];
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;
77 0cfb3760 2012-10-21 rsc min = time % 60;
79 0cfb3760 2012-10-21 rsc hr = time % 24;
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);
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;
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;
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"},
114 0cfb3760 2012-10-21 rsc int num_masks = sizeof(masks) / sizeof(MaskType);
116 0cfb3760 2012-10-21 rsc Boolean first = True;
118 0cfb3760 2012-10-21 rsc buffer[0] = 0;
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);
126 0cfb3760 2012-10-21 rsc strcat(buffer, " | ");
127 0cfb3760 2012-10-21 rsc strcat(buffer, masks[i].string);
129 0cfb3760 2012-10-21 rsc return (buffer);
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;
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"},
146 0cfb3760 2012-10-21 rsc int num_masks = sizeof(masks) / sizeof(MaskType);
148 0cfb3760 2012-10-21 rsc Boolean first = True;
150 0cfb3760 2012-10-21 rsc buffer[0] = 0;
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);
158 0cfb3760 2012-10-21 rsc strcat(buffer, " | ");
159 0cfb3760 2012-10-21 rsc strcat(buffer, masks[i].string);
162 0cfb3760 2012-10-21 rsc return (buffer);
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;
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");
173 0cfb3760 2012-10-21 rsc case NotifyHint:
174 0cfb3760 2012-10-21 rsc return ("NotifyHint");
177 0cfb3760 2012-10-21 rsc return ("?");
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)
185 0cfb3760 2012-10-21 rsc static char buffer[16];
187 0cfb3760 2012-10-21 rsc if (value == None)
188 0cfb3760 2012-10-21 rsc return ("None");
190 0cfb3760 2012-10-21 rsc sprintf(buffer, "0x%x", value);
191 0cfb3760 2012-10-21 rsc return (buffer);
195 0206bd51 2008-01-30 rsc /* Returns the string equivalent of a colormap state */
196 0206bd51 2008-01-30 rsc static char *ColormapState(state)
199 0cfb3760 2012-10-21 rsc switch (state) {
200 0cfb3760 2012-10-21 rsc case ColormapInstalled:
201 0cfb3760 2012-10-21 rsc return ("ColormapInstalled");
203 0cfb3760 2012-10-21 rsc case ColormapUninstalled:
204 0cfb3760 2012-10-21 rsc return ("ColormapUninstalled");
207 0cfb3760 2012-10-21 rsc return ("?");
211 0206bd51 2008-01-30 rsc /* Returns the string equivalent of a crossing detail */
212 0206bd51 2008-01-30 rsc static char *CrossingDetail(detail)
215 0cfb3760 2012-10-21 rsc switch (detail) {
216 0cfb3760 2012-10-21 rsc case NotifyAncestor:
217 0cfb3760 2012-10-21 rsc return ("NotifyAncestor");
219 0cfb3760 2012-10-21 rsc case NotifyInferior:
220 0cfb3760 2012-10-21 rsc return ("NotifyInferior");
222 0cfb3760 2012-10-21 rsc case NotifyVirtual:
223 0cfb3760 2012-10-21 rsc return ("NotifyVirtual");
225 0cfb3760 2012-10-21 rsc case NotifyNonlinear:
226 0cfb3760 2012-10-21 rsc return ("NotifyNonlinear");
228 0cfb3760 2012-10-21 rsc case NotifyNonlinearVirtual:
229 0cfb3760 2012-10-21 rsc return ("NotifyNonlinearVirtual");
232 0cfb3760 2012-10-21 rsc return ("?");
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)
240 0cfb3760 2012-10-21 rsc switch (detail) {
241 0cfb3760 2012-10-21 rsc case NotifyAncestor:
242 0cfb3760 2012-10-21 rsc return ("NotifyAncestor");
244 0cfb3760 2012-10-21 rsc case NotifyInferior:
245 0cfb3760 2012-10-21 rsc return ("NotifyInferior");
247 0cfb3760 2012-10-21 rsc case NotifyVirtual:
248 0cfb3760 2012-10-21 rsc return ("NotifyVirtual");
250 0cfb3760 2012-10-21 rsc case NotifyNonlinear:
251 0cfb3760 2012-10-21 rsc return ("NotifyNonlinear");
253 0cfb3760 2012-10-21 rsc case NotifyNonlinearVirtual:
254 0cfb3760 2012-10-21 rsc return ("NotifyNonlinearVirtual");
256 0cfb3760 2012-10-21 rsc case NotifyPointer:
257 0cfb3760 2012-10-21 rsc return ("NotifyPointer");
259 0cfb3760 2012-10-21 rsc case NotifyPointerRoot:
260 0cfb3760 2012-10-21 rsc return ("NotifyPointerRoot");
262 0cfb3760 2012-10-21 rsc case NotifyDetailNone:
263 0cfb3760 2012-10-21 rsc return ("NotifyDetailNone");
266 0cfb3760 2012-10-21 rsc return ("?");
270 0206bd51 2008-01-30 rsc /* Returns the string equivalent of a configure detail */
271 0206bd51 2008-01-30 rsc static char *ConfigureDetail(detail)
274 0cfb3760 2012-10-21 rsc switch (detail) {
276 0cfb3760 2012-10-21 rsc return ("Above");
279 0cfb3760 2012-10-21 rsc return ("Below");
282 0cfb3760 2012-10-21 rsc return ("TopIf");
284 0cfb3760 2012-10-21 rsc case BottomIf:
285 0cfb3760 2012-10-21 rsc return ("BottomIf");
287 0cfb3760 2012-10-21 rsc case Opposite:
288 0cfb3760 2012-10-21 rsc return ("Opposite");
291 0cfb3760 2012-10-21 rsc return ("?");
295 0206bd51 2008-01-30 rsc /* Returns the string equivalent of a grab mode */
296 0206bd51 2008-01-30 rsc static char *GrabMode(mode)
299 0cfb3760 2012-10-21 rsc switch (mode) {
300 0cfb3760 2012-10-21 rsc case NotifyNormal:
301 0cfb3760 2012-10-21 rsc return ("NotifyNormal");
303 0cfb3760 2012-10-21 rsc case NotifyGrab:
304 0cfb3760 2012-10-21 rsc return ("NotifyGrab");
306 0cfb3760 2012-10-21 rsc case NotifyUngrab:
307 0cfb3760 2012-10-21 rsc return ("NotifyUngrab");
309 0cfb3760 2012-10-21 rsc case NotifyWhileGrabbed:
310 0cfb3760 2012-10-21 rsc return ("NotifyWhileGrabbed");
313 0cfb3760 2012-10-21 rsc return ("?");
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;
321 0cfb3760 2012-10-21 rsc switch (request) {
322 0cfb3760 2012-10-21 rsc case MappingModifier:
323 0cfb3760 2012-10-21 rsc return ("MappingModifier");
325 0cfb3760 2012-10-21 rsc case MappingKeyboard:
326 0cfb3760 2012-10-21 rsc return ("MappingKeyboard");
328 0cfb3760 2012-10-21 rsc case MappingPointer:
329 0cfb3760 2012-10-21 rsc return ("MappingPointer");
332 0cfb3760 2012-10-21 rsc return ("?");
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)
340 0cfb3760 2012-10-21 rsc switch (place) {
341 0cfb3760 2012-10-21 rsc case PlaceOnTop:
342 0cfb3760 2012-10-21 rsc return ("PlaceOnTop");
344 0cfb3760 2012-10-21 rsc case PlaceOnBottom:
345 0cfb3760 2012-10-21 rsc return ("PlaceOnBottom");
348 0cfb3760 2012-10-21 rsc return ("?");
352 0206bd51 2008-01-30 rsc /* Returns the string equivalent of a major code */
353 0206bd51 2008-01-30 rsc static char *MajorCode(code)
356 0cfb3760 2012-10-21 rsc static char buffer[32];
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");
362 0cfb3760 2012-10-21 rsc case X_CopyPlane:
363 0cfb3760 2012-10-21 rsc return ("X_CopyPlane");
366 0cfb3760 2012-10-21 rsc sprintf(buffer, "0x%x", code);
367 0cfb3760 2012-10-21 rsc return (buffer);
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;
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];
380 0cfb3760 2012-10-21 rsc XLookupString(ev, string, 64, &keysym_str, NULL);
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);
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)
394 0cfb3760 2012-10-21 rsc static char buffer[256];
395 0cfb3760 2012-10-21 rsc char *atom_name;
397 0cfb3760 2012-10-21 rsc if (atom == None)
398 0cfb3760 2012-10-21 rsc return ("None");
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);
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 /******************************************************************************/
410 0206bd51 2008-01-30 rsc static void VerbMotion(XMotionEvent *ev)
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));
423 0206bd51 2008-01-30 rsc static void VerbButton(XButtonEvent *ev)
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));
436 0206bd51 2008-01-30 rsc static void VerbColormap(XColormapEvent *ev)
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));
444 0206bd51 2008-01-30 rsc static void VerbCrossing(XCrossingEvent *ev)
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));
459 0206bd51 2008-01-30 rsc static void VerbExpose(XExposeEvent *ev)
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);
467 0206bd51 2008-01-30 rsc static void VerbGraphicsExpose(XGraphicsExposeEvent *ev)
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);
476 0206bd51 2008-01-30 rsc static void VerbNoExpose(XNoExposeEvent *ev)
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);
483 0206bd51 2008-01-30 rsc static void VerbFocus(XFocusChangeEvent *ev)
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));
490 0206bd51 2008-01-30 rsc static void VerbKeymap(XKeymapEvent *ev)
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");
501 0206bd51 2008-01-30 rsc static void VerbKey(XKeyEvent *ev)
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));
514 0206bd51 2008-01-30 rsc static void VerbProperty(XPropertyEvent *ev)
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));
522 0206bd51 2008-01-30 rsc static void VerbResizeRequest(XResizeRequestEvent *ev)
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);
528 0206bd51 2008-01-30 rsc static void VerbCirculate(XCirculateEvent *ev)
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));
535 0206bd51 2008-01-30 rsc static void VerbConfigure(XConfigureEvent *ev)
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));
546 0206bd51 2008-01-30 rsc static void VerbCreateWindow(XCreateWindowEvent *ev)
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));
556 0206bd51 2008-01-30 rsc static void VerbDestroyWindow(XDestroyWindowEvent *ev)
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);
562 0206bd51 2008-01-30 rsc static void VerbGravity(XGravityEvent *ev)
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);
569 0206bd51 2008-01-30 rsc static void VerbMap(XMapEvent *ev)
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));
576 0206bd51 2008-01-30 rsc static void VerbReparent(XReparentEvent *ev)
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));
585 0206bd51 2008-01-30 rsc static void VerbUnmap(XUnmapEvent *ev)
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));
592 0206bd51 2008-01-30 rsc static void VerbCirculateRequest(XCirculateRequestEvent *ev)
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));
599 0206bd51 2008-01-30 rsc static void VerbConfigureRequest(XConfigureRequestEvent *ev)
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));
611 0206bd51 2008-01-30 rsc static void VerbMapRequest(XMapRequestEvent *ev)
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);
617 0206bd51 2008-01-30 rsc static void VerbClient(XClientMessageEvent *ev)
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");
630 0206bd51 2008-01-30 rsc static void VerbMapping(XMappingEvent *ev)
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);
638 0206bd51 2008-01-30 rsc static void VerbSelectionClear(XSelectionClearEvent *ev)
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));
645 0206bd51 2008-01-30 rsc static void VerbSelection(XSelectionEvent *ev)
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));
654 0206bd51 2008-01-30 rsc static void VerbSelectionRequest(XSelectionRequestEvent *ev)
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));
664 0206bd51 2008-01-30 rsc static void VerbVisibility(XVisibilityEvent *ev)
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));
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 /******************************************************************************/
674 0206bd51 2008-01-30 rsc char *GetType(ev)
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");
745 0cfb3760 2012-10-21 rsc return "???";
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 /******************************************************************************/
752 0206bd51 2008-01-30 rsc void ShowEvent(XEvent *eev)
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)
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);
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);
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);
776 0cfb3760 2012-10-21 rsc case ColormapNotify:
777 0cfb3760 2012-10-21 rsc VerbColormap((void*)ev);
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);
785 0cfb3760 2012-10-21 rsc case Expose:
786 0cfb3760 2012-10-21 rsc VerbExpose((void*)ev);
789 0cfb3760 2012-10-21 rsc case GraphicsExpose:
790 0cfb3760 2012-10-21 rsc VerbGraphicsExpose((void*)ev);
793 0cfb3760 2012-10-21 rsc case NoExpose:
794 0cfb3760 2012-10-21 rsc VerbNoExpose((void*)ev);
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);
802 0cfb3760 2012-10-21 rsc case KeymapNotify:
803 0cfb3760 2012-10-21 rsc VerbKeymap((void*)ev);
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);
811 0cfb3760 2012-10-21 rsc case PropertyNotify:
812 0cfb3760 2012-10-21 rsc VerbProperty((void*)ev);
815 0cfb3760 2012-10-21 rsc case ResizeRequest:
816 0cfb3760 2012-10-21 rsc VerbResizeRequest((void*)ev);
819 0cfb3760 2012-10-21 rsc case CirculateNotify:
820 0cfb3760 2012-10-21 rsc VerbCirculate((void*)ev);
823 0cfb3760 2012-10-21 rsc case ConfigureNotify:
824 0cfb3760 2012-10-21 rsc VerbConfigure((void*)ev);
827 0cfb3760 2012-10-21 rsc case CreateNotify:
828 0cfb3760 2012-10-21 rsc VerbCreateWindow((void*)ev);
831 0cfb3760 2012-10-21 rsc case DestroyNotify:
832 0cfb3760 2012-10-21 rsc VerbDestroyWindow((void*)ev);
835 0cfb3760 2012-10-21 rsc case GravityNotify:
836 0cfb3760 2012-10-21 rsc VerbGravity((void*)ev);
839 0cfb3760 2012-10-21 rsc case MapNotify:
840 0cfb3760 2012-10-21 rsc VerbMap((void*)ev);
843 0cfb3760 2012-10-21 rsc case ReparentNotify:
844 0cfb3760 2012-10-21 rsc VerbReparent((void*)ev);
847 0cfb3760 2012-10-21 rsc case UnmapNotify:
848 0cfb3760 2012-10-21 rsc VerbUnmap((void*)ev);
851 0cfb3760 2012-10-21 rsc case CirculateRequest:
852 0cfb3760 2012-10-21 rsc VerbCirculateRequest((void*)ev);
855 0cfb3760 2012-10-21 rsc case ConfigureRequest:
856 0cfb3760 2012-10-21 rsc VerbConfigureRequest((void*)ev);
859 0cfb3760 2012-10-21 rsc case MapRequest:
860 0cfb3760 2012-10-21 rsc VerbMapRequest((void*)ev);
863 0cfb3760 2012-10-21 rsc case ClientMessage:
864 0cfb3760 2012-10-21 rsc VerbClient((void*)ev);
867 0cfb3760 2012-10-21 rsc case MappingNotify:
868 0cfb3760 2012-10-21 rsc VerbMapping((void*)ev);
871 0cfb3760 2012-10-21 rsc case SelectionClear:
872 0cfb3760 2012-10-21 rsc VerbSelectionClear((void*)ev);
875 0cfb3760 2012-10-21 rsc case SelectionNotify:
876 0cfb3760 2012-10-21 rsc VerbSelection((void*)ev);
879 0cfb3760 2012-10-21 rsc case SelectionRequest:
880 0cfb3760 2012-10-21 rsc VerbSelectionRequest((void*)ev);
883 0cfb3760 2012-10-21 rsc case VisibilityNotify:
884 0cfb3760 2012-10-21 rsc VerbVisibility((void*)ev);