1 /**************************************************************************
5 Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
7 Contact: Boram Park <boram1288.park@samsung.com>
8 Sangjin LEE <lsj119@samsung.com>
10 Permission is hereby granted, free of charge, to any person obtaining a
11 copy of this software and associated documentation files (the
12 "Software"), to deal in the Software without restriction, including
13 without limitation the rights to use, copy, modify, merge, publish,
14 distribute, sub license, and/or sell copies of the Software, and to
15 permit persons to whom the Software is furnished to do so, subject to
16 the following conditions:
18 The above copyright notice and this permission notice (including the
19 next paragraph) shall be included in all copies or substantial portions
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
25 IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
26 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
27 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
28 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 **************************************************************************/
39 #include <sys/types.h>
40 #include <sys/fcntl.h>
51 #include <X11/Xatom.h>
53 #include <windowstr.h>
54 #include <X11/Xproto.h>
55 #include <X11/extensions/XI2proto.h>
57 #include "xdbg_types.h"
58 #include "xdbg_evlog_core.h"
59 #include "xdbg_evlog.h"
63 _getWindowAttributeMask (CARD32 mask, char *reply, int *len)
68 for (i = 0 ; i < sizeof(mask) * 4 ; i++)
79 case CWBackPixmap: REPLY("CWBackPixmap"); break;
80 case CWBackPixel: REPLY("CWBackPixel"); break;
81 case CWBorderPixmap: REPLY("CWBorderPixmap"); break;
82 case CWBorderPixel: REPLY("CWBorderPixel"); break;
83 case CWBitGravity: REPLY("CWBitGravity"); break;
84 case CWWinGravity: REPLY("CWWinGravity"); break;
85 case CWBackingStore: REPLY("CWBackingStore"); break;
86 case CWBackingPlanes: REPLY("CWBackingPlanes"); break;
87 case CWBackingPixel: REPLY("CWBackingPixel"); break;
88 case CWOverrideRedirect: REPLY("CWOverrideRedirect"); break;
89 case CWSaveUnder: REPLY("CWSaveUnder"); break;
90 case CWEventMask: REPLY("CWEventMask"); break;
91 case CWDontPropagate: REPLY("CWDontPropagate"); break;
92 case CWColormap: REPLY("CWColormap"); break;
93 case CWCursor: REPLY("CWCursor"); break;
101 #define GET_INT16(m, f) \
104 f = (INT16) *pVlist;\
107 #define GET_CARD16(m, f) \
110 f = (CARD16) *pVlist;\
114 #define GET_CARD8(m, f) \
117 f = (CARD8) *pVlist;\
122 _getConfigureWindowMask (CARD16 mask, char *reply, int *len, XID *vlist)
127 unsigned short w=0, h=0;
134 if ((mask & (CWX | CWY)) && (!(mask & (CWHeight | CWWidth)))) {
138 /* or should be resized */
139 else if (mask & (CWX | CWY | CWWidth | CWHeight)) {
142 GET_CARD16(CWWidth, w);
143 GET_CARD16(CWHeight, h);
147 for (i = 0 ; i < sizeof(mask) * 4 ; i++)
160 case CWX: REPLY("CWX:%d",x); break;
161 case CWY: REPLY("CWY:%d",y); break;
162 case CWWidth: REPLY("CWWidth:%d",w); break;
163 case CWHeight: REPLY("CWHeight:%d",h); break;
164 case CWBorderWidth: REPLY("CWBorderWidth"); break;
165 case CWSibling: REPLY("CWSibling"); break;
166 case CWStackMode: REPLY("CWStackMode"); break;
173 case CWX: REPLY("CWX"); break;
174 case CWY: REPLY("CWY"); break;
175 case CWWidth: REPLY("CWWidth"); break;
176 case CWHeight: REPLY("CWHeight"); break;
177 case CWBorderWidth: REPLY("CWBorderWidth"); break;
178 case CWSibling: REPLY("CWSibling"); break;
179 case CWStackMode: REPLY("CWStackMode"); break;
189 _getKeyMask (CARD16 mask, char *reply, int *len)
194 for (i = 0 ; i < sizeof(mask) * 4 ; i++)
205 case ShiftMask: REPLY("ShiftMask"); break;
206 case LockMask: REPLY("LockMask"); break;
207 case ControlMask: REPLY("ControlMask"); break;
208 case Mod1Mask: REPLY("Mod1Mask"); break;
209 case Mod2Mask: REPLY("Mod2Mask"); break;
210 case Mod3Mask: REPLY("Mod3Mask"); break;
211 case Mod4Mask: REPLY("Mod4Mask"); break;
212 case Mod5Mask: REPLY("Mod5Mask"); break;
213 case Button1Mask: REPLY("Button1Mask"); break;
214 case Button2Mask: REPLY("Button2Mask"); break;
215 case Button3Mask: REPLY("Button3Mask"); break;
216 case Button4Mask: REPLY("Button4Mask"); break;
217 case Button5Mask: REPLY("Button5Mask"); break;
218 case AnyModifier: REPLY("AnyModifier"); break;
227 _getEventMask (CARD32 mask, char *reply, int *len)
232 for (i = 0 ; i < sizeof(mask) * 4 ; i++)
243 case NoEventMask: REPLY("NoEventMask"); break;
244 case KeyPressMask: REPLY("KeyPressMask"); break;
245 case KeyReleaseMask: REPLY("KeyReleaseMask"); break;
246 case ButtonPressMask: REPLY("ButtonPressMask"); break;
247 case ButtonReleaseMask: REPLY("ButtonReleaseMask"); break;
248 case EnterWindowMask: REPLY("EnterWindowMask"); break;
249 case LeaveWindowMask: REPLY("LeaveWindowMask"); break;
250 case PointerMotionMask: REPLY("PointerMotionMask"); break;
251 case PointerMotionHintMask: REPLY("PointerMotionHintMask"); break;
252 case Button1MotionMask: REPLY("Button1MotionMask"); break;
253 case Button2MotionMask: REPLY("Button2MotionMask"); break;
254 case Button3MotionMask: REPLY("Button3MotionMask"); break;
255 case Button4MotionMask: REPLY("Button4MotionMask"); break;
256 case Button5MotionMask: REPLY("Button5MotionMask"); break;
257 case ButtonMotionMask: REPLY("ButtonMotionMask"); break;
258 case KeymapStateMask: REPLY("KeymapStateMask"); break;
259 case ExposureMask: REPLY("ExposureMask"); break;
260 case VisibilityChangeMask: REPLY("VisibilityChangeMask"); break;
261 case StructureNotifyMask: REPLY("StructureNotifyMask"); break;
262 case ResizeRedirectMask: REPLY("ResizeRedirectMask"); break;
263 case SubstructureNotifyMask: REPLY("SubstructureNotifyMask"); break;
264 case SubstructureRedirectMask: REPLY("SubstructureRedirectMask"); break;
265 case FocusChangeMask: REPLY("FocusChangeMask"); break;
266 case PropertyChangeMask: REPLY("PropertyChangeMask"); break;
267 case ColormapChangeMask: REPLY("ColormapChangeMask"); break;
268 case OwnerGrabButtonMask: REPLY("OwnerGrabButtonMask"); break;
276 char * xDbgEvlogRequestCore (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
278 xReq *req = evinfo->req.ptr;
280 switch (req->reqType)
284 xCreateWindowReq *stuff = (xCreateWindowReq *)req;
286 REPLY (": Window(0x%x) Parent(0x%x) size(%dx%d) boaderWid(%d) coordinate(%d,%d)",
287 (unsigned int)stuff->wid,
288 (unsigned int)stuff->parent,
295 if (detail_level >= EVLOG_PRINT_DETAIL)
297 const char *visual, *class;
298 char dvisual[10], dclass[10];
300 switch (stuff->visual)
302 case CopyFromParent: visual = "CopyFromParent"; break;
303 default: visual = dvisual; snprintf (dvisual, 10, "0x%x", (unsigned int)stuff->visual); break;
306 switch (stuff->class)
308 case CopyFromParent: class = "CopyFromParent"; break;
309 case InputOutput: class = "InputOutput"; break;
310 case InputOnly: class = "InputOnly"; break;
311 default: class = dclass; snprintf (dclass, 10, "0x%x", stuff->class); break;
315 REPLY ("%67s depth(%d) visual_ID(%s) class(%s)\n",
321 \r REPLY ("%67s mask", " ");
323 reply = _getWindowAttributeMask(stuff->mask, reply, len);
330 case X_ChangeWindowAttributes:
332 xChangeWindowAttributesReq *stuff = (xChangeWindowAttributesReq *)req;
333 REPLY (": XID(0x%x)", (unsigned int)stuff->window);
335 if (detail_level >= EVLOG_PRINT_DETAIL)
337 \r REPLY (" detail");
339 reply = _getWindowAttributeMask(stuff->valueMask, reply, len);
340 if (stuff->valueMask == CWEventMask)
342 REPLY (", mask(%x)", (unsigned int)*((XID *)&stuff[1]));
349 case X_ChangeSaveSet:
351 xChangeSaveSetReq *stuff = (xChangeSaveSetReq *)req;
353 REPLY (": XID(0x%x)",
354 (unsigned int)stuff->window);
356 if (detail_level >= EVLOG_PRINT_DETAIL)
363 case SetModeInsert: mode = "SetModeInsert"; break;
364 case SetModeDelete: mode = "SetModeDelete"; break;
365 default: mode = dmode; snprintf (dmode, 10, "%d", stuff->mode); break;
375 case X_ReparentWindow:
377 xReparentWindowReq *stuff = (xReparentWindowReq *)req;
378 REPLY (": Window(0x%x) Parent(0x%x) coord(%d,%d)",
379 (unsigned int)stuff->window,
380 (unsigned int)stuff->parent,
387 case X_ConfigureWindow:
389 xConfigureWindowReq *stuff = (xConfigureWindowReq *)req;
390 REPLY (": XID(0x%x)",
391 (unsigned int)stuff->window);
393 if (detail_level >= EVLOG_PRINT_DETAIL)
397 reply = _getConfigureWindowMask(stuff->mask, reply, len, (XID *)&stuff[1]);
404 case X_CirculateWindow:
406 xCirculateWindowReq *stuff = (xCirculateWindowReq *)req;
408 REPLY (": XID(0x%x)",
409 (unsigned int)stuff->window);
411 if (detail_level >= EVLOG_PRINT_DETAIL)
413 const char *direction;
416 switch (stuff->direction)
418 case RaiseLowest: direction = "RaiseLowest"; break;
419 case LowerHighest: direction = "LowerHighest"; break;
420 default: direction = ddirection; snprintf (ddirection, 10, "%d", stuff->direction); break;
423 REPLY (" direction(%s)",
430 case X_ChangeProperty:
432 xChangePropertyReq *stuff = (xChangePropertyReq *)req;
434 REPLY (": XID(0x%x)",
435 (unsigned int)stuff->window);
438 reply = xDbgGetAtom(stuff->property, evinfo, reply, len);
441 reply = xDbgGetAtom(stuff->type, evinfo, reply, len);
443 if (detail_level >= EVLOG_PRINT_DETAIL)
450 case PropModeReplace: mode = "PropModeReplace"; break;
451 case PropModePrepend: mode = "PropModePrepend"; break;
452 case PropModeAppend: mode = "PropModeAppend"; break;
453 default: mode = dmode; snprintf (dmode, 10, "%d", stuff->mode); break;
457 REPLY ("%67s mode(%s) format(%d) nUnits(%ld)",
461 (long int)stuff->nUnits);
467 case X_DeleteProperty:
469 xDeletePropertyReq *stuff = (xDeletePropertyReq *)req;
470 REPLY (": XID(0x%x)",
471 (unsigned int)stuff->window);
474 reply = xDbgGetAtom(stuff->property, evinfo, reply, len);
481 xGetPropertyReq *stuff = (xGetPropertyReq *)req;
483 REPLY (": XID(0x%x)",
484 (unsigned int)stuff->window);
487 reply = xDbgGetAtom(stuff->property, evinfo, reply, len);
489 reply = xDbgGetAtom(stuff->type, evinfo, reply, len);
491 if (detail_level >= EVLOG_PRINT_DETAIL)
494 REPLY ("%67s delete(%s) longOffset(%ld) longLength(%ld)",
496 stuff->delete ? "YES" : "NO",
497 (long int)stuff->longOffset,
498 (long int)stuff->longLength);
504 case X_SetSelectionOwner:
506 xSetSelectionOwnerReq *stuff = (xSetSelectionOwnerReq *)req;
507 REPLY (": XID(0x%x)",
508 (unsigned int)stuff->window);
510 REPLY (" Selection");
511 reply = xDbgGetAtom(stuff->selection, evinfo, reply, len);
513 if (detail_level >= EVLOG_PRINT_DETAIL)
515 REPLY (" time(%lums)",
516 (unsigned long)stuff->time);
522 case X_ConvertSelection:
524 xConvertSelectionReq *stuff = (xConvertSelectionReq *)req;
525 REPLY (": XID(0x%x)",
526 (unsigned int)stuff->requestor);
528 REPLY (" Selection");
529 reply = xDbgGetAtom(stuff->selection, evinfo, reply, len);
531 reply = xDbgGetAtom(stuff->target, evinfo, reply, len);
533 reply = xDbgGetAtom(stuff->property, evinfo, reply, len);
535 if (detail_level >= EVLOG_PRINT_DETAIL)
537 REPLY (" time(%lums)",
538 (unsigned long)stuff->time);
546 xSendEventReq *stuff = (xSendEventReq *)req;
547 REPLY (": XID(0x%x)",
548 (unsigned int)stuff->destination);
550 if (detail_level >= EVLOG_PRINT_DETAIL)
552 REPLY (" propagate(%s)",
553 stuff->propagate ? "YES" : "NO");
555 REPLY (" event_mask");
557 reply = _getEventMask(stuff->eventMask, reply, len);
566 xGrabPointerReq *stuff = (xGrabPointerReq *)req;
568 REPLY (": XID(0x%x) ConfineTo(0x%x) Cursor(0x%x)",
569 (unsigned int)stuff->grabWindow,
570 (unsigned int)stuff->confineTo,
571 (unsigned int)stuff->cursor);
573 if (detail_level >= EVLOG_PRINT_DETAIL)
575 const char *pointer_mode, *keyboard_mode;
576 char dpointer_mode[10], dkeyboard_mode[10];
578 switch (stuff->pointerMode)
580 case GrabModeSync: pointer_mode = "GrabModeSync"; break;
581 case GrabModeAsync: pointer_mode = "GrabModeAsync"; break;
582 default: pointer_mode = dpointer_mode; snprintf (dpointer_mode, 10, "%d", stuff->pointerMode); break;
585 switch (stuff->keyboardMode)
587 case GrabModeSync: keyboard_mode = "GrabModeSync"; break;
588 case GrabModeAsync: keyboard_mode = "GrabModeAsync"; break;
589 default: keyboard_mode = dkeyboard_mode; snprintf (dkeyboard_mode, 10, "%d", stuff->keyboardMode); break;
592 REPLY (" pointer_mode(%s) keyboard_mode(%s) time(%lums)\n",
595 (unsigned long)stuff->time);
597 REPLY (" event_mask");
599 reply = _getEventMask(stuff->eventMask, reply, len);
608 xGrabButtonReq *stuff = (xGrabButtonReq *)req;
610 REPLY (": XID(0x%x) ConfineTo(0x%x) Cursor(0x%x)",
611 (unsigned int)stuff->grabWindow,
612 (unsigned int)stuff->confineTo,
613 (unsigned int)stuff->cursor);
615 if (detail_level >= EVLOG_PRINT_DETAIL)
617 const char *pointer_mode, *keyboard_mode, *button;
618 char dpointer_mode[10], dkeyboard_mode[10], dbutton[10];
620 switch (stuff->pointerMode)
622 case GrabModeSync: pointer_mode = "GrabModeSync"; break;
623 case GrabModeAsync: pointer_mode = "GrabModeAsync"; break;
624 default: pointer_mode = dpointer_mode; snprintf (dpointer_mode, 10, "%d", stuff->pointerMode); break;
627 switch (stuff->keyboardMode)
629 case GrabModeSync: keyboard_mode = "GrabModeSync"; break;
630 case GrabModeAsync: keyboard_mode = "GrabModeAsync"; break;
631 default: keyboard_mode = dkeyboard_mode; snprintf (dkeyboard_mode, 10, "%d", stuff->keyboardMode); break;
634 switch (stuff->button)
636 case Button1: button = "Button1"; break;
637 case Button2: button = "Button2"; break;
638 case Button3: button = "Button3"; break;
639 case Button4: button = "Button4"; break;
640 case Button5: button = "Button5"; break;
641 default: button = dbutton; snprintf (dbutton, 10, "%d", stuff->button); break;
645 REPLY ("%67s event_mask(0x%x) pointer_mode(%s) keyboard_mode(%s) button(%s)",
652 REPLY (" modifiers");
654 reply = _getKeyMask(stuff->modifiers, reply, len);
663 xUngrabButtonReq *stuff = (xUngrabButtonReq *)req;
664 REPLY (": XID(0x%x)",
665 (unsigned int)stuff->grabWindow);
667 if (detail_level >= EVLOG_PRINT_DETAIL)
669 REPLY (" modifiers");
671 reply = _getKeyMask(stuff->modifiers, reply, len);
678 case X_ChangeActivePointerGrab:
680 xChangeActivePointerGrabReq *stuff = (xChangeActivePointerGrabReq *)req;
681 REPLY (": Cursor(0x%x)",
682 (unsigned int)stuff->cursor);
684 if (detail_level >= EVLOG_PRINT_DETAIL)
686 REPLY (" time(%lums)",
687 (unsigned long)stuff->time);
689 REPLY (" event_mask");
691 reply = _getEventMask(stuff->eventMask, reply, len);
700 xGrabKeyboardReq *stuff = (xGrabKeyboardReq *)req;
702 REPLY (": XID(0x%x)",
703 (unsigned int)stuff->grabWindow);
705 if (detail_level >= EVLOG_PRINT_DETAIL)
707 const char *pointer_mode, *keyboard_mode;
708 char dpointer_mode[10], dkeyboard_mode[10];
710 switch (stuff->pointerMode)
712 case GrabModeSync: pointer_mode = "GrabModeSync"; break;
713 case GrabModeAsync: pointer_mode = "GrabModeAsync"; break;
714 default: pointer_mode = dpointer_mode; snprintf (dpointer_mode, 10, "%d", stuff->pointerMode); break;
717 switch (stuff->keyboardMode)
719 case GrabModeSync: keyboard_mode = "GrabModeSync"; break;
720 case GrabModeAsync: keyboard_mode = "GrabModeAsync"; break;
721 default: keyboard_mode = dkeyboard_mode; snprintf (dkeyboard_mode, 10, "%d", stuff->keyboardMode); break;
724 REPLY (" owner_events(%s) pointer_mode(%s) keyboard_mode(%s)",
725 stuff->ownerEvents ? "YES" : "NO",
735 xGrabKeyReq *stuff = (xGrabKeyReq *)req;
737 REPLY (": XID(0x%x)",
738 (unsigned int)stuff->grabWindow);
740 if (detail_level >= EVLOG_PRINT_DETAIL)
742 const char *pointer_mode, *keyboard_mode;
743 char dpointer_mode[10], dkeyboard_mode[10];
745 switch (stuff->pointerMode)
747 case GrabModeSync: pointer_mode = "GrabModeSync"; break;
748 case GrabModeAsync: pointer_mode = "GrabModeAsync"; break;
749 default: pointer_mode = dpointer_mode; snprintf (dpointer_mode, 10, "%d", stuff->pointerMode); break;
752 switch (stuff->keyboardMode)
754 case GrabModeSync: keyboard_mode = "GrabModeSync"; break;
755 case GrabModeAsync: keyboard_mode = "GrabModeAsync"; break;
756 default: keyboard_mode = dkeyboard_mode; snprintf (dkeyboard_mode, 10, "%d", stuff->keyboardMode); break;
759 REPLY (" key(%d) pointer_mode(%s) keyboard_mode(%s)\n",
764 REPLY (" modifiers");
766 reply = _getKeyMask(stuff->modifiers, reply, len);
775 xUngrabKeyReq *stuff = (xUngrabKeyReq *)req;
776 REPLY (": XID(0x%x)",
777 (unsigned int)stuff->grabWindow);
779 if (detail_level >= EVLOG_PRINT_DETAIL)
784 REPLY (" modifiers");
786 reply = _getKeyMask(stuff->modifiers, reply, len);
793 case X_SetInputFocus:
795 xSetInputFocusReq *stuff = (xSetInputFocusReq *)req;
796 REPLY (": XID(0x%x)",
797 (unsigned int)stuff->focus);
799 if (detail_level >= EVLOG_PRINT_DETAIL)
801 REPLY (" reverTo(%d) time(%lums)",
803 (unsigned long)stuff->time);
811 xCreatePixmapReq *stuff = (xCreatePixmapReq *)req;
812 REPLY (": Pixmap(0x%x) Drawable(0x%x) size(%dx%d)",
813 (unsigned int)stuff->pid,
814 (unsigned int)stuff->drawable,
818 if (detail_level >= EVLOG_PRINT_DETAIL)
829 xCreateGCReq *stuff = (xCreateGCReq *)req;
830 REPLY (": Gc(0x%x) Drawable(0x%x)",
831 (unsigned int)stuff->gc,
832 (unsigned int)stuff->drawable);
839 xClearAreaReq *stuff = (xClearAreaReq *)req;
840 REPLY (": XID(0x%x) area(%d,%d %dx%d)",
841 (unsigned int)stuff->window,
847 if (detail_level >= EVLOG_PRINT_DETAIL)
849 REPLY (" exposures(%s)",
850 stuff->exposures ? "YES" : "NO");
858 xCopyAreaReq *stuff = (xCopyAreaReq *)req;
859 REPLY (": srcXID(0x%x) dstXID(0x%x) gc(0x%x) size(%dx%d) src(%d,%d) dst(%d,%d)",
860 (unsigned int)stuff->srcDrawable,
861 (unsigned int)stuff->dstDrawable,
862 (unsigned int)stuff->gc,
875 xCopyPlaneReq *stuff = (xCopyPlaneReq *)req;
876 REPLY (": srcXID(0x%x) dstXID(0x%x) gc(0x%x) size(%dx%d) src(%d,%d) dst(%d,%d)",
877 (unsigned int)stuff->srcDrawable,
878 (unsigned int)stuff->dstDrawable,
879 (unsigned int)stuff->gc,
887 if (detail_level >= EVLOG_PRINT_DETAIL)
889 REPLY (" bit_plane(0x%x)",
890 (unsigned int)stuff->bitPlane);
898 xPolyPointReq *stuff = (xPolyPointReq *)req;
899 REPLY (": XID(0x%x) gc(0x%x)",
900 (unsigned int)stuff->drawable,
901 (unsigned int)stuff->gc);
903 if (detail_level >= EVLOG_PRINT_DETAIL)
905 const char *coord_mode;
906 char dcoord_mode[10];
908 switch (stuff->coordMode)
910 case CoordModeOrigin: coord_mode = "CoordModeOrigin"; break;
911 case CoordModePrevious: coord_mode = "CoordModePrevious"; break;
912 default: coord_mode = dcoord_mode; snprintf (dcoord_mode, 10, "%d", stuff->coordMode); break;
915 REPLY (" coord_mode(%s)",
924 xPolyLineReq *stuff = (xPolyLineReq *)req;
925 REPLY (": XID(0x%x gc(0x%x)",
926 (unsigned int)stuff->drawable,
927 (unsigned int)stuff->gc);
929 if (detail_level >= EVLOG_PRINT_DETAIL)
931 const char *coord_mode;
932 char dcoord_mode[10];
934 switch (stuff->coordMode)
936 case CoordModeOrigin: coord_mode = "CoordModeOrigin"; break;
937 case CoordModePrevious: coord_mode = "CoordModePrevious"; break;
938 default: coord_mode = dcoord_mode; snprintf (dcoord_mode, 10, "%d", stuff->coordMode); break;
941 REPLY (" coord_mode(%s)",
950 xPolySegmentReq *stuff = (xPolySegmentReq *)req;
951 REPLY (": XID(0x%x) gc(0x%x)",
952 (unsigned int)stuff->drawable,
953 (unsigned int)stuff->gc);
958 case X_PolyRectangle:
960 xPolyRectangleReq *stuff = (xPolyRectangleReq *)req;
961 REPLY (": XID(0x%x) gc(0x%x)",
962 (unsigned int)stuff->drawable,
963 (unsigned int)stuff->gc);
970 xPolyArcReq *stuff = (xPolyArcReq *)req;
971 REPLY (": XID(0x%x) gc(0x%x)",
972 (unsigned int)stuff->drawable,
973 (unsigned int)stuff->gc);
980 xFillPolyReq *stuff = (xFillPolyReq *)req;
981 REPLY (": XID(0x%x) gc(0x%x)",
982 (unsigned int)stuff->drawable,
983 (unsigned int)stuff->gc);
985 if (detail_level >= EVLOG_PRINT_DETAIL)
987 const char *shape, *coord_mode;
988 char dshape[10], dcoord_mode[10];
990 switch (stuff->shape)
992 case Complex: shape = "Complex"; break;
993 case Nonconvex: shape = "Nonconvex"; break;
994 case Convex: shape = "Convex"; break;
995 default: shape = dshape; snprintf (dshape, 10, "%d", stuff->shape); break;
998 switch (stuff->coordMode)
1000 case CoordModeOrigin: coord_mode = "CoordModeOrigin"; break;
1001 case CoordModePrevious: coord_mode = "CoordModePrevious"; break;
1002 default: coord_mode = dcoord_mode; snprintf (dcoord_mode, 10, "%d", stuff->coordMode); break;
1005 REPLY (" shape(%s) coord_mode(%s)",
1013 case X_PolyFillRectangle:
1015 xPolyFillRectangleReq *stuff = (xPolyFillRectangleReq *)req;
1016 REPLY (": XID(0x%x) gc(0x%x)",
1017 (unsigned int)stuff->drawable,
1018 (unsigned int)stuff->gc);
1025 xPolyFillArcReq *stuff = (xPolyFillArcReq *)req;
1026 REPLY (": XID(0x%x) gc(0x%x)",
1027 (unsigned int)stuff->drawable,
1028 (unsigned int)stuff->gc);
1035 xPutImageReq *stuff = (xPutImageReq *)req;
1036 REPLY (": XID(0x%x) gc(0x%x) size(%dx%d) dst(%d,%d)",
1037 (unsigned int)stuff->drawable,
1038 (unsigned int)stuff->gc,
1044 if (detail_level >= EVLOG_PRINT_DETAIL)
1049 switch (stuff->format)
1051 case XYBitmap: format = "XYBitmap"; break;
1052 case XYPixmap: format = "XYPixmap"; break;
1053 case ZPixmap: format = "ZPixmap"; break;
1054 default: format = dformat; snprintf (dformat, 10, "%d", stuff->format); break;
1057 REPLY (" format(%s) depth(%d)",
1067 xGetImageReq *stuff = (xGetImageReq *)req;
1068 REPLY (": XID(0x%x) size(%dx%d) dst(%d,%d)",
1069 (unsigned int)stuff->drawable,
1075 if (detail_level >= EVLOG_PRINT_DETAIL)
1080 switch (stuff->format)
1082 case XYBitmap: format = "XYBitmap"; break;
1083 case XYPixmap: format = "XYPixmap"; break;
1084 case ZPixmap: format = "ZPixmap"; break;
1085 default: format = dformat; snprintf (dformat, 10, "%d", stuff->format); break;
1088 REPLY (" format(%s) plane_mask(0x%x)",
1090 (unsigned int)stuff->planeMask);
1098 xPolyText8Req *stuff = (xPolyText8Req *)req;
1099 REPLY (": XID(0x%x) gc(0x%x) coord(%d,%d)",
1100 (unsigned int)stuff->drawable,
1101 (unsigned int)stuff->gc,
1110 xPolyText16Req *stuff = (xPolyText16Req *)req;
1111 REPLY (": XID(0x%x) gc(0x%x) coord(%d,%d)",
1112 (unsigned int)stuff->drawable,
1113 (unsigned int)stuff->gc,
1122 xImageText8Req *stuff = (xImageText8Req *)req;
1123 REPLY (": XID(0x%x) gc(0x%x) coord(%d,%d)",
1124 (unsigned int)stuff->drawable,
1125 (unsigned int)stuff->gc,
1129 if (detail_level >= EVLOG_PRINT_DETAIL)
1131 REPLY (" nchars(%d)",
1140 xImageText16Req *stuff = (xImageText16Req *)req;
1141 REPLY (": XID(0x%x) gc(0x%x) coord(%d,%d)",
1142 (unsigned int)stuff->drawable,
1143 (unsigned int)stuff->gc,
1147 if (detail_level >= EVLOG_PRINT_DETAIL)
1149 REPLY (" nchars(%d)",
1156 case X_ChangeKeyboardMapping:
1158 xChangeKeyboardMappingReq *stuff = (xChangeKeyboardMappingReq *)req;
1159 REPLY (": first_key_code(%d) key_syms_per_key_code(%d)",
1160 stuff->firstKeyCode,
1161 stuff->keySymsPerKeyCode);
1163 if (detail_level >= EVLOG_PRINT_DETAIL)
1165 REPLY (" key_codes(%d)",
1172 case X_GetKeyboardMapping:
1174 xGetKeyboardMappingReq *stuff = (xGetKeyboardMappingReq *)req;
1175 REPLY (": first_key_code(%d)",
1176 stuff->firstKeyCode);
1178 if (detail_level >= EVLOG_PRINT_DETAIL)
1180 REPLY (" count(%d)",
1187 case X_ChangePointerControl:
1189 xChangePointerControlReq *stuff = (xChangePointerControlReq *)req;
1190 REPLY (": accelNum(%d) accelDenum(%d) threshold(%d)",
1195 if (detail_level >= EVLOG_PRINT_DETAIL)
1197 REPLY (" do_accel(%s) do_thresh(%s)",
1198 stuff->doAccel ? "YES" : "NO",
1199 stuff->doThresh ? "YES" : "NO");
1205 case X_SetPointerMapping:
1207 xSetPointerMappingReq *stuff = (xSetPointerMappingReq *)req;
1209 if (detail_level >= EVLOG_PRINT_DETAIL)
1211 REPLY (": Elts(%d)",
1218 case X_SetModifierMapping:
1220 xSetModifierMappingReq *stuff =(xSetModifierMappingReq *)req;
1221 REPLY (": num_key_per_modifier(%d)",
1222 stuff->numKeyPerModifier);
1227 case X_ListProperties:
1228 case X_DestroyWindow:
1229 case X_DestroySubwindows:
1231 case X_MapSubwindows:
1233 case X_UnmapSubwindows:
1236 case X_UngrabPointer:
1237 case X_UngrabKeyboard:
1242 xResourceReq *stuff = (xResourceReq *)req;
1243 REPLY (": XID(0x%x)",
1244 (unsigned int)stuff->id);
1256 char * xDbgEvlogEventCore (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
1258 xEvent *evt = evinfo->evt.ptr;
1260 switch (evt->u.u.type & 0x7F)
1268 REPLY (": Root(0x%x %d,%d) Event(0x%x %d,%d) Child(0x%x)",
1269 (unsigned int)evt->u.keyButtonPointer.root,
1270 evt->u.keyButtonPointer.rootX,
1271 evt->u.keyButtonPointer.rootY,
1272 (unsigned int)evt->u.keyButtonPointer.event,
1273 evt->u.keyButtonPointer.eventX,
1274 evt->u.keyButtonPointer.eventY,
1275 (unsigned int)evt->u.keyButtonPointer.child);
1277 if (detail_level >= EVLOG_PRINT_DETAIL)
1280 REPLY ("%67s state(0x%x) same_screen(%s)",
1282 evt->u.keyButtonPointer.state,
1283 evt->u.keyButtonPointer.sameScreen ? "YES" : "NO");
1292 REPLY (": Root(0x%x %d,%d) Event(0x%x %d,%d) Child(0x%x)",
1293 (unsigned int)evt->u.enterLeave.root,
1294 evt->u.enterLeave.rootX,
1295 evt->u.enterLeave.rootY,
1296 (unsigned int)evt->u.enterLeave.event,
1297 evt->u.enterLeave.eventX,
1298 evt->u.enterLeave.eventY,
1299 (unsigned int)evt->u.enterLeave.child);
1301 if (detail_level >= EVLOG_PRINT_DETAIL)
1304 REPLY ("%67s time(%lums) state(0x%x) same_screen(%s) focus(%s)",
1306 (unsigned long)evt->u.enterLeave.time,
1307 evt->u.enterLeave.state,
1308 evt->u.enterLeave.flags & ELFlagSameScreen ? "YES" : "NO",
1309 evt->u.enterLeave.flags & ELFlagFocus ? "YES" : "NO");
1319 REPLY (": XID(0x%x)",
1320 (unsigned int)evt->u.focus.window);
1322 if (detail_level >= EVLOG_PRINT_DETAIL)
1327 switch (evt->u.focus.mode)
1329 case NotifyNormal: mode = "NotifyNormal"; break;
1330 case NotifyGrab: mode = "NotifyGrab"; break;
1331 case NotifyUngrab: mode = "NotifyUngrab"; break;
1332 case NotifyWhileGrabbed: mode = "NotifyWhileGrabbed"; break;
1333 default: mode = dmode, snprintf (dmode, 10, "%u", evt->u.focus.mode); break;
1345 REPLY (": XID(0x%x) size(%dx%d) coord(%d,%d)",
1346 (unsigned int)evt->u.expose.window,
1347 evt->u.expose.width,
1348 evt->u.expose.height,
1352 if (detail_level >= EVLOG_PRINT_DETAIL)
1354 REPLY (" count(%d)",
1355 evt->u.expose.count);
1361 case GraphicsExpose:
1363 REPLY (": XID(0x%x) size(%dx%d) coord(%d,%d)",
1364 (unsigned int)evt->u.graphicsExposure.drawable,
1365 evt->u.graphicsExposure.width,
1366 evt->u.graphicsExposure.height,
1367 evt->u.graphicsExposure.x,
1368 evt->u.graphicsExposure.y);
1370 if (detail_level >= EVLOG_PRINT_DETAIL)
1375 switch (evt->u.graphicsExposure.majorEvent)
1377 case X_CopyArea: major = "CopyArea"; break;
1378 case X_CopyPlane: major = "CopyPlane"; break;
1379 default: major = dmajor; snprintf (dmajor, 10, "%d", evt->u.graphicsExposure.majorEvent); break;
1382 REPLY (" major_event(%s) minor_event(%d) count(%d)",
1384 evt->u.graphicsExposure.minorEvent,
1385 evt->u.graphicsExposure.count);
1393 REPLY (": XID(0x%x)",
1394 (unsigned int)evt->u.noExposure.drawable);
1396 if (detail_level >= EVLOG_PRINT_DETAIL)
1401 switch (evt->u.noExposure.majorEvent)
1403 case X_CopyArea: major = "CopyArea"; break;
1404 case X_CopyPlane: major = "CopyPlane"; break;
1405 default: major = dmajor; snprintf (dmajor, 10, "%d", evt->u.noExposure.majorEvent); break;
1408 REPLY (" major_event(%s) minor_event(%d)",
1410 evt->u.noExposure.minorEvent);
1416 case VisibilityNotify:
1418 REPLY (": XID(0x%x)",
1419 (unsigned int)evt->u.visibility.window);
1421 if (detail_level >= EVLOG_PRINT_DETAIL)
1426 switch (evt->u.visibility.state)
1428 case VisibilityUnobscured: state = "VisibilityUnobscured"; break;
1429 case VisibilityPartiallyObscured: state = "VisibilityPartiallyObscured"; break;
1430 case VisibilityFullyObscured: state = "VisibilityFullyObscured"; break;
1431 default: state = dstate; snprintf (dstate, 10, "%d", evt->u.visibility.state); break;
1434 REPLY (" state(%s)",
1443 REPLY (": Window(0x%x) Parent(0x%x) size(%dx%d) coord(%d,%d) borderWidth(%d)",
1444 (unsigned int)evt->u.createNotify.window,
1445 (unsigned int)evt->u.createNotify.parent,
1446 evt->u.createNotify.width,
1447 evt->u.createNotify.height,
1448 evt->u.createNotify.x,
1449 evt->u.createNotify.y,
1450 evt->u.createNotify.borderWidth);
1452 if (detail_level >= EVLOG_PRINT_DETAIL)
1454 REPLY (" override(%s)",
1455 evt->u.createNotify.override ? "YES" : "NO");
1463 REPLY (": Window(0x%x) Event(0x%x)",
1464 (unsigned int)evt->u.destroyNotify.window,
1465 (unsigned int)evt->u.destroyNotify.event);
1472 REPLY (": Window(0x%x) Event(0x%x)",
1473 (unsigned int)evt->u.unmapNotify.window,
1474 (unsigned int)evt->u.unmapNotify.event);
1476 if (detail_level >= EVLOG_PRINT_DETAIL)
1478 REPLY (" from_Configure(%s)",
1479 evt->u.unmapNotify.fromConfigure ? "YES" : "NO");
1487 REPLY (": Window(0x%x) Event(0x%x)",
1488 (unsigned int)evt->u.mapNotify.window,
1489 (unsigned int)evt->u.mapNotify.event);
1491 if (detail_level >= EVLOG_PRINT_DETAIL)
1493 REPLY (" override(%s)",
1494 evt->u.mapNotify.override ? "YES" : "NO");
1502 REPLY (": Window(0x%x) Parent(0x%x)",
1503 (unsigned int)evt->u.mapRequest.window,
1504 (unsigned int)evt->u.mapRequest.parent);
1509 case ReparentNotify:
1511 REPLY (": Window(0x%x) Event(0x%x) Parent(0x%x) coord(%d,%d)",
1512 (unsigned int)evt->u.reparent.window,
1513 (unsigned int)evt->u.reparent.event,
1514 (unsigned int)evt->u.reparent.parent,
1518 if (detail_level >= EVLOG_PRINT_DETAIL)
1520 REPLY (" override(%s)",
1521 evt->u.reparent.override ? "YES" : "NO");
1527 case ConfigureNotify:
1529 REPLY (": Window(0x%x) Event(0x%x) AboveSibling(0x%x) size(%dx%d) coord(%d,%d) borderWidth(%d)",
1530 (unsigned int)evt->u.configureNotify.window,
1531 (unsigned int)evt->u.configureNotify.event,
1532 (unsigned int)evt->u.configureNotify.aboveSibling,
1533 evt->u.configureNotify.width,
1534 evt->u.configureNotify.height,
1535 evt->u.configureNotify.x,
1536 evt->u.configureNotify.y,
1537 evt->u.configureNotify.borderWidth);
1539 if (detail_level >= EVLOG_PRINT_DETAIL)
1541 REPLY (" override(%s)",
1542 evt->u.configureNotify.override ? "YES" : "NO");
1548 case ConfigureRequest:
1550 REPLY (": Window(0x%x) Parent(0x%x) Sibling(0x%x) size(%dx%d) coord(%d,%d) borderWidth(%d)",
1551 (unsigned int)evt->u.configureRequest.window,
1552 (unsigned int)evt->u.configureRequest.parent,
1553 (unsigned int)evt->u.configureRequest.sibling,
1554 evt->u.configureRequest.width,
1555 evt->u.configureRequest.height,
1556 evt->u.configureRequest.x,
1557 evt->u.configureRequest.y,
1558 evt->u.configureRequest.borderWidth);
1560 if (detail_level >= EVLOG_PRINT_DETAIL)
1563 REPLY ("%67s value_mask",
1566 reply = _getConfigureWindowMask(evt->u.configureRequest.valueMask, reply, len, NULL);
1575 REPLY (": Window(0x%x) Event(0x%x) coord(%d,%d)",
1576 (unsigned int)evt->u.gravity.window,
1577 (unsigned int)evt->u.gravity.event,
1586 REPLY (": Window(0x%x) size(%dx%d)",
1587 (unsigned int)evt->u.resizeRequest.window,
1588 evt->u.resizeRequest.width,
1589 evt->u.resizeRequest.height);
1594 case CirculateNotify:
1595 case CirculateRequest:
1597 REPLY (": Window(0x%x) Event(0x%x) parent(0x%x)",
1598 (unsigned int)evt->u.circulate.window,
1599 (unsigned int)evt->u.circulate.event,
1600 (unsigned int)evt->u.circulate.parent);
1602 if (detail_level >= EVLOG_PRINT_DETAIL)
1607 switch (evt->u.circulate.place)
1609 case PlaceOnTop: place = "PlaceOnTop"; break;
1610 case PlaceOnBottom: place = "PlaceOnBottom"; break;
1611 default: place = dplace; snprintf (dplace, 10, "%d", evt->u.circulate.place); break;
1614 REPLY (" place(%s)",
1621 case PropertyNotify:
1623 REPLY (": Window(0x%x)",
1624 (unsigned int)evt->u.property.window);
1626 REPLY (" Property");
1627 reply = xDbgGetAtom(evt->u.property.atom, evinfo, reply, len);
1629 if (detail_level >= EVLOG_PRINT_DETAIL)
1634 switch (evt->u.property.state)
1636 case PropertyNewValue: state = "PropertyNewValue"; break;
1637 case PropertyDelete: state = "PropertyDelete"; break;
1638 default: state = dstate; snprintf (dstate, 10, "%d", evt->u.property.state); break;
1642 REPLY ("%67s time(%lums) state(%s)",
1644 (unsigned long)evt->u.property.time,
1651 case SelectionClear:
1653 REPLY (": Window(0x%x)",
1654 (unsigned int)evt->u.selectionClear.window);
1657 reply = xDbgGetAtom(evt->u.selectionClear.atom, evinfo, reply, len);
1659 if (detail_level >= EVLOG_PRINT_DETAIL)
1661 REPLY (" time(%lums)",
1662 (unsigned long)evt->u.selectionClear.time);
1668 case SelectionRequest:
1670 REPLY (": Owner(0x%x) Requestor(0x%x)",
1671 (unsigned int)evt->u.selectionRequest.owner,
1672 (unsigned int)evt->u.selectionRequest.requestor);
1674 REPLY (" selection");
1675 reply = xDbgGetAtom(evt->u.selectionRequest.selection, evinfo, reply, len);
1677 reply = xDbgGetAtom(evt->u.selectionRequest.target, evinfo, reply, len);
1678 REPLY (" Property");
1679 reply = xDbgGetAtom(evt->u.selectionRequest.property, evinfo, reply, len);
1681 if (detail_level >= EVLOG_PRINT_DETAIL)
1683 REPLY (" time(%lums)",
1684 (unsigned long)evt->u.selectionRequest.time);
1690 case SelectionNotify:
1692 REPLY (": Requestor(0x%x)",
1693 (unsigned int)evt->u.selectionNotify.requestor);
1695 REPLY (" selection");
1696 reply = xDbgGetAtom(evt->u.selectionNotify.selection, evinfo, reply, len);
1698 reply = xDbgGetAtom(evt->u.selectionNotify.target, evinfo, reply, len);
1699 REPLY (" Property");
1700 reply = xDbgGetAtom(evt->u.selectionNotify.property, evinfo, reply, len);
1702 if (detail_level >= EVLOG_PRINT_DETAIL)
1704 REPLY (" time(%lums)",
1705 (unsigned long)evt->u.selectionNotify.time);
1711 case ColormapNotify:
1713 REPLY (": XID(0x%x) Colormap(0x%x)",
1714 (unsigned int)evt->u.colormap.window,
1715 (unsigned int)evt->u.colormap.colormap);
1717 if (detail_level >= EVLOG_PRINT_DETAIL)
1722 switch (evt->u.colormap.state)
1724 case ColormapInstalled: state = "ColormapInstalled"; break;
1725 case ColormapUninstalled: state = "ColormapUninstalled"; break;
1726 default: state = dstate; snprintf (dstate, 10, "%d", evt->u.colormap.state); break;
1729 REPLY (" new(%s) state(%s)",
1730 evt->u.colormap.new ? "YES" : "NO",
1739 REPLY (": XID(0x%x)",
1740 (unsigned int)evt->u.clientMessage.window);
1743 reply = xDbgGetAtom(evt->u.clientMessage.u.b.type, evinfo, reply, len);
1757 char * xDbgEvlogReplyCore (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
1759 xGenericReply *rep = evinfo->rep.ptr;
1761 switch (evinfo->rep.reqType)
1765 if (evinfo->rep.isStart)
1767 xGetGeometryReply *stuff = (xGetGeometryReply *)rep;
1769 REPLY (": XID(0x%x) coord(%d,%d %dx%d) borderWidth(%d)",
1770 (unsigned int)stuff->root,
1775 stuff->borderWidth);
1787 if (evinfo->rep.isStart)
1789 xQueryTreeReply *stuff = (xQueryTreeReply *)rep;
1791 REPLY (": XID(0x%x) Parent(0x%x) ChildrenNum(%d)",
1792 (unsigned int)stuff->root,
1793 (unsigned int)stuff->parent,
1798 Window *stuff = (Window *)rep;
1803 for (i = 0 ; i < evinfo->rep.size / sizeof(Window) ; i++)
1805 REPLY("0x%x", (unsigned int)stuff[i]);
1806 if(i != evinfo->rep.size / sizeof(Window) - 1)
1817 if (evinfo->rep.isStart)
1819 xGetPropertyReply *stuff = (xGetPropertyReply *)rep;
1821 REPLY (": PropertyType");
1822 reply = xDbgGetAtom(stuff->propertyType, evinfo, reply, len);
1824 REPLY (" bytesAfter(0x%x) format(%d) ItemNum(%ld)",
1825 (unsigned int)stuff->bytesAfter,
1827 (long int)stuff->nItems);
1837 case X_ListProperties:
1839 if (evinfo->rep.isStart)
1841 xListPropertiesReply *stuff = (xListPropertiesReply *)rep;
1843 REPLY (" PropertieNum(%d)",
1844 stuff->nProperties);
1848 Atom *stuff = (Atom *)rep;
1851 REPLY ("Properties");
1853 for (i = 0 ; i < evinfo->rep.size / sizeof(Atom) ; i ++)
1855 reply = xDbgGetAtom(stuff[i], evinfo, reply, len);
1856 if(i != evinfo->rep.size / sizeof(Atom) - 1)
1867 if (evinfo->rep.isStart)
1869 xGetImageReply *stuff = (xGetImageReply *)rep;
1871 REPLY (": XID(0x%x)",
1872 (unsigned int)stuff->visual);
1882 case X_GetKeyboardControl:
1884 if (evinfo->rep.isStart)
1886 xGetKeyboardControlReply *stuff = (xGetKeyboardControlReply *)rep;
1888 REPLY (": keyClickPercent(%d) bellPercent(%d), bellPitch(%d) bellDuration(%d)",
1889 stuff->keyClickPercent,
1892 stuff->bellDuration);
1902 case X_GetPointerControl:
1904 if (evinfo->rep.isStart)
1906 xGetPointerControlReply *stuff = (xGetPointerControlReply *)rep;
1908 REPLY (": accelNumerator(%d) accelDenominator(%d), threshold(%d)",
1909 stuff->accelNumerator,
1910 stuff->accelDenominator,