Blob


1 /*
2 * Original code posted to comp.sources.x
3 * Modifications by Russ Cox <rsc@swtch.com>.
4 */
6 /*
7 Path: uunet!wyse!mikew
8 From: mikew@wyse.wyse.com (Mike Wexler)
9 Newsgroups: comp.sources.x
10 Subject: v02i056: subroutine to print events in human readable form, Part01/01
11 Message-ID: <1935@wyse.wyse.com>
12 Date: 22 Dec 88 19:28:25 GMT
13 Organization: Wyse Technology, San Jose
14 Lines: 1093
15 Approved: mikew@wyse.com
17 Submitted-by: richsun!darkstar!ken
18 Posting-number: Volume 2, Issue 56
19 Archive-name: showevent/part01
22 There are times during debugging when it would be real useful to be able to
23 print the fields of an event in a human readable form. Too many times I found
24 myself scrounging around in section 8 of the Xlib manual looking for the valid
25 fields for the events I wanted to see, then adding printf's to display the
26 numeric values of the fields, and then scanning through X.h trying to decode
27 the cryptic detail and state fields. After playing with xev, I decided to
28 write a couple of standard functions that I could keep in a library and call
29 on whenever I needed a little debugging verbosity. The first function,
30 GetType(), is useful for returning the string representation of the type of
31 an event. The second function, ShowEvent(), is used to display all the fields
32 of an event in a readable format. The functions are not complicated, in fact,
33 they are mind-numbingly boring - but that's just the point nobody wants to
34 spend the time writing functions like this, they just want to have them when
35 they need them.
37 A simple, sample program is included which does little else but to demonstrate
38 the use of these two functions. These functions have saved me many an hour
39 during debugging and I hope you find some benefit to these. If you have any
40 comments, suggestions, improvements, or if you find any blithering errors you
41 can get it touch with me at the following location:
43 ken@richsun.UUCP
44 */
46 #include <stdio.h>
47 #include <X11/Intrinsic.h>
48 #include <X11/Xproto.h>
49 #include "printevent.h"
51 static char* sep = " ";
53 /******************************************************************************/
54 /**** Miscellaneous routines to convert values to their string equivalents ****/
55 /******************************************************************************/
57 /* Returns the string equivalent of a boolean parameter */
58 static char*
59 TorF(int bool)
60 {
61 switch (bool) {
62 case True:
63 return ("True");
65 case False:
66 return ("False");
68 default:
69 return ("?");
70 }
71 }
73 /* Returns the string equivalent of a property notify state */
74 static char*
75 PropertyState(int state)
76 {
77 switch (state) {
78 case PropertyNewValue:
79 return ("PropertyNewValue");
81 case PropertyDelete:
82 return ("PropertyDelete");
84 default:
85 return ("?");
86 }
87 }
89 /* Returns the string equivalent of a visibility notify state */
90 static char*
91 VisibilityState(int state)
92 {
93 switch (state) {
94 case VisibilityUnobscured:
95 return ("VisibilityUnobscured");
97 case VisibilityPartiallyObscured:
98 return ("VisibilityPartiallyObscured");
100 case VisibilityFullyObscured:
101 return ("VisibilityFullyObscured");
103 default:
104 return ("?");
108 /* Returns the string equivalent of a timestamp */
109 static char*
110 ServerTime(Time time)
112 unsigned long msec;
113 unsigned long sec;
114 unsigned long min;
115 unsigned long hr;
116 unsigned long day;
117 static char buffer[32];
119 msec = time % 1000;
120 time /= 1000;
121 sec = time % 60;
122 time /= 60;
123 min = time % 60;
124 time /= 60;
125 hr = time % 24;
126 time /= 24;
127 day = time;
129 if(0)
130 sprintf(buffer, "%lu day%s %02lu:%02lu:%02lu.%03lu",
131 day, day == 1 ? "" : "(s)", hr, min, sec, msec);
133 sprintf(buffer, "%lud%luh%lum%lu.%03lds", day, hr, min, sec, msec);
134 return (buffer);
137 /* Simple structure to ease the interpretation of masks */
138 typedef struct MaskType MaskType;
139 struct MaskType
141 unsigned int value;
142 char *string;
143 };
145 /* Returns the string equivalent of a mask of buttons and/or modifier keys */
146 static char*
147 ButtonAndOrModifierState(unsigned int state)
149 static char buffer[256];
150 static MaskType masks[] = {
151 {Button1Mask, "Button1Mask"},
152 {Button2Mask, "Button2Mask"},
153 {Button3Mask, "Button3Mask"},
154 {Button4Mask, "Button4Mask"},
155 {Button5Mask, "Button5Mask"},
156 {ShiftMask, "ShiftMask"},
157 {LockMask, "LockMask"},
158 {ControlMask, "ControlMask"},
159 {Mod1Mask, "Mod1Mask"},
160 {Mod2Mask, "Mod2Mask"},
161 {Mod3Mask, "Mod3Mask"},
162 {Mod4Mask, "Mod4Mask"},
163 {Mod5Mask, "Mod5Mask"},
164 };
165 int num_masks = sizeof(masks) / sizeof(MaskType);
166 int i;
167 Boolean first = True;
169 buffer[0] = 0;
171 for (i = 0; i < num_masks; i++)
172 if (state & masks[i].value)
173 if (first) {
174 first = False;
175 strcpy(buffer, masks[i].string);
176 } else {
177 strcat(buffer, " | ");
178 strcat(buffer, masks[i].string);
180 return (buffer);
183 /* Returns the string equivalent of a mask of configure window values */
184 static char*
185 ConfigureValueMask(unsigned int valuemask)
187 static char buffer[256];
188 static MaskType masks[] = {
189 {CWX, "CWX"},
190 {CWY, "CWY"},
191 {CWWidth, "CWWidth"},
192 {CWHeight, "CWHeight"},
193 {CWBorderWidth, "CWBorderWidth"},
194 {CWSibling, "CWSibling"},
195 {CWStackMode, "CWStackMode"},
196 };
197 int num_masks = sizeof(masks) / sizeof(MaskType);
198 int i;
199 Boolean first = True;
201 buffer[0] = 0;
203 for (i = 0; i < num_masks; i++)
204 if (valuemask & masks[i].value)
205 if (first) {
206 first = False;
207 strcpy(buffer, masks[i].string);
208 } else {
209 strcat(buffer, " | ");
210 strcat(buffer, masks[i].string);
213 return (buffer);
216 /* Returns the string equivalent of a motion hint */
217 static char*
218 IsHint(char is_hint)
220 switch (is_hint) {
221 case NotifyNormal:
222 return ("NotifyNormal");
224 case NotifyHint:
225 return ("NotifyHint");
227 default:
228 return ("?");
232 /* Returns the string equivalent of an id or the value "None" */
233 static char*
234 MaybeNone(int value)
236 static char buffer[16];
238 if (value == None)
239 return ("None");
240 else {
241 sprintf(buffer, "0x%x", value);
242 return (buffer);
246 /* Returns the string equivalent of a colormap state */
247 static char*
248 ColormapState(int state)
250 switch (state) {
251 case ColormapInstalled:
252 return ("ColormapInstalled");
254 case ColormapUninstalled:
255 return ("ColormapUninstalled");
257 default:
258 return ("?");
262 /* Returns the string equivalent of a crossing detail */
263 static char*
264 CrossingDetail(int detail)
266 switch (detail) {
267 case NotifyAncestor:
268 return ("NotifyAncestor");
270 case NotifyInferior:
271 return ("NotifyInferior");
273 case NotifyVirtual:
274 return ("NotifyVirtual");
276 case NotifyNonlinear:
277 return ("NotifyNonlinear");
279 case NotifyNonlinearVirtual:
280 return ("NotifyNonlinearVirtual");
282 default:
283 return ("?");
287 /* Returns the string equivalent of a focus change detail */
288 static char*
289 FocusChangeDetail(int detail)
291 switch (detail) {
292 case NotifyAncestor:
293 return ("NotifyAncestor");
295 case NotifyInferior:
296 return ("NotifyInferior");
298 case NotifyVirtual:
299 return ("NotifyVirtual");
301 case NotifyNonlinear:
302 return ("NotifyNonlinear");
304 case NotifyNonlinearVirtual:
305 return ("NotifyNonlinearVirtual");
307 case NotifyPointer:
308 return ("NotifyPointer");
310 case NotifyPointerRoot:
311 return ("NotifyPointerRoot");
313 case NotifyDetailNone:
314 return ("NotifyDetailNone");
316 default:
317 return ("?");
321 /* Returns the string equivalent of a configure detail */
322 static char*
323 ConfigureDetail(int detail)
325 switch (detail) {
326 case Above:
327 return ("Above");
329 case Below:
330 return ("Below");
332 case TopIf:
333 return ("TopIf");
335 case BottomIf:
336 return ("BottomIf");
338 case Opposite:
339 return ("Opposite");
341 default:
342 return ("?");
346 /* Returns the string equivalent of a grab mode */
347 static char*
348 GrabMode(int mode)
350 switch (mode) {
351 case NotifyNormal:
352 return ("NotifyNormal");
354 case NotifyGrab:
355 return ("NotifyGrab");
357 case NotifyUngrab:
358 return ("NotifyUngrab");
360 case NotifyWhileGrabbed:
361 return ("NotifyWhileGrabbed");
363 default:
364 return ("?");
368 /* Returns the string equivalent of a mapping request */
369 static char*
370 MappingRequest(int request)
372 switch (request) {
373 case MappingModifier:
374 return ("MappingModifier");
376 case MappingKeyboard:
377 return ("MappingKeyboard");
379 case MappingPointer:
380 return ("MappingPointer");
382 default:
383 return ("?");
387 /* Returns the string equivalent of a stacking order place */
388 static char*
389 Place(int place)
391 switch (place) {
392 case PlaceOnTop:
393 return ("PlaceOnTop");
395 case PlaceOnBottom:
396 return ("PlaceOnBottom");
398 default:
399 return ("?");
403 /* Returns the string equivalent of a major code */
404 static char*
405 MajorCode(int code)
407 static char buffer[32];
409 switch (code) {
410 case X_CopyArea:
411 return ("X_CopyArea");
413 case X_CopyPlane:
414 return ("X_CopyPlane");
416 default:
417 sprintf(buffer, "0x%x", code);
418 return (buffer);
422 /* Returns the string equivalent the keycode contained in the key event */
423 static char*
424 Keycode(XKeyEvent *ev)
426 static char buffer[256];
427 KeySym keysym_str;
428 char *keysym_name;
429 char string[256];
431 XLookupString(ev, string, 64, &keysym_str, NULL);
433 if (keysym_str == NoSymbol)
434 keysym_name = "NoSymbol";
435 else if (!(keysym_name = XKeysymToString(keysym_str)))
436 keysym_name = "(no name)";
437 sprintf(buffer, "%u (keysym 0x%x \"%s\")",
438 (int)ev->keycode, (int)keysym_str, keysym_name);
439 return (buffer);
442 /* Returns the string equivalent of an atom or "None"*/
443 static char*
444 AtomName(Display *dpy, Atom atom)
446 static char buffer[256];
447 char *atom_name;
449 if (atom == None)
450 return ("None");
452 atom_name = XGetAtomName(dpy, atom);
453 strncpy(buffer, atom_name, 256);
454 XFree(atom_name);
455 return (buffer);
458 /******************************************************************************/
459 /**** Routines to print out readable values for the field of various events ***/
460 /******************************************************************************/
462 static void
463 VerbMotion(XMotionEvent *ev)
465 printf("window=0x%x%s", (int)ev->window, sep);
466 printf("root=0x%x%s", (int)ev->root, sep);
467 printf("subwindow=0x%x%s", (int)ev->subwindow, sep);
468 printf("time=%s%s", ServerTime(ev->time), sep);
469 printf("x=%d y=%d%s", ev->x, ev->y, sep);
470 printf("x_root=%d y_root=%d%s", ev->x_root, ev->y_root, sep);
471 printf("state=%s%s", ButtonAndOrModifierState(ev->state), sep);
472 printf("is_hint=%s%s", IsHint(ev->is_hint), sep);
473 printf("same_screen=%s\n", TorF(ev->same_screen));
476 static void
477 VerbButton(XButtonEvent *ev)
479 printf("window=0x%x%s", (int)ev->window, sep);
480 printf("root=0x%x%s", (int)ev->root, sep);
481 printf("subwindow=0x%x%s", (int)ev->subwindow, sep);
482 printf("time=%s%s", ServerTime(ev->time), sep);
483 printf("x=%d y=%d%s", ev->x, ev->y, sep);
484 printf("x_root=%d y_root=%d%s", ev->x_root, ev->y_root, sep);
485 printf("state=%s%s", ButtonAndOrModifierState(ev->state), sep);
486 printf("button=%s%s", ButtonAndOrModifierState(ev->button), sep);
487 printf("same_screen=%s\n", TorF(ev->same_screen));
490 static void
491 VerbColormap(XColormapEvent *ev)
493 printf("window=0x%x%s", (int)ev->window, sep);
494 printf("colormap=%s%s", MaybeNone(ev->colormap), sep);
495 printf("new=%s%s", TorF(ev->new), sep);
496 printf("state=%s\n", ColormapState(ev->state));
499 static void
500 VerbCrossing(XCrossingEvent *ev)
502 printf("window=0x%x%s", (int)ev->window, sep);
503 printf("root=0x%x%s", (int)ev->root, sep);
504 printf("subwindow=0x%x%s", (int)ev->subwindow, sep);
505 printf("time=%s%s", ServerTime(ev->time), sep);
506 printf("x=%d y=%d%s", ev->x, ev->y, sep);
507 printf("x_root=%d y_root=%d%s", ev->x_root, ev->y_root, sep);
508 printf("mode=%s%s", GrabMode(ev->mode), sep);
509 printf("detail=%s%s", CrossingDetail(ev->detail), sep);
510 printf("same_screen=%s%s", TorF(ev->same_screen), sep);
511 printf("focus=%s%s", TorF(ev->focus), sep);
512 printf("state=%s\n", ButtonAndOrModifierState(ev->state));
515 static void
516 VerbExpose(XExposeEvent *ev)
518 printf("window=0x%x%s", (int)ev->window, sep);
519 printf("x=%d y=%d%s", ev->x, ev->y, sep);
520 printf("width=%d height=%d%s", ev->width, ev->height, sep);
521 printf("count=%d\n", ev->count);
524 static void
525 VerbGraphicsExpose(XGraphicsExposeEvent *ev)
527 printf("drawable=0x%x%s", (int)ev->drawable, sep);
528 printf("x=%d y=%d%s", ev->x, ev->y, sep);
529 printf("width=%d height=%d%s", ev->width, ev->height, sep);
530 printf("major_code=%s%s", MajorCode(ev->major_code), sep);
531 printf("minor_code=%d\n", ev->minor_code);
534 static void
535 VerbNoExpose(XNoExposeEvent *ev)
537 printf("drawable=0x%x%s", (int)ev->drawable, sep);
538 printf("major_code=%s%s", MajorCode(ev->major_code), sep);
539 printf("minor_code=%d\n", ev->minor_code);
542 static void
543 VerbFocus(XFocusChangeEvent *ev)
545 printf("window=0x%x%s", (int)ev->window, sep);
546 printf("mode=%s%s", GrabMode(ev->mode), sep);
547 printf("detail=%s\n", FocusChangeDetail(ev->detail));
550 static void
551 VerbKeymap(XKeymapEvent *ev)
553 int i;
555 printf("window=0x%x%s", (int)ev->window, sep);
556 printf("key_vector=");
557 for (i = 0; i < 32; i++)
558 printf("%02x", ev->key_vector[i]);
559 printf("\n");
562 static void
563 VerbKey(XKeyEvent *ev)
565 printf("window=0x%x%s", (int)ev->window, sep);
566 printf("root=0x%x%s", (int)ev->root, sep);
567 if(ev->subwindow)
568 printf("subwindow=0x%x%s", (int)ev->subwindow, sep);
569 printf("time=%s%s", ServerTime(ev->time), sep);
570 printf("[%d,%d]%s", ev->x, ev->y, sep);
571 printf("root=[%d,%d]%s", ev->x_root, ev->y_root, sep);
572 if(ev->state)
573 printf("state=%s%s", ButtonAndOrModifierState(ev->state), sep);
574 printf("keycode=%s%s", Keycode(ev), sep);
575 if(!ev->same_screen)
576 printf("!same_screen", TorF(ev->same_screen));
577 printf("\n");
578 return;
580 printf("window=0x%x%s", (int)ev->window, sep);
581 printf("root=0x%x%s", (int)ev->root, sep);
582 printf("subwindow=0x%x%s", (int)ev->subwindow, sep);
583 printf("time=%s%s", ServerTime(ev->time), sep);
584 printf("x=%d y=%d%s", ev->x, ev->y, sep);
585 printf("x_root=%d y_root=%d%s", ev->x_root, ev->y_root, sep);
586 printf("state=%s%s", ButtonAndOrModifierState(ev->state), sep);
587 printf("keycode=%s%s", Keycode(ev), sep);
588 printf("same_screen=%s\n", TorF(ev->same_screen));
591 static void
592 VerbProperty(XPropertyEvent *ev)
594 printf("window=0x%x%s", (int)ev->window, sep);
595 printf("atom=%s%s", AtomName(ev->display, ev->atom), sep);
596 printf("time=%s%s", ServerTime(ev->time), sep);
597 printf("state=%s\n", PropertyState(ev->state));
600 static void
601 VerbResizeRequest(XResizeRequestEvent *ev)
603 printf("window=0x%x%s", (int)ev->window, sep);
604 printf("width=%d height=%d\n", ev->width, ev->height);
607 static void
608 VerbCirculate(XCirculateEvent *ev)
610 printf("event=0x%x%s", (int)ev->event, sep);
611 printf("window=0x%x%s", (int)ev->window, sep);
612 printf("place=%s\n", Place(ev->place));
615 static void
616 VerbConfigure(XConfigureEvent *ev)
618 printf("event=0x%x%s", (int)ev->event, sep);
619 printf("window=0x%x%s", (int)ev->window, sep);
620 printf("x=%d y=%d%s", ev->x, ev->y, sep);
621 printf("width=%d height=%d%s", ev->width, ev->height, sep);
622 printf("border_width=%d%s", ev->border_width, sep);
623 printf("above=%s%s", MaybeNone(ev->above), sep);
624 printf("override_redirect=%s\n", TorF(ev->override_redirect));
627 static void
628 VerbCreateWindow(XCreateWindowEvent *ev)
630 printf("parent=0x%x%s", (int)ev->parent, sep);
631 printf("window=0x%x%s", (int)ev->window, sep);
632 printf("x=%d y=%d%s", ev->x, ev->y, sep);
633 printf("width=%d height=%d%s", ev->width, ev->height, sep);
634 printf("border_width=%d%s", ev->border_width, sep);
635 printf("override_redirect=%s\n", TorF(ev->override_redirect));
638 static void
639 VerbDestroyWindow(XDestroyWindowEvent *ev)
641 printf("event=0x%x%s", (int)ev->event, sep);
642 printf("window=0x%x\n", (int)ev->window);
645 static void
646 VerbGravity(XGravityEvent *ev)
648 printf("event=0x%x%s", (int)ev->event, sep);
649 printf("window=0x%x%s", (int)ev->window, sep);
650 printf("x=%d y=%d\n", ev->x, ev->y);
653 static void
654 VerbMap(XMapEvent *ev)
656 printf("event=0x%x%s", (int)ev->event, sep);
657 printf("window=0x%x%s", (int)ev->window, sep);
658 printf("override_redirect=%s\n", TorF(ev->override_redirect));
661 static void
662 VerbReparent(XReparentEvent *ev)
664 printf("event=0x%x%s", (int)ev->event, sep);
665 printf("window=0x%x%s", (int)ev->window, sep);
666 printf("parent=0x%x%s", (int)ev->parent, sep);
667 printf("x=%d y=%d%s", ev->x, ev->y, sep);
668 printf("override_redirect=%s\n", TorF(ev->override_redirect));
671 static void
672 VerbUnmap(XUnmapEvent *ev)
674 printf("event=0x%x%s", (int)ev->event, sep);
675 printf("window=0x%x%s", (int)ev->window, sep);
676 printf("from_configure=%s\n", TorF(ev->from_configure));
679 static void
680 VerbCirculateRequest(XCirculateRequestEvent *ev)
682 printf("parent=0x%x%s", (int)ev->parent, sep);
683 printf("window=0x%x%s", (int)ev->window, sep);
684 printf("place=%s\n", Place(ev->place));
687 static void
688 VerbConfigureRequest(XConfigureRequestEvent *ev)
690 printf("parent=0x%x%s", (int)ev->parent, sep);
691 printf("window=0x%x%s", (int)ev->window, sep);
692 printf("x=%d y=%d%s", ev->x, ev->y, sep);
693 printf("width=%d height=%d%s", ev->width, ev->height, sep);
694 printf("border_width=%d%s", ev->border_width, sep);
695 printf("above=%s%s", MaybeNone(ev->above), sep);
696 printf("detail=%s%s", ConfigureDetail(ev->detail), sep);
697 printf("value_mask=%s\n", ConfigureValueMask(ev->value_mask));
700 static void
701 VerbMapRequest(XMapRequestEvent *ev)
703 printf("parent=0x%x%s", (int)ev->parent, sep);
704 printf("window=0x%x\n", (int)ev->window);
707 static void
708 VerbClient(XClientMessageEvent *ev)
710 int i;
712 printf("window=0x%x%s", (int)ev->window, sep);
713 printf("message_type=%s%s", AtomName(ev->display, ev->message_type), sep);
714 printf("format=%d\n", ev->format);
715 printf("data (shown as longs)=");
716 for (i = 0; i < 5; i++)
717 printf(" 0x%08lx", ev->data.l[i]);
718 printf("\n");
721 static void
722 VerbMapping(XMappingEvent *ev)
724 printf("window=0x%x%s", (int)ev->window, sep);
725 printf("request=%s%s", MappingRequest(ev->request), sep);
726 printf("first_keycode=0x%x%s", ev->first_keycode, sep);
727 printf("count=0x%x\n", ev->count);
730 static void
731 VerbSelectionClear(XSelectionClearEvent *ev)
733 printf("window=0x%x%s", (int)ev->window, sep);
734 printf("selection=%s%s", AtomName(ev->display, ev->selection), sep);
735 printf("time=%s\n", ServerTime(ev->time));
738 static void
739 VerbSelection(XSelectionEvent *ev)
741 printf("requestor=0x%x%s", (int)ev->requestor, sep);
742 printf("selection=%s%s", AtomName(ev->display, ev->selection), sep);
743 printf("target=%s%s", AtomName(ev->display, ev->target), sep);
744 printf("property=%s%s", AtomName(ev->display, ev->property), sep);
745 printf("time=%s\n", ServerTime(ev->time));
748 static void
749 VerbSelectionRequest(XSelectionRequestEvent *ev)
751 printf("owner=0x%x%s", (int)ev->owner, sep);
752 printf("requestor=0x%x%s", (int)ev->requestor, sep);
753 printf("selection=%s%s", AtomName(ev->display, ev->selection), sep);
754 printf("target=%s%s", AtomName(ev->display, ev->target), sep);
755 printf("property=%s%s", AtomName(ev->display, ev->property), sep);
756 printf("time=%s\n", ServerTime(ev->time));
759 static void
760 VerbVisibility(XVisibilityEvent *ev)
762 printf("window=0x%x%s", (int)ev->window, sep);
763 printf("state=%s\n", VisibilityState(ev->state));
766 /******************************************************************************/
767 /************ Return the string representation for type of an event ***********/
768 /******************************************************************************/
770 char *eventtype(XEvent *ev)
772 static char buffer[20];
774 switch (ev->type) {
775 case KeyPress:
776 return ("KeyPress");
777 case KeyRelease:
778 return ("KeyRelease");
779 case ButtonPress:
780 return ("ButtonPress");
781 case ButtonRelease:
782 return ("ButtonRelease");
783 case MotionNotify:
784 return ("MotionNotify");
785 case EnterNotify:
786 return ("EnterNotify");
787 case LeaveNotify:
788 return ("LeaveNotify");
789 case FocusIn:
790 return ("FocusIn");
791 case FocusOut:
792 return ("FocusOut");
793 case KeymapNotify:
794 return ("KeymapNotify");
795 case Expose:
796 return ("Expose");
797 case GraphicsExpose:
798 return ("GraphicsExpose");
799 case NoExpose:
800 return ("NoExpose");
801 case VisibilityNotify:
802 return ("VisibilityNotify");
803 case CreateNotify:
804 return ("CreateNotify");
805 case DestroyNotify:
806 return ("DestroyNotify");
807 case UnmapNotify:
808 return ("UnmapNotify");
809 case MapNotify:
810 return ("MapNotify");
811 case MapRequest:
812 return ("MapRequest");
813 case ReparentNotify:
814 return ("ReparentNotify");
815 case ConfigureNotify:
816 return ("ConfigureNotify");
817 case ConfigureRequest:
818 return ("ConfigureRequest");
819 case GravityNotify:
820 return ("GravityNotify");
821 case ResizeRequest:
822 return ("ResizeRequest");
823 case CirculateNotify:
824 return ("CirculateNotify");
825 case CirculateRequest:
826 return ("CirculateRequest");
827 case PropertyNotify:
828 return ("PropertyNotify");
829 case SelectionClear:
830 return ("SelectionClear");
831 case SelectionRequest:
832 return ("SelectionRequest");
833 case SelectionNotify:
834 return ("SelectionNotify");
835 case ColormapNotify:
836 return ("ColormapNotify");
837 case ClientMessage:
838 return ("ClientMessage");
839 case MappingNotify:
840 return ("MappingNotify");
842 sprintf(buffer, "%d", ev->type);
843 return buffer;
846 /******************************************************************************/
847 /**************** Print the values of all fields for any event ****************/
848 /******************************************************************************/
850 void printevent(XEvent *e)
852 XAnyEvent *ev = (void*)e;
854 printf("%3ld %-20s ", ev->serial, eventtype(e));
855 if(ev->send_event)
856 printf("(sendevent) ");
857 if(0){
858 printf("type=%s%s", eventtype(e), sep);
859 printf("serial=%lu%s", ev->serial, sep);
860 printf("send_event=%s%s", TorF(ev->send_event), sep);
861 printf("display=0x%p%s", ev->display, sep);
864 switch (ev->type) {
865 case MotionNotify:
866 VerbMotion((void*)ev);
867 break;
869 case ButtonPress:
870 case ButtonRelease:
871 VerbButton((void*)ev);
872 break;
874 case ColormapNotify:
875 VerbColormap((void*)ev);
876 break;
878 case EnterNotify:
879 case LeaveNotify:
880 VerbCrossing((void*)ev);
881 break;
883 case Expose:
884 VerbExpose((void*)ev);
885 break;
887 case GraphicsExpose:
888 VerbGraphicsExpose((void*)ev);
889 break;
891 case NoExpose:
892 VerbNoExpose((void*)ev);
893 break;
895 case FocusIn:
896 case FocusOut:
897 VerbFocus((void*)ev);
898 break;
900 case KeymapNotify:
901 VerbKeymap((void*)ev);
902 break;
904 case KeyPress:
905 case KeyRelease:
906 VerbKey((void*)ev);
907 break;
909 case PropertyNotify:
910 VerbProperty((void*)ev);
911 break;
913 case ResizeRequest:
914 VerbResizeRequest((void*)ev);
915 break;
917 case CirculateNotify:
918 VerbCirculate((void*)ev);
919 break;
921 case ConfigureNotify:
922 VerbConfigure((void*)ev);
923 break;
925 case CreateNotify:
926 VerbCreateWindow((void*)ev);
927 break;
929 case DestroyNotify:
930 VerbDestroyWindow((void*)ev);
931 break;
933 case GravityNotify:
934 VerbGravity((void*)ev);
935 break;
937 case MapNotify:
938 VerbMap((void*)ev);
939 break;
941 case ReparentNotify:
942 VerbReparent((void*)ev);
943 break;
945 case UnmapNotify:
946 VerbUnmap((void*)ev);
947 break;
949 case CirculateRequest:
950 VerbCirculateRequest((void*)ev);
951 break;
953 case ConfigureRequest:
954 VerbConfigureRequest((void*)ev);
955 break;
957 case MapRequest:
958 VerbMapRequest((void*)ev);
959 break;
961 case ClientMessage:
962 VerbClient((void*)ev);
963 break;
965 case MappingNotify:
966 VerbMapping((void*)ev);
967 break;
969 case SelectionClear:
970 VerbSelectionClear((void*)ev);
971 break;
973 case SelectionNotify:
974 VerbSelection((void*)ev);
975 break;
977 case SelectionRequest:
978 VerbSelectionRequest((void*)ev);
979 break;
981 case VisibilityNotify:
982 VerbVisibility((void*)ev);
983 break;