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 0206bd51 2008-01-30 rsc switch (bool) {
17 0206bd51 2008-01-30 rsc return ("True");
20 0206bd51 2008-01-30 rsc return ("False");
23 0206bd51 2008-01-30 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 0206bd51 2008-01-30 rsc switch (state) {
32 0206bd51 2008-01-30 rsc case PropertyNewValue:
33 0206bd51 2008-01-30 rsc return ("PropertyNewValue");
35 0206bd51 2008-01-30 rsc case PropertyDelete:
36 0206bd51 2008-01-30 rsc return ("PropertyDelete");
39 0206bd51 2008-01-30 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 0206bd51 2008-01-30 rsc switch (state) {
48 0206bd51 2008-01-30 rsc case VisibilityUnobscured:
49 0206bd51 2008-01-30 rsc return ("VisibilityUnobscured");
51 0206bd51 2008-01-30 rsc case VisibilityPartiallyObscured:
52 0206bd51 2008-01-30 rsc return ("VisibilityPartiallyObscured");
54 0206bd51 2008-01-30 rsc case VisibilityFullyObscured:
55 0206bd51 2008-01-30 rsc return ("VisibilityFullyObscured");
58 0206bd51 2008-01-30 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 0206bd51 2008-01-30 rsc unsigned long msec;
67 0206bd51 2008-01-30 rsc unsigned long sec;
68 0206bd51 2008-01-30 rsc unsigned long min;
69 0206bd51 2008-01-30 rsc unsigned long hr;
70 0206bd51 2008-01-30 rsc unsigned long day;
71 0206bd51 2008-01-30 rsc static char buffer[32];
73 0206bd51 2008-01-30 rsc msec = time % 1000;
74 0206bd51 2008-01-30 rsc time /= 1000;
75 0206bd51 2008-01-30 rsc sec = time % 60;
77 0206bd51 2008-01-30 rsc min = time % 60;
79 0206bd51 2008-01-30 rsc hr = time % 24;
83 0206bd51 2008-01-30 rsc sprintf(buffer, "%ld day%s %02ld:%02ld:%02ld.%03ld",
84 0206bd51 2008-01-30 rsc day, day == 1 ? "" : "(s)", hr, min, sec, msec);
85 0206bd51 2008-01-30 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 0206bd51 2008-01-30 rsc unsigned int value;
91 0206bd51 2008-01-30 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 0206bd51 2008-01-30 rsc static char buffer[256];
99 0206bd51 2008-01-30 rsc static MaskType masks[] = {
100 0206bd51 2008-01-30 rsc {Button1Mask, "Button1Mask"},
101 0206bd51 2008-01-30 rsc {Button2Mask, "Button2Mask"},
102 0206bd51 2008-01-30 rsc {Button3Mask, "Button3Mask"},
103 0206bd51 2008-01-30 rsc {Button4Mask, "Button4Mask"},
104 0206bd51 2008-01-30 rsc {Button5Mask, "Button5Mask"},
105 0206bd51 2008-01-30 rsc {ShiftMask, "ShiftMask"},
106 0206bd51 2008-01-30 rsc {LockMask, "LockMask"},
107 0206bd51 2008-01-30 rsc {ControlMask, "ControlMask"},
108 0206bd51 2008-01-30 rsc {Mod1Mask, "Mod1Mask"},
109 0206bd51 2008-01-30 rsc {Mod2Mask, "Mod2Mask"},
110 0206bd51 2008-01-30 rsc {Mod3Mask, "Mod3Mask"},
111 0206bd51 2008-01-30 rsc {Mod4Mask, "Mod4Mask"},
112 0206bd51 2008-01-30 rsc {Mod5Mask, "Mod5Mask"},
114 0206bd51 2008-01-30 rsc int num_masks = sizeof(masks) / sizeof(MaskType);
116 0206bd51 2008-01-30 rsc Boolean first = True;
118 0206bd51 2008-01-30 rsc buffer[0] = 0;
120 0206bd51 2008-01-30 rsc for (i = 0; i < num_masks; i++)
121 0206bd51 2008-01-30 rsc if (state & masks[i].value)
122 0206bd51 2008-01-30 rsc if (first) {
123 0206bd51 2008-01-30 rsc first = False;
124 0206bd51 2008-01-30 rsc strcpy(buffer, masks[i].string);
126 0206bd51 2008-01-30 rsc strcat(buffer, " | ");
127 0206bd51 2008-01-30 rsc strcat(buffer, masks[i].string);
129 0206bd51 2008-01-30 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 0206bd51 2008-01-30 rsc static char buffer[256];
137 0206bd51 2008-01-30 rsc static MaskType masks[] = {
138 0206bd51 2008-01-30 rsc {CWX, "CWX"},
139 0206bd51 2008-01-30 rsc {CWY, "CWY"},
140 0206bd51 2008-01-30 rsc {CWWidth, "CWWidth"},
141 0206bd51 2008-01-30 rsc {CWHeight, "CWHeight"},
142 0206bd51 2008-01-30 rsc {CWBorderWidth, "CWBorderWidth"},
143 0206bd51 2008-01-30 rsc {CWSibling, "CWSibling"},
144 0206bd51 2008-01-30 rsc {CWStackMode, "CWStackMode"},
146 0206bd51 2008-01-30 rsc int num_masks = sizeof(masks) / sizeof(MaskType);
148 0206bd51 2008-01-30 rsc Boolean first = True;
150 0206bd51 2008-01-30 rsc buffer[0] = 0;
152 0206bd51 2008-01-30 rsc for (i = 0; i < num_masks; i++)
153 0206bd51 2008-01-30 rsc if (valuemask & masks[i].value)
154 0206bd51 2008-01-30 rsc if (first) {
155 0206bd51 2008-01-30 rsc first = False;
156 0206bd51 2008-01-30 rsc strcpy(buffer, masks[i].string);
158 0206bd51 2008-01-30 rsc strcat(buffer, " | ");
159 0206bd51 2008-01-30 rsc strcat(buffer, masks[i].string);
162 0206bd51 2008-01-30 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 0206bd51 2008-01-30 rsc switch (is_hint) {
170 0206bd51 2008-01-30 rsc case NotifyNormal:
171 0206bd51 2008-01-30 rsc return ("NotifyNormal");
173 0206bd51 2008-01-30 rsc case NotifyHint:
174 0206bd51 2008-01-30 rsc return ("NotifyHint");
177 0206bd51 2008-01-30 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 0206bd51 2008-01-30 rsc static char buffer[16];
187 0206bd51 2008-01-30 rsc if (value == None)
188 0206bd51 2008-01-30 rsc return ("None");
190 0206bd51 2008-01-30 rsc sprintf(buffer, "0x%x", value);
191 0206bd51 2008-01-30 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 0206bd51 2008-01-30 rsc switch (state) {
200 0206bd51 2008-01-30 rsc case ColormapInstalled:
201 0206bd51 2008-01-30 rsc return ("ColormapInstalled");
203 0206bd51 2008-01-30 rsc case ColormapUninstalled:
204 0206bd51 2008-01-30 rsc return ("ColormapUninstalled");
207 0206bd51 2008-01-30 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 0206bd51 2008-01-30 rsc switch (detail) {
216 0206bd51 2008-01-30 rsc case NotifyAncestor:
217 0206bd51 2008-01-30 rsc return ("NotifyAncestor");
219 0206bd51 2008-01-30 rsc case NotifyInferior:
220 0206bd51 2008-01-30 rsc return ("NotifyInferior");
222 0206bd51 2008-01-30 rsc case NotifyVirtual:
223 0206bd51 2008-01-30 rsc return ("NotifyVirtual");
225 0206bd51 2008-01-30 rsc case NotifyNonlinear:
226 0206bd51 2008-01-30 rsc return ("NotifyNonlinear");
228 0206bd51 2008-01-30 rsc case NotifyNonlinearVirtual:
229 0206bd51 2008-01-30 rsc return ("NotifyNonlinearVirtual");
232 0206bd51 2008-01-30 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 0206bd51 2008-01-30 rsc switch (detail) {
241 0206bd51 2008-01-30 rsc case NotifyAncestor:
242 0206bd51 2008-01-30 rsc return ("NotifyAncestor");
244 0206bd51 2008-01-30 rsc case NotifyInferior:
245 0206bd51 2008-01-30 rsc return ("NotifyInferior");
247 0206bd51 2008-01-30 rsc case NotifyVirtual:
248 0206bd51 2008-01-30 rsc return ("NotifyVirtual");
250 0206bd51 2008-01-30 rsc case NotifyNonlinear:
251 0206bd51 2008-01-30 rsc return ("NotifyNonlinear");
253 0206bd51 2008-01-30 rsc case NotifyNonlinearVirtual:
254 0206bd51 2008-01-30 rsc return ("NotifyNonlinearVirtual");
256 0206bd51 2008-01-30 rsc case NotifyPointer:
257 0206bd51 2008-01-30 rsc return ("NotifyPointer");
259 0206bd51 2008-01-30 rsc case NotifyPointerRoot:
260 0206bd51 2008-01-30 rsc return ("NotifyPointerRoot");
262 0206bd51 2008-01-30 rsc case NotifyDetailNone:
263 0206bd51 2008-01-30 rsc return ("NotifyDetailNone");
266 0206bd51 2008-01-30 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 0206bd51 2008-01-30 rsc switch (detail) {
276 0206bd51 2008-01-30 rsc return ("Above");
279 0206bd51 2008-01-30 rsc return ("Below");
282 0206bd51 2008-01-30 rsc return ("TopIf");
284 0206bd51 2008-01-30 rsc case BottomIf:
285 0206bd51 2008-01-30 rsc return ("BottomIf");
287 0206bd51 2008-01-30 rsc case Opposite:
288 0206bd51 2008-01-30 rsc return ("Opposite");
291 0206bd51 2008-01-30 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 0206bd51 2008-01-30 rsc switch (mode) {
300 0206bd51 2008-01-30 rsc case NotifyNormal:
301 0206bd51 2008-01-30 rsc return ("NotifyNormal");
303 0206bd51 2008-01-30 rsc case NotifyGrab:
304 0206bd51 2008-01-30 rsc return ("NotifyGrab");
306 0206bd51 2008-01-30 rsc case NotifyUngrab:
307 0206bd51 2008-01-30 rsc return ("NotifyUngrab");
309 0206bd51 2008-01-30 rsc case NotifyWhileGrabbed:
310 0206bd51 2008-01-30 rsc return ("NotifyWhileGrabbed");
313 0206bd51 2008-01-30 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 0206bd51 2008-01-30 rsc switch (request) {
322 0206bd51 2008-01-30 rsc case MappingModifier:
323 0206bd51 2008-01-30 rsc return ("MappingModifier");
325 0206bd51 2008-01-30 rsc case MappingKeyboard:
326 0206bd51 2008-01-30 rsc return ("MappingKeyboard");
328 0206bd51 2008-01-30 rsc case MappingPointer:
329 0206bd51 2008-01-30 rsc return ("MappingPointer");
332 0206bd51 2008-01-30 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 0206bd51 2008-01-30 rsc switch (place) {
341 0206bd51 2008-01-30 rsc case PlaceOnTop:
342 0206bd51 2008-01-30 rsc return ("PlaceOnTop");
344 0206bd51 2008-01-30 rsc case PlaceOnBottom:
345 0206bd51 2008-01-30 rsc return ("PlaceOnBottom");
348 0206bd51 2008-01-30 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 0206bd51 2008-01-30 rsc static char buffer[32];
358 0206bd51 2008-01-30 rsc switch (code) {
359 0206bd51 2008-01-30 rsc case X_CopyArea:
360 0206bd51 2008-01-30 rsc return ("X_CopyArea");
362 0206bd51 2008-01-30 rsc case X_CopyPlane:
363 0206bd51 2008-01-30 rsc return ("X_CopyPlane");
366 0206bd51 2008-01-30 rsc sprintf(buffer, "0x%x", code);
367 0206bd51 2008-01-30 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 0206bd51 2008-01-30 rsc static char buffer[256];
376 0206bd51 2008-01-30 rsc KeySym keysym_str;
377 0206bd51 2008-01-30 rsc char *keysym_name;
378 0206bd51 2008-01-30 rsc char string[256];
380 0206bd51 2008-01-30 rsc XLookupString(ev, string, 64, &keysym_str, NULL);
382 0206bd51 2008-01-30 rsc if (keysym_str == NoSymbol)
383 0206bd51 2008-01-30 rsc keysym_name = "NoSymbol";
384 0206bd51 2008-01-30 rsc else if (!(keysym_name = XKeysymToString(keysym_str)))
385 0206bd51 2008-01-30 rsc keysym_name = "(no name)";
386 0206bd51 2008-01-30 rsc sprintf(buffer, "%u (keysym 0x%x \"%s\")",
387 0206bd51 2008-01-30 rsc ev->keycode, (unsigned)keysym_str, keysym_name);
388 0206bd51 2008-01-30 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 0206bd51 2008-01-30 rsc static char buffer[256];
395 0206bd51 2008-01-30 rsc char *atom_name;
397 0206bd51 2008-01-30 rsc if (atom == None)
398 0206bd51 2008-01-30 rsc return ("None");
400 0206bd51 2008-01-30 rsc atom_name = XGetAtomName(dpy, atom);
401 0206bd51 2008-01-30 rsc strncpy(buffer, atom_name, 256);
402 0206bd51 2008-01-30 rsc XFree(atom_name);
403 0206bd51 2008-01-30 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 0206bd51 2008-01-30 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
413 0206bd51 2008-01-30 rsc printf("root=0x%x%s", (unsigned)ev->root, sep);
414 0206bd51 2008-01-30 rsc printf("subwindow=0x%x%s", (unsigned)ev->subwindow, sep);
415 0206bd51 2008-01-30 rsc printf("time=%s%s", ServerTime(ev->time), sep);
416 0206bd51 2008-01-30 rsc printf("x=%d y=%d%s", ev->x, ev->y, sep);
417 0206bd51 2008-01-30 rsc printf("x_root=%d y_root=%d%s", ev->x_root, ev->y_root, sep);
418 0206bd51 2008-01-30 rsc printf("state=%s%s", ButtonAndOrModifierState(ev->state), sep);
419 0206bd51 2008-01-30 rsc printf("is_hint=%s%s", IsHint(ev->is_hint), sep);
420 0206bd51 2008-01-30 rsc printf("same_screen=%s\n", TorF(ev->same_screen));
423 0206bd51 2008-01-30 rsc static void VerbButton(XButtonEvent *ev)
425 0206bd51 2008-01-30 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
426 0206bd51 2008-01-30 rsc printf("root=0x%x%s", (unsigned)ev->root, sep);
427 0206bd51 2008-01-30 rsc printf("subwindow=0x%x%s", (unsigned)ev->subwindow, sep);
428 0206bd51 2008-01-30 rsc printf("time=%s%s", ServerTime(ev->time), sep);
429 0206bd51 2008-01-30 rsc printf("x=%d y=%d%s", ev->x, ev->y, sep);
430 0206bd51 2008-01-30 rsc printf("x_root=%d y_root=%d%s", ev->x_root, ev->y_root, sep);
431 0206bd51 2008-01-30 rsc printf("state=%s%s", ButtonAndOrModifierState(ev->state), sep);
432 0206bd51 2008-01-30 rsc printf("button=%s%s", ButtonAndOrModifierState(ev->button), sep);
433 0206bd51 2008-01-30 rsc printf("same_screen=%s\n", TorF(ev->same_screen));
436 0206bd51 2008-01-30 rsc static void VerbColormap(XColormapEvent *ev)
438 0206bd51 2008-01-30 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
439 0206bd51 2008-01-30 rsc printf("colormap=%s%s", MaybeNone(ev->colormap), sep);
440 0206bd51 2008-01-30 rsc printf("new=%s%s", TorF(ev->new), sep);
441 0206bd51 2008-01-30 rsc printf("state=%s\n", ColormapState(ev->state));
444 0206bd51 2008-01-30 rsc static void VerbCrossing(XCrossingEvent *ev)
446 0206bd51 2008-01-30 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
447 0206bd51 2008-01-30 rsc printf("root=0x%x%s", (unsigned)ev->root, sep);
448 0206bd51 2008-01-30 rsc printf("subwindow=0x%x%s", (unsigned)ev->subwindow, sep);
449 0206bd51 2008-01-30 rsc printf("time=%s%s", ServerTime(ev->time), sep);
450 0206bd51 2008-01-30 rsc printf("x=%d y=%d%s", ev->x, ev->y, sep);
451 0206bd51 2008-01-30 rsc printf("x_root=%d y_root=%d%s", ev->x_root, ev->y_root, sep);
452 0206bd51 2008-01-30 rsc printf("mode=%s%s", GrabMode(ev->mode), sep);
453 0206bd51 2008-01-30 rsc printf("detail=%s%s", CrossingDetail(ev->detail), sep);
454 0206bd51 2008-01-30 rsc printf("same_screen=%s%s", TorF(ev->same_screen), sep);
455 0206bd51 2008-01-30 rsc printf("focus=%s%s", TorF(ev->focus), sep);
456 0206bd51 2008-01-30 rsc printf("state=%s\n", ButtonAndOrModifierState(ev->state));
459 0206bd51 2008-01-30 rsc static void VerbExpose(XExposeEvent *ev)
461 0206bd51 2008-01-30 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
462 0206bd51 2008-01-30 rsc printf("x=%d y=%d%s", ev->x, ev->y, sep);
463 0206bd51 2008-01-30 rsc printf("width=%d height=%d%s", ev->width, ev->height, sep);
464 0206bd51 2008-01-30 rsc printf("count=%d\n", ev->count);
467 0206bd51 2008-01-30 rsc static void VerbGraphicsExpose(XGraphicsExposeEvent *ev)
469 0206bd51 2008-01-30 rsc printf("drawable=0x%x%s", (unsigned)ev->drawable, sep);
470 0206bd51 2008-01-30 rsc printf("x=%d y=%d%s", ev->x, ev->y, sep);
471 0206bd51 2008-01-30 rsc printf("width=%d height=%d%s", ev->width, ev->height, sep);
472 0206bd51 2008-01-30 rsc printf("major_code=%s%s", MajorCode(ev->major_code), sep);
473 0206bd51 2008-01-30 rsc printf("minor_code=%d\n", ev->minor_code);
476 0206bd51 2008-01-30 rsc static void VerbNoExpose(XNoExposeEvent *ev)
478 0206bd51 2008-01-30 rsc printf("drawable=0x%x%s", (unsigned)ev->drawable, sep);
479 0206bd51 2008-01-30 rsc printf("major_code=%s%s", MajorCode(ev->major_code), sep);
480 0206bd51 2008-01-30 rsc printf("minor_code=%d\n", ev->minor_code);
483 0206bd51 2008-01-30 rsc static void VerbFocus(XFocusChangeEvent *ev)
485 0206bd51 2008-01-30 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
486 0206bd51 2008-01-30 rsc printf("mode=%s%s", GrabMode(ev->mode), sep);
487 0206bd51 2008-01-30 rsc printf("detail=%s\n", FocusChangeDetail(ev->detail));
490 0206bd51 2008-01-30 rsc static void VerbKeymap(XKeymapEvent *ev)
494 0206bd51 2008-01-30 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
495 0206bd51 2008-01-30 rsc printf("key_vector=");
496 0206bd51 2008-01-30 rsc for (i = 0; i < 32; i++)
497 0206bd51 2008-01-30 rsc printf("%02x", ev->key_vector[i]);
498 0206bd51 2008-01-30 rsc printf("\n");
501 0206bd51 2008-01-30 rsc static void VerbKey(XKeyEvent *ev)
503 0206bd51 2008-01-30 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
504 0206bd51 2008-01-30 rsc printf("root=0x%x%s", (unsigned)ev->root, sep);
505 0206bd51 2008-01-30 rsc printf("subwindow=0x%x%s", (unsigned)ev->subwindow, sep);
506 0206bd51 2008-01-30 rsc printf("time=%s%s", ServerTime(ev->time), sep);
507 0206bd51 2008-01-30 rsc printf("x=%d y=%d%s", ev->x, ev->y, sep);
508 0206bd51 2008-01-30 rsc printf("x_root=%d y_root=%d%s", ev->x_root, ev->y_root, sep);
509 0206bd51 2008-01-30 rsc printf("state=%s%s", ButtonAndOrModifierState(ev->state), sep);
510 0206bd51 2008-01-30 rsc printf("keycode=%s%s", Keycode(ev), sep);
511 0206bd51 2008-01-30 rsc printf("same_screen=%s\n", TorF(ev->same_screen));
514 0206bd51 2008-01-30 rsc static void VerbProperty(XPropertyEvent *ev)
516 0206bd51 2008-01-30 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
517 0206bd51 2008-01-30 rsc printf("atom=%s%s", AtomName(ev->display, ev->atom), sep);
518 0206bd51 2008-01-30 rsc printf("time=%s%s", ServerTime(ev->time), sep);
519 0206bd51 2008-01-30 rsc printf("state=%s\n", PropertyState(ev->state));
522 0206bd51 2008-01-30 rsc static void VerbResizeRequest(XResizeRequestEvent *ev)
524 0206bd51 2008-01-30 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
525 0206bd51 2008-01-30 rsc printf("width=%d height=%d\n", ev->width, ev->height);
528 0206bd51 2008-01-30 rsc static void VerbCirculate(XCirculateEvent *ev)
530 0206bd51 2008-01-30 rsc printf("event=0x%x%s", (unsigned)ev->event, sep);
531 0206bd51 2008-01-30 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
532 0206bd51 2008-01-30 rsc printf("place=%s\n", Place(ev->place));
535 0206bd51 2008-01-30 rsc static void VerbConfigure(XConfigureEvent *ev)
537 0206bd51 2008-01-30 rsc printf("event=0x%x%s", (unsigned)ev->event, sep);
538 0206bd51 2008-01-30 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
539 0206bd51 2008-01-30 rsc printf("x=%d y=%d%s", ev->x, ev->y, sep);
540 0206bd51 2008-01-30 rsc printf("width=%d height=%d%s", ev->width, ev->height, sep);
541 0206bd51 2008-01-30 rsc printf("border_width=%d%s", ev->border_width, sep);
542 0206bd51 2008-01-30 rsc printf("above=%s%s", MaybeNone(ev->above), sep);
543 0206bd51 2008-01-30 rsc printf("override_redirect=%s\n", TorF(ev->override_redirect));
546 0206bd51 2008-01-30 rsc static void VerbCreateWindow(XCreateWindowEvent *ev)
548 0206bd51 2008-01-30 rsc printf("parent=0x%x%s", (unsigned)ev->parent, sep);
549 0206bd51 2008-01-30 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
550 0206bd51 2008-01-30 rsc printf("x=%d y=%d%s", ev->x, ev->y, sep);
551 0206bd51 2008-01-30 rsc printf("width=%d height=%d%s", ev->width, ev->height, sep);
552 0206bd51 2008-01-30 rsc printf("border_width=%d%s", ev->border_width, sep);
553 0206bd51 2008-01-30 rsc printf("override_redirect=%s\n", TorF(ev->override_redirect));
556 0206bd51 2008-01-30 rsc static void VerbDestroyWindow(XDestroyWindowEvent *ev)
558 0206bd51 2008-01-30 rsc printf("event=0x%x%s", (unsigned)ev->event, sep);
559 0206bd51 2008-01-30 rsc printf("window=0x%x\n", (unsigned)ev->window);
562 0206bd51 2008-01-30 rsc static void VerbGravity(XGravityEvent *ev)
564 0206bd51 2008-01-30 rsc printf("event=0x%x%s", (unsigned)ev->event, sep);
565 0206bd51 2008-01-30 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
566 0206bd51 2008-01-30 rsc printf("x=%d y=%d\n", ev->x, ev->y);
569 0206bd51 2008-01-30 rsc static void VerbMap(XMapEvent *ev)
571 0206bd51 2008-01-30 rsc printf("event=0x%x%s", (unsigned)ev->event, sep);
572 0206bd51 2008-01-30 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
573 0206bd51 2008-01-30 rsc printf("override_redirect=%s\n", TorF(ev->override_redirect));
576 0206bd51 2008-01-30 rsc static void VerbReparent(XReparentEvent *ev)
578 0206bd51 2008-01-30 rsc printf("event=0x%x%s", (unsigned)ev->event, sep);
579 0206bd51 2008-01-30 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
580 0206bd51 2008-01-30 rsc printf("parent=0x%x%s", (unsigned)ev->parent, sep);
581 0206bd51 2008-01-30 rsc printf("x=%d y=%d%s", ev->x, ev->y, sep);
582 0206bd51 2008-01-30 rsc printf("override_redirect=%s\n", TorF(ev->override_redirect));
585 0206bd51 2008-01-30 rsc static void VerbUnmap(XUnmapEvent *ev)
587 0206bd51 2008-01-30 rsc printf("event=0x%x%s", (unsigned)ev->event, sep);
588 0206bd51 2008-01-30 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
589 0206bd51 2008-01-30 rsc printf("from_configure=%s\n", TorF(ev->from_configure));
592 0206bd51 2008-01-30 rsc static void VerbCirculateRequest(XCirculateRequestEvent *ev)
594 0206bd51 2008-01-30 rsc printf("parent=0x%x%s", (unsigned)ev->parent, sep);
595 0206bd51 2008-01-30 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
596 0206bd51 2008-01-30 rsc printf("place=%s\n", Place(ev->place));
599 0206bd51 2008-01-30 rsc static void VerbConfigureRequest(XConfigureRequestEvent *ev)
601 0206bd51 2008-01-30 rsc printf("parent=0x%x%s", (unsigned)ev->parent, sep);
602 0206bd51 2008-01-30 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
603 0206bd51 2008-01-30 rsc printf("x=%d y=%d%s", ev->x, ev->y, sep);
604 0206bd51 2008-01-30 rsc printf("width=%d height=%d%s", ev->width, ev->height, sep);
605 0206bd51 2008-01-30 rsc printf("border_width=%d%s", ev->border_width, sep);
606 0206bd51 2008-01-30 rsc printf("above=%s%s", MaybeNone(ev->above), sep);
607 0206bd51 2008-01-30 rsc printf("detail=%s%s", ConfigureDetail(ev->detail), sep);
608 0206bd51 2008-01-30 rsc printf("value_mask=%s\n", ConfigureValueMask(ev->value_mask));
611 0206bd51 2008-01-30 rsc static void VerbMapRequest(XMapRequestEvent *ev)
613 0206bd51 2008-01-30 rsc printf("parent=0x%x%s", (unsigned)ev->parent, sep);
614 0206bd51 2008-01-30 rsc printf("window=0x%x\n", (unsigned)ev->window);
617 0206bd51 2008-01-30 rsc static void VerbClient(XClientMessageEvent *ev)
621 0206bd51 2008-01-30 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
622 0206bd51 2008-01-30 rsc printf("message_type=%s%s", AtomName(ev->display, ev->message_type), sep);
623 0206bd51 2008-01-30 rsc printf("format=%d\n", ev->format);
624 0206bd51 2008-01-30 rsc printf("data (shown as longs)=");
625 0206bd51 2008-01-30 rsc for (i = 0; i < 5; i++)
626 0206bd51 2008-01-30 rsc printf(" 0x%08lx", ev->data.l[i]);
627 0206bd51 2008-01-30 rsc printf("\n");
630 0206bd51 2008-01-30 rsc static void VerbMapping(XMappingEvent *ev)
632 0206bd51 2008-01-30 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
633 0206bd51 2008-01-30 rsc printf("request=%s%s", MappingRequest(ev->request), sep);
634 0206bd51 2008-01-30 rsc printf("first_keycode=0x%x%s", ev->first_keycode, sep);
635 0206bd51 2008-01-30 rsc printf("count=0x%x\n", ev->count);
638 0206bd51 2008-01-30 rsc static void VerbSelectionClear(XSelectionClearEvent *ev)
640 0206bd51 2008-01-30 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
641 0206bd51 2008-01-30 rsc printf("selection=%s%s", AtomName(ev->display, ev->selection), sep);
642 0206bd51 2008-01-30 rsc printf("time=%s\n", ServerTime(ev->time));
645 0206bd51 2008-01-30 rsc static void VerbSelection(XSelectionEvent *ev)
647 0206bd51 2008-01-30 rsc printf("requestor=0x%x%s", (unsigned)ev->requestor, sep);
648 0206bd51 2008-01-30 rsc printf("selection=%s%s", AtomName(ev->display, ev->selection), sep);
649 0206bd51 2008-01-30 rsc printf("target=%s%s", AtomName(ev->display, ev->target), sep);
650 0206bd51 2008-01-30 rsc printf("property=%s%s", AtomName(ev->display, ev->property), sep);
651 0206bd51 2008-01-30 rsc printf("time=%s\n", ServerTime(ev->time));
654 0206bd51 2008-01-30 rsc static void VerbSelectionRequest(XSelectionRequestEvent *ev)
656 0206bd51 2008-01-30 rsc printf("owner=0x%x%s", (unsigned)ev->owner, sep);
657 0206bd51 2008-01-30 rsc printf("requestor=0x%x%s", (unsigned)ev->requestor, sep);
658 0206bd51 2008-01-30 rsc printf("selection=%s%s", AtomName(ev->display, ev->selection), sep);
659 0206bd51 2008-01-30 rsc printf("target=%s%s", AtomName(ev->display, ev->target), sep);
660 0206bd51 2008-01-30 rsc printf("property=%s%s", AtomName(ev->display, ev->property), sep);
661 0206bd51 2008-01-30 rsc printf("time=%s\n", ServerTime(ev->time));
664 0206bd51 2008-01-30 rsc static void VerbVisibility(XVisibilityEvent *ev)
666 0206bd51 2008-01-30 rsc printf("window=0x%x%s", (unsigned)ev->window, sep);
667 0206bd51 2008-01-30 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 0206bd51 2008-01-30 rsc switch (ev->type) {
678 0206bd51 2008-01-30 rsc case KeyPress:
679 0206bd51 2008-01-30 rsc return ("KeyPress");
680 0206bd51 2008-01-30 rsc case KeyRelease:
681 0206bd51 2008-01-30 rsc return ("KeyRelease");
682 0206bd51 2008-01-30 rsc case ButtonPress:
683 0206bd51 2008-01-30 rsc return ("ButtonPress");
684 0206bd51 2008-01-30 rsc case ButtonRelease:
685 0206bd51 2008-01-30 rsc return ("ButtonRelease");
686 0206bd51 2008-01-30 rsc case MotionNotify:
687 0206bd51 2008-01-30 rsc return ("MotionNotify");
688 0206bd51 2008-01-30 rsc case EnterNotify:
689 0206bd51 2008-01-30 rsc return ("EnterNotify");
690 0206bd51 2008-01-30 rsc case LeaveNotify:
691 0206bd51 2008-01-30 rsc return ("LeaveNotify");
692 0206bd51 2008-01-30 rsc case FocusIn:
693 0206bd51 2008-01-30 rsc return ("FocusIn");
694 0206bd51 2008-01-30 rsc case FocusOut:
695 0206bd51 2008-01-30 rsc return ("FocusOut");
696 0206bd51 2008-01-30 rsc case KeymapNotify:
697 0206bd51 2008-01-30 rsc return ("KeymapNotify");
698 0206bd51 2008-01-30 rsc case Expose:
699 0206bd51 2008-01-30 rsc return ("Expose");
700 0206bd51 2008-01-30 rsc case GraphicsExpose:
701 0206bd51 2008-01-30 rsc return ("GraphicsExpose");
702 0206bd51 2008-01-30 rsc case NoExpose:
703 0206bd51 2008-01-30 rsc return ("NoExpose");
704 0206bd51 2008-01-30 rsc case VisibilityNotify:
705 0206bd51 2008-01-30 rsc return ("VisibilityNotify");
706 0206bd51 2008-01-30 rsc case CreateNotify:
707 0206bd51 2008-01-30 rsc return ("CreateNotify");
708 0206bd51 2008-01-30 rsc case DestroyNotify:
709 0206bd51 2008-01-30 rsc return ("DestroyNotify");
710 0206bd51 2008-01-30 rsc case UnmapNotify:
711 0206bd51 2008-01-30 rsc return ("UnmapNotify");
712 0206bd51 2008-01-30 rsc case MapNotify:
713 0206bd51 2008-01-30 rsc return ("MapNotify");
714 0206bd51 2008-01-30 rsc case MapRequest:
715 0206bd51 2008-01-30 rsc return ("MapRequest");
716 0206bd51 2008-01-30 rsc case ReparentNotify:
717 0206bd51 2008-01-30 rsc return ("ReparentNotify");
718 0206bd51 2008-01-30 rsc case ConfigureNotify:
719 0206bd51 2008-01-30 rsc return ("ConfigureNotify");
720 0206bd51 2008-01-30 rsc case ConfigureRequest:
721 0206bd51 2008-01-30 rsc return ("ConfigureRequest");
722 0206bd51 2008-01-30 rsc case GravityNotify:
723 0206bd51 2008-01-30 rsc return ("GravityNotify");
724 0206bd51 2008-01-30 rsc case ResizeRequest:
725 0206bd51 2008-01-30 rsc return ("ResizeRequest");
726 0206bd51 2008-01-30 rsc case CirculateNotify:
727 0206bd51 2008-01-30 rsc return ("CirculateNotify");
728 0206bd51 2008-01-30 rsc case CirculateRequest:
729 0206bd51 2008-01-30 rsc return ("CirculateRequest");
730 0206bd51 2008-01-30 rsc case PropertyNotify:
731 0206bd51 2008-01-30 rsc return ("PropertyNotify");
732 0206bd51 2008-01-30 rsc case SelectionClear:
733 0206bd51 2008-01-30 rsc return ("SelectionClear");
734 0206bd51 2008-01-30 rsc case SelectionRequest:
735 0206bd51 2008-01-30 rsc return ("SelectionRequest");
736 0206bd51 2008-01-30 rsc case SelectionNotify:
737 0206bd51 2008-01-30 rsc return ("SelectionNotify");
738 0206bd51 2008-01-30 rsc case ColormapNotify:
739 0206bd51 2008-01-30 rsc return ("ColormapNotify");
740 0206bd51 2008-01-30 rsc case ClientMessage:
741 0206bd51 2008-01-30 rsc return ("ClientMessage");
742 0206bd51 2008-01-30 rsc case MappingNotify:
743 0206bd51 2008-01-30 rsc return ("MappingNotify");
745 0206bd51 2008-01-30 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 0206bd51 2008-01-30 rsc XAnyEvent *ev = (XAnyEvent*)eev;
755 0206bd51 2008-01-30 rsc /* determine which field separator to use */
756 0206bd51 2008-01-30 rsc if (use_separate_lines)
761 0206bd51 2008-01-30 rsc printf("type=%s%s", GetType(ev), sep);
762 0206bd51 2008-01-30 rsc printf("serial=%ld%s", ev->serial, sep);
763 0206bd51 2008-01-30 rsc printf("send_event=%s%s", TorF(ev->send_event), sep);
764 0206bd51 2008-01-30 rsc printf("display=0x%x%s", (unsigned)ev->display, sep);
766 0206bd51 2008-01-30 rsc switch (ev->type) {
767 0206bd51 2008-01-30 rsc case MotionNotify:
768 0206bd51 2008-01-30 rsc VerbMotion((void*)ev);
771 0206bd51 2008-01-30 rsc case ButtonPress:
772 0206bd51 2008-01-30 rsc case ButtonRelease:
773 0206bd51 2008-01-30 rsc VerbButton((void*)ev);
776 0206bd51 2008-01-30 rsc case ColormapNotify:
777 0206bd51 2008-01-30 rsc VerbColormap((void*)ev);
780 0206bd51 2008-01-30 rsc case EnterNotify:
781 0206bd51 2008-01-30 rsc case LeaveNotify:
782 0206bd51 2008-01-30 rsc VerbCrossing((void*)ev);
785 0206bd51 2008-01-30 rsc case Expose:
786 0206bd51 2008-01-30 rsc VerbExpose((void*)ev);
789 0206bd51 2008-01-30 rsc case GraphicsExpose:
790 0206bd51 2008-01-30 rsc VerbGraphicsExpose((void*)ev);
793 0206bd51 2008-01-30 rsc case NoExpose:
794 0206bd51 2008-01-30 rsc VerbNoExpose((void*)ev);
797 0206bd51 2008-01-30 rsc case FocusIn:
798 0206bd51 2008-01-30 rsc case FocusOut:
799 0206bd51 2008-01-30 rsc VerbFocus((void*)ev);
802 0206bd51 2008-01-30 rsc case KeymapNotify:
803 0206bd51 2008-01-30 rsc VerbKeymap((void*)ev);
806 0206bd51 2008-01-30 rsc case KeyPress:
807 0206bd51 2008-01-30 rsc case KeyRelease:
808 0206bd51 2008-01-30 rsc VerbKey((void*)ev);
811 0206bd51 2008-01-30 rsc case PropertyNotify:
812 0206bd51 2008-01-30 rsc VerbProperty((void*)ev);
815 0206bd51 2008-01-30 rsc case ResizeRequest:
816 0206bd51 2008-01-30 rsc VerbResizeRequest((void*)ev);
819 0206bd51 2008-01-30 rsc case CirculateNotify:
820 0206bd51 2008-01-30 rsc VerbCirculate((void*)ev);
823 0206bd51 2008-01-30 rsc case ConfigureNotify:
824 0206bd51 2008-01-30 rsc VerbConfigure((void*)ev);
827 0206bd51 2008-01-30 rsc case CreateNotify:
828 0206bd51 2008-01-30 rsc VerbCreateWindow((void*)ev);
831 0206bd51 2008-01-30 rsc case DestroyNotify:
832 0206bd51 2008-01-30 rsc VerbDestroyWindow((void*)ev);
835 0206bd51 2008-01-30 rsc case GravityNotify:
836 0206bd51 2008-01-30 rsc VerbGravity((void*)ev);
839 0206bd51 2008-01-30 rsc case MapNotify:
840 0206bd51 2008-01-30 rsc VerbMap((void*)ev);
843 0206bd51 2008-01-30 rsc case ReparentNotify:
844 0206bd51 2008-01-30 rsc VerbReparent((void*)ev);
847 0206bd51 2008-01-30 rsc case UnmapNotify:
848 0206bd51 2008-01-30 rsc VerbUnmap((void*)ev);
851 0206bd51 2008-01-30 rsc case CirculateRequest:
852 0206bd51 2008-01-30 rsc VerbCirculateRequest((void*)ev);
855 0206bd51 2008-01-30 rsc case ConfigureRequest:
856 0206bd51 2008-01-30 rsc VerbConfigureRequest((void*)ev);
859 0206bd51 2008-01-30 rsc case MapRequest:
860 0206bd51 2008-01-30 rsc VerbMapRequest((void*)ev);
863 0206bd51 2008-01-30 rsc case ClientMessage:
864 0206bd51 2008-01-30 rsc VerbClient((void*)ev);
867 0206bd51 2008-01-30 rsc case MappingNotify:
868 0206bd51 2008-01-30 rsc VerbMapping((void*)ev);
871 0206bd51 2008-01-30 rsc case SelectionClear:
872 0206bd51 2008-01-30 rsc VerbSelectionClear((void*)ev);
875 0206bd51 2008-01-30 rsc case SelectionNotify:
876 0206bd51 2008-01-30 rsc VerbSelection((void*)ev);
879 0206bd51 2008-01-30 rsc case SelectionRequest:
880 0206bd51 2008-01-30 rsc VerbSelectionRequest((void*)ev);
883 0206bd51 2008-01-30 rsc case VisibilityNotify:
884 0206bd51 2008-01-30 rsc VerbVisibility((void*)ev);