add 'shape' extension in evlog
[adaptation/xorg/driver/xserver-xorg-module-xdbg.git] / common / xdbg_evlog_xext.c
1 /**************************************************************************
2
3 xdbg
4
5 Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
6
7 Contact: Boram Park <boram1288.park@samsung.com>
8          Sangjin LEE <lsj119@samsung.com>
9
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:
17
18 The above copyright notice and this permission notice (including the
19 next paragraph) shall be included in all copies or substantial portions
20 of the Software.
21
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.
29
30 **************************************************************************/
31
32 #ifdef HAVE_CONFIG_H
33 #include "config.h"
34 #endif
35
36 #include <stdio.h>
37 #include <string.h>
38 #include <strings.h>
39 #include <sys/types.h>
40 #include <sys/fcntl.h>
41 #include <unistd.h>
42 #include <stdarg.h>
43 #include <fcntl.h>
44 #include <unistd.h>
45
46 #include <dix.h>
47 #define XREGISTRY
48 #include <registry.h>
49 #include <xace.h>
50 #include <xacestr.h>
51 #include <X11/Xatom.h>
52 #include <X11/Xlib.h>
53 #include <windowstr.h>
54
55 #include <X11/extensions/XShm.h>
56 #include <X11/extensions/dpms.h>
57 #include <X11/extensions/sync.h>
58 #include <X11/extensions/xtestext1.h>
59 #include <X11/extensions/XTest.h>
60 #include <X11/Xlibint.h>
61
62 #include <X11/extensions/dpmsproto.h>
63 #include <X11/extensions/shmproto.h>
64 #include <X11/extensions/syncproto.h>
65 #include <X11/extensions/xtestext1proto.h>
66 #include <X11/extensions/xtestproto.h>
67
68 #include "xdbg_types.h"
69 #include "xdbg_evlog_xext.h"
70 #include "xdbg_evlog.h"
71
72 static char *
73 _EvlogRequestXextDpms(EvlogInfo *evinfo, int detail_level, char *reply, int *len)
74 {
75     xReq *req = evinfo->req.ptr;
76
77     switch (req->data)
78     {
79     case X_DPMSSetTimeouts:
80         {
81             xDPMSSetTimeoutsReq *stuff = (xDPMSSetTimeoutsReq *)req;
82             REPLY (": Standby(%d) Suspend(%d) off(%d)",
83                 stuff->standby,
84                 stuff->suspend,
85                 stuff->off);
86
87             return reply;
88         }
89
90     case X_DPMSForceLevel:
91         {
92             xDPMSForceLevelReq *stuff = (xDPMSForceLevelReq *)req;
93             REPLY (": Level(%d)",
94                 stuff->level);
95
96             return reply;
97         }
98
99     default:
100             break;
101     }
102
103     return reply;
104 }
105
106
107 static char *
108 _EvlogRequestXextShm (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
109 {
110     xReq *req = evinfo->req.ptr;
111
112     switch (req->data)
113     {
114     case X_ShmPutImage:
115         {
116             xShmPutImageReq *stuff = (xShmPutImageReq *)req;
117             REPLY (": XID(0x%lx) gc(0x%lx) size(%dx%d) src(%d,%d %dx%d) dst(%d,%d)",
118                 stuff->drawable,
119                 stuff->gc,
120                 stuff->totalWidth,
121                 stuff->totalHeight,
122                 stuff->srcX,
123                 stuff->srcY,
124                 stuff->srcWidth,
125                 stuff->srcHeight,
126                 stuff->dstX,
127                 stuff->dstY);
128
129             if (detail_level >= EVLOG_PRINT_DETAIL)
130             {
131                 const char *format;
132                 char dformat[10];
133
134                 switch (stuff->format)
135                 {
136                     case XYBitmap:  format = "XYBitmap"; break;
137                     case XYPixmap:  format = "XYPixmap"; break;
138                     case ZPixmap:  format = "ZPixmap"; break;
139                     default:  format = dformat; sprintf (dformat, "%d", stuff->format); break;
140                 }
141
142                 REPLY ("\n");
143                 REPLY ("%67s depth(%d) format(%s) send_event(%s) shmseg(0x%lx) offset(%ld)",
144                     " ",
145                     stuff->depth,
146                     format,
147                     stuff->sendEvent ? "YES" : "NO",
148                     stuff->shmseg,
149                     stuff->offset);
150             }
151
152             return reply;
153         }
154
155     case X_ShmGetImage:
156         {
157             xShmGetImageReq *stuff = (xShmGetImageReq *)req;
158             REPLY (": XID(0x%lx) size(%dx%d) coord(%d,%d)",
159                 stuff->drawable,
160                 stuff->width,
161                 stuff->height,
162                 stuff->x,
163                 stuff->y);
164
165             if (detail_level >= EVLOG_PRINT_DETAIL)
166             {
167                 const char *format;
168                 char  dformat[10];
169
170                 switch (stuff->format)
171                 {
172                     case XYBitmap:  format = "XYBitmap"; break;
173                     case XYPixmap:  format = "XYPixmap"; break;
174                     case ZPixmap:  format = "ZPixmap"; break;
175                     default:  format = dformat; sprintf (dformat, "%d", stuff->format); break;
176                 }
177
178                 REPLY ("\n");
179                 REPLY ("%67s format(%s) plain_mask(0x%lx) shmseg(0x%lx) offset(%ld)",
180                     " ",
181                     format,
182                     stuff->planeMask,
183                     stuff->shmseg,
184                     stuff->offset);
185             }
186
187             return reply;
188         }
189
190     case X_ShmCreatePixmap:
191         {
192             xShmCreatePixmapReq *stuff = (xShmCreatePixmapReq *)req;
193             REPLY (": Pixmap(0x%lx) Drawable(0x%lx) size(%dx%d)",
194                 stuff->pid,
195                 stuff->drawable,
196                 stuff->width,
197                 stuff->height);
198
199             if (detail_level >= EVLOG_PRINT_DETAIL)
200             {
201                 REPLY ("\n");
202                 REPLY ("%67s depth(%d) shmseg(0x%lx) offset(%ld)",
203                     " ",
204                     stuff->depth,
205                     stuff->shmseg,
206                     stuff->offset);
207             }
208
209             return reply;
210         }
211
212     default:
213             break;
214     }
215
216     return reply;
217 }
218
219 static char *
220 _EvlogRequestXextSync(EvlogInfo *evinfo, int detail_level, char *reply, int *len)
221 {
222     xReq *req = evinfo->req.ptr;
223
224     switch (req->data)
225     {
226     case X_SyncCreateCounter:
227         {
228             xSyncCreateCounterReq *stuff = (xSyncCreateCounterReq *)req;
229             REPLY (": XID(0x%lx) initValue(%ld/%ld)",
230                 stuff->cid,
231                 stuff->initial_value_hi,
232                 stuff->initial_value_lo);
233
234             return reply;
235         }
236
237     case X_SyncSetCounter:
238         {
239             xSyncSetCounterReq *stuff = (xSyncSetCounterReq *)req;
240             REPLY (": XID(0x%lx) Value(%ld/%ld)",
241                 stuff->cid,
242                 stuff->value_hi,
243                 stuff->value_lo);
244
245             return reply;
246         }
247
248     case X_SyncChangeCounter:
249         {
250             xSyncChangeCounterReq *stuff = (xSyncChangeCounterReq *)req;
251             REPLY (": XID(0x%lx) Value(%ld/%ld)",
252                 stuff->cid,
253                 stuff->value_hi,
254                 stuff->value_lo);
255
256             return reply;
257         }
258
259     case X_SyncQueryCounter:
260         {
261             xSyncQueryCounterReq *stuff = (xSyncQueryCounterReq *)req;
262             REPLY (": XID(0x%lx)",
263                 stuff->counter);
264
265             return reply;
266         }
267
268     case X_SyncDestroyCounter:
269         {
270             xSyncDestroyCounterReq *stuff = (xSyncDestroyCounterReq *)req;
271             REPLY (": XID(0x%lx)",
272                 stuff->counter);
273
274             return reply;
275         }
276
277     default:
278             break;
279     }
280
281     return reply;
282 }
283
284 static char *
285 _EvlogRequestXextXtestExt1(EvlogInfo *evinfo, int detail_level, char *reply, int *len)
286 {
287     xReq *req = evinfo->req.ptr;
288
289     switch (req->data)
290     {
291     case X_TestFakeInput:
292         {
293             xTestFakeInputReq *stuff = (xTestFakeInputReq *)req;
294             REPLY (": XID(0x%lx)",
295                 stuff->ack);
296
297             return reply;
298         }
299
300     case X_TestGetInput:
301         {
302             xTestGetInputReq *stuff = (xTestGetInputReq *)req;
303             REPLY (": XID(0x%lx)",
304                 stuff->mode);
305
306             return reply;
307         }
308
309     default:
310             break;
311     }
312
313     return reply;
314 }
315
316
317 static char *
318 _EvlogRequestXextXtest(EvlogInfo *evinfo, int detail_level, char *reply, int *len)
319 {
320     xReq *req = evinfo->req.ptr;
321
322     switch (req->data)
323     {
324     case X_XTestGetVersion:
325         {
326             xXTestGetVersionReq *stuff = (xXTestGetVersionReq *)req;
327             REPLY (": MajorVersion(%d) MinorVersion(%d)",
328                 stuff->majorVersion,
329                 stuff->minorVersion);
330
331             return reply;
332         }
333
334     case X_XTestCompareCursor:
335         {
336             xXTestCompareCursorReq *stuff = (xXTestCompareCursorReq *)req;
337             REPLY (": XID(0x%lx) Cursor(0x%lx)",
338                 stuff->window,
339                 stuff->cursor);
340
341             return reply;
342         }
343
344     case X_XTestFakeInput:
345         {
346             xXTestFakeInputReq *stuff = (xXTestFakeInputReq *)req;
347             REPLY (": XID(0x%lx) coord(%d,%d)",
348                 stuff->root,
349                 stuff->rootX,
350                 stuff->rootY);
351
352             if (detail_level >= EVLOG_PRINT_DETAIL)
353             {
354                 REPLY (" type(%d) detail(%d) time(%lums) device_id(%d)",
355                     stuff->type,
356                     stuff->detail,
357                     stuff->time,
358                     stuff->deviceid);
359             }
360
361             return reply;
362         }
363     }
364
365     return reply;
366 }
367
368 static char *
369 _EvlogRequestXextShape(EvlogInfo *evinfo, int detail_level, char *reply, int *len)
370 {
371     xReq *req = evinfo->req.ptr;
372
373     switch (req->data)
374     {
375     case X_ShapeRectangles:
376         {
377             xShapeRectanglesReq *stuff = (xShapeRectanglesReq *)req;
378             REPLY (": XID(0x%lx) coord(%d,%d)",
379                 stuff->dest,
380                 stuff->xOff,
381                 stuff->yOff);
382
383             if (detail_level >= EVLOG_PRINT_DETAIL)
384             {
385                 int i;
386                 int nrect;
387                 xRectangle *prect;
388                 const char *destKind, *ordering;
389                 char  ddestKind[10], dordering[10];
390
391                 switch (stuff->destKind)
392                 {
393                     case ShapeBounding:  destKind = "ShapeBounding"; break;
394                     case ShapeClip:  destKind = "ShapeClip"; break;
395                     case ShapeInput:  destKind = "ShapeInput"; break;
396                     default:  destKind = ddestKind; sprintf (ddestKind, "%d", stuff->destKind); break;
397                 }
398
399                 switch (stuff->ordering)
400                 {
401                     case Unsorted:  ordering = "Unsorted"; break;
402                     case YSorted:  ordering = "YSorted"; break;
403                     case YXSorted:  ordering = "YXSorted"; break;
404                     case YXBanded:  ordering = "YXBanded"; break;
405                     default:  ordering = dordering; sprintf (dordering, "%d", stuff->ordering); break;
406                 }
407
408                 nrect = ((stuff->length * 4) - sizeof(xShapeRectanglesReq)) / sizeof(xRectangle);
409                 prect = (xRectangle *) &stuff[1];
410
411                 REPLY (" op(%d) destKind(%s) ordering(%s) nrect(%d)",
412                     stuff->op,
413                     destKind,
414                     ordering,
415                     nrect);
416
417                 REPLY ("\n");
418                 REPLY ("%67s Region", " ");
419                 REPLY ("(");
420
421                 for (i = 0 ; i < nrect ; i++)
422                 {
423                     REPLY("[%d,%d %dx%d]", 
424                         prect[i].x,
425                         prect[i].y,
426                         prect[i].width,
427                         prect[i].height);
428
429                     if(i != nrect - 1)
430                         REPLY (", ");
431                 }
432
433                 REPLY (")");
434             }
435
436             return reply;
437         }
438
439     case X_ShapeMask:
440         {
441             xShapeMaskReq *stuff = (xShapeMaskReq *)req;
442             REPLY (": XID(0x%lx) coord(%d,%d) src(0x%lx)",
443                 stuff->dest,
444                 stuff->xOff,
445                 stuff->yOff,
446                 stuff->src);
447
448             if (detail_level >= EVLOG_PRINT_DETAIL)
449             {
450                 const char *destKind;
451                 char  ddestKind[10];
452
453                 switch (stuff->destKind)
454                 {
455                     case ShapeBounding:  destKind = "ShapeBounding"; break;
456                     case ShapeClip:  destKind = "ShapeClip"; break;
457                     case ShapeInput:  destKind = "ShapeInput"; break;
458                     default:  destKind = ddestKind; sprintf (ddestKind, "%d", stuff->destKind); break;
459                 }
460
461                 REPLY (" op(%d) destKind(%s)",
462                     stuff->op,
463                     destKind);
464             }
465
466             return reply;
467         }
468
469     case X_ShapeCombine:
470         {
471             xShapeCombineReq *stuff = (xShapeCombineReq *)req;
472             REPLY (": XID(0x%lx) coord(%d,%d) src(0x%lx)",
473                 stuff->dest,
474                 stuff->xOff,
475                 stuff->yOff,
476                 stuff->src);
477
478             if (detail_level >= EVLOG_PRINT_DETAIL)
479             {
480                 const char *destKind, *srcKind;
481                 char  ddestKind[10], dsrcKind[10];
482
483                 switch (stuff->destKind)
484                 {
485                     case ShapeBounding:  destKind = "ShapeBounding"; break;
486                     case ShapeClip:  destKind = "ShapeClip"; break;
487                     case ShapeInput:  destKind = "ShapeInput"; break;
488                     default:  destKind = ddestKind; sprintf (ddestKind, "%d", stuff->destKind); break;
489                 }
490
491                 switch (stuff->srcKind)
492                 {
493                     case ShapeBounding:  srcKind = "ShapeBounding"; break;
494                     case ShapeClip:  srcKind = "ShapeClip"; break;
495                     case ShapeInput:  srcKind = "ShapeInput"; break;
496                     default:  srcKind = dsrcKind; sprintf (dsrcKind, "%d", stuff->srcKind); break;
497                 }
498
499                 REPLY (" op(%d) destKind(%s) srcKind(%s)",
500                     stuff->op,
501                     destKind,
502                     srcKind);
503             }
504
505             return reply;
506         }
507
508     case X_ShapeOffset:
509         {
510             xShapeOffsetReq *stuff = (xShapeOffsetReq *)req;
511             REPLY (": XID(0x%lx) coord(%d,%d)",
512                 stuff->dest,
513                 stuff->xOff,
514                 stuff->yOff);
515
516             if (detail_level >= EVLOG_PRINT_DETAIL)
517             {
518                 const char *destKind;
519                 char  ddestKind[10];
520
521                 switch (stuff->destKind)
522                 {
523                     case ShapeBounding:  destKind = "ShapeBounding"; break;
524                     case ShapeClip:  destKind = "ShapeClip"; break;
525                     case ShapeInput:  destKind = "ShapeInput"; break;
526                     default:  destKind = ddestKind; sprintf (ddestKind, "%d", stuff->destKind); break;
527                 }
528
529                 REPLY (" destKind(%s)",
530                     destKind);
531             }
532
533             return reply;
534         }
535
536     case X_ShapeQueryExtents:
537         {
538             xShapeQueryExtentsReq *stuff = (xShapeQueryExtentsReq *)req;
539             REPLY (": XID(0x%lx)",
540                 stuff->window);
541
542             return reply;
543         }
544
545     case X_ShapeSelectInput:
546         {
547             xShapeSelectInputReq *stuff = (xShapeSelectInputReq *)req;
548             REPLY (": XID(0x%lx)",
549                 stuff->window);
550
551             if (detail_level >= EVLOG_PRINT_DETAIL)
552             {
553                 REPLY (" enable(%s)",
554                     stuff->enable ? "YES" : "NO");
555             }
556
557             return reply;
558         }
559
560     case X_ShapeInputSelected:
561         {
562             xShapeInputSelectedReq *stuff = (xShapeInputSelectedReq *)req;
563             REPLY (": XID(0x%lx)",
564                 stuff->window);
565
566             return reply;
567         }
568
569     case X_ShapeGetRectangles:
570         {
571             xShapeGetRectanglesReq *stuff = (xShapeGetRectanglesReq *)req;
572             REPLY (": XID(0x%lx)",
573                 stuff->window);
574
575             if (detail_level >= EVLOG_PRINT_DETAIL)
576             {
577                 const char *kind;
578                 char  dkind[10];
579
580                 switch (stuff->kind)
581                 {
582                     case ShapeBounding:  kind = "ShapeBounding"; break;
583                     case ShapeClip:  kind = "ShapeClip"; break;
584                     case ShapeInput:  kind = "ShapeInput"; break;
585                     default:  kind = dkind; sprintf (dkind, "%d", stuff->kind); break;
586                 }
587
588                 REPLY (" kind(%s)",
589                     kind);
590             }
591
592             return reply;
593         }
594
595     default:
596             break;
597     }
598
599     return reply;
600 }
601
602 static char *
603 _EvlogEventXextDpms (EvlogInfo *evinfo, int first_base, int detail_level, char *reply, int *len)
604 {
605 #if 0
606     xEvent *evt = evinfo->evt.ptr;
607
608     switch ((evt->u.u.type & 0x7F) - first_base)
609     {
610
611     default:
612             break;
613     }
614 #endif
615     return reply;
616 }
617
618
619 static char *
620 _EvlogEventXextShm (EvlogInfo *evinfo, int first_base, int detail_level, char *reply, int *len)
621 {
622     xEvent *evt = evinfo->evt.ptr;
623
624     switch ((evt->u.u.type & 0x7F) - first_base)
625     {
626     case ShmCompletion:
627         {
628             xShmCompletionEvent *stuff = (xShmCompletionEvent *) evt;
629             REPLY (": XID(0x%lx)",
630                 stuff->drawable);
631
632             if (detail_level >= EVLOG_PRINT_DETAIL)
633             {
634                 REPLY (" sequence_num(%d) major_event(%d) minor_event(%d) shmseg(0x%lx) offset(%ld)",
635                     stuff->sequenceNumber,
636                     stuff->majorEvent,
637                     stuff->minorEvent,
638                     stuff->shmseg,
639                     stuff->offset);
640             }
641             return reply;
642         }
643
644     default:
645             break;
646     }
647
648     return reply;
649 }
650
651
652 static char *
653 _EvlogEventXextSync (EvlogInfo *evinfo, int first_base, int detail_level, char *reply, int *len)
654 {
655     xEvent *evt = evinfo->evt.ptr;
656
657     switch ((evt->u.u.type & 0x7F) - first_base)
658     {
659     case XSyncCounterNotify:
660         {
661             xSyncCounterNotifyEvent *stuff = (xSyncCounterNotifyEvent *) evt;
662             REPLY (": XID(0x%lx) WaitValue(0x%lx/0x%lx) CounterValue(0x%lx/0x%lx)",
663                 stuff->counter,
664                 stuff->wait_value_hi,
665                 stuff->wait_value_lo,
666                 stuff->counter_value_hi,
667                 stuff->counter_value_lo);
668
669             if (detail_level >= EVLOG_PRINT_DETAIL)
670             {
671                 REPLY ("\n");
672                 REPLY ("%67s sequence_num(%d) time(%lums) count(%d) destroyed(%s)",
673                     " ",
674                     stuff->sequenceNumber,
675                     stuff->time,
676                     stuff->count,
677                     stuff->destroyed ? "YES" : "NO");
678             }
679
680             return reply;
681         }
682
683     case XSyncAlarmNotify:
684         {
685             xSyncAlarmNotifyEvent *stuff = (xSyncAlarmNotifyEvent *) evt;
686             REPLY (": XID(0x%lx) CounterValue(0x%lx/0x%lx) AlarmValue(0x%lx/0x%lx)",
687                 stuff->alarm,
688                 stuff->counter_value_hi,
689                 stuff->counter_value_lo,
690                 stuff->alarm_value_hi,
691                 stuff->alarm_value_lo);
692
693             if (detail_level >= EVLOG_PRINT_DETAIL)
694             {
695                 REPLY ("\n");
696                 REPLY ("%67s sequence_num(%d) time(%lums) state(%d)",
697                     " ",
698                     stuff->sequenceNumber,
699                     stuff->time,
700                     stuff->state);
701             }
702
703             return reply;
704         }
705
706     default:
707             break;
708     }
709
710     return reply;
711 }
712
713
714 static char *
715 _EvlogEventXextXtestExt1 (EvlogInfo *evinfo, int first_base, int detail_level, char *reply, int *len)
716 {
717     xEvent *evt = evinfo->evt.ptr;
718
719     switch ((evt->u.u.type & 0x7F) - first_base)
720     {
721
722     default:
723             break;
724     }
725
726     return reply;
727 }
728
729 static char *
730 _EvlogEventXextXtest (EvlogInfo *evinfo, int first_base, int detail_level, char *reply, int *len)
731 {
732     xEvent *evt = evinfo->evt.ptr;
733
734     switch ((evt->u.u.type & 0x7F) - first_base)
735     {
736
737     default:
738             break;
739     }
740
741     return reply;
742 }
743
744 static char *
745 _EvlogEventXextShape (EvlogInfo *evinfo, int first_base, int detail_level, char *reply, int *len)
746 {
747     xEvent *evt = evinfo->evt.ptr;
748
749     switch ((evt->u.u.type & 0x7F) - first_base)
750     {
751     case ShapeNotify:
752         {
753             xShapeNotifyEvent *stuff = (xShapeNotifyEvent *) evt;
754             REPLY (": XID(0x%lx) coord(%d,%d %dx%d)",
755                 stuff->window,
756                 stuff->x,
757                 stuff->y,
758                 stuff->width,
759                 stuff->height);
760
761             if (detail_level >= EVLOG_PRINT_DETAIL)
762             {
763                 const char *kind;
764                 char dkind[10];
765
766                 switch (stuff->kind)
767                 {
768                     case ShapeBounding:  kind = "ShapeBounding"; break;
769                     case ShapeClip:  kind = "ShapeClip"; break;
770                     case ShapeInput:  kind = "ShapeInput"; break;
771                     default:  kind = dkind; sprintf (dkind, "%d", stuff->kind); break;
772                 }
773
774
775                 REPLY ("\n");
776                 REPLY ("%67s kind(%s) sequence_num(%d) time(%lums) shaped(%s)",
777                     " ",
778                     kind,
779                     stuff->sequenceNumber,
780                     stuff->time,
781                     stuff->shaped ? "EXIST" : "NON_EXIST");
782             }
783
784             return reply;
785         }
786
787     default:
788             break;
789     }
790
791     return reply;
792 }
793
794 static char *
795 _EvlogReplyXextDpms (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
796 {
797     xGenericReply *rep = evinfo->rep.ptr;
798
799     switch (evinfo->rep.reqData)
800     {
801     case X_DPMSSetTimeouts:
802         {
803             if (evinfo->rep.isStart)
804             {
805                 xDPMSGetTimeoutsReply *stuff = (xDPMSGetTimeoutsReply *)rep;
806                 REPLY (": Standby(%usec) Suspend(%usec) off(%usec) sequence_num(%d)",
807                     stuff->standby,
808                     stuff->suspend,
809                     stuff->off,
810                     stuff->sequenceNumber);
811             }
812             else
813             {
814                 return reply;
815             }
816
817             return reply;
818         }
819
820     default:
821             break;
822     }
823
824     return reply;
825 }
826
827 static char *
828 _EvlogReplyXextShm (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
829 {
830     xGenericReply *rep = evinfo->rep.ptr;
831
832     switch (evinfo->rep.reqData)
833     {
834     case X_ShmGetImage:
835         {
836             if (evinfo->rep.isStart)
837             {
838                 xShmGetImageReply *stuff = (xShmGetImageReply *)rep;
839                 REPLY (": Visual(0x%lx) size(%ld) sequence_num(%d)",
840                     stuff->visual,
841                     stuff->size,
842                     stuff->sequenceNumber);
843             }
844             else
845             {
846                 return reply;
847             }
848
849             return reply;
850         }
851
852     default:
853             break;
854     }
855
856     return reply;
857 }
858
859 static char *
860 _EvlogReplyXextSync (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
861 {
862     xGenericReply *rep = evinfo->rep.ptr;
863
864     switch (evinfo->rep.reqData)
865     {
866         case X_SyncQueryCounter:
867         {
868             if (evinfo->rep.isStart)
869             {
870                 xSyncQueryCounterReply *stuff = (xSyncQueryCounterReply *)rep;
871                 REPLY (": Value(0x%lx/0x%lx) sequence_num(%d)",
872                     stuff->value_hi,
873                     stuff->value_lo,
874                     stuff->sequenceNumber);
875             }
876             else
877             {
878                 return reply;
879             }
880
881             return reply;
882         }
883
884     default:
885             break;
886     }
887
888     return reply;
889 }
890
891 static char *
892 _EvlogReplyXextXtestExt1 (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
893 {
894     xGenericReply *rep = evinfo->rep.ptr;
895
896     switch (evinfo->rep.reqData)
897     {
898         case X_TestQueryInputSize:
899         {
900             if (evinfo->rep.isStart)
901             {
902                 xTestQueryInputSizeReply *stuff = (xTestQueryInputSizeReply *)rep;
903                 REPLY (": sizeReturn(0x%lx) sequence_num(%d)",
904                     stuff->size_return,
905                     stuff->sequenceNumber);
906             }
907             else
908             {
909                 return reply;
910             }
911
912             return reply;
913         }
914
915     default:
916             break;
917     }
918
919     return reply;
920 }
921
922 static char *
923 _EvlogReplyXextXtest (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
924 {
925     xGenericReply *rep = evinfo->rep.ptr;
926
927     switch (evinfo->rep.reqData)
928     {
929     case X_XTestGetVersion:
930         {
931             if (evinfo->rep.isStart)
932             {
933                 xXTestGetVersionReply *stuff = (xXTestGetVersionReply *)rep;
934                 REPLY (": MinorVersion(%d) sequence_num(%d)",
935                     stuff->minorVersion,
936                     stuff->sequenceNumber);
937             }
938             else
939             {
940                 return reply;
941             }
942
943             return reply;
944         }
945
946     default:
947             break;
948     }
949
950     return reply;
951 }
952
953 static char *
954 _EvlogReplyXextShape(EvlogInfo *evinfo, int detail_level, char *reply, int *len)
955 {
956     xGenericReply *rep = evinfo->rep.ptr;
957
958     switch (evinfo->rep.reqData)
959     {
960     case X_ShapeQueryVersion:
961         {
962             if (evinfo->rep.isStart)
963             {
964                 xShapeQueryVersionReply *stuff = (xShapeQueryVersionReply *)rep;
965                 REPLY (": MajorVersion(%d) MinorVersion(%d)",
966                     stuff->majorVersion,
967                     stuff->minorVersion);
968             }
969             else
970             {
971                 return reply;
972             }
973
974             return reply;
975         }
976
977     case X_ShapeQueryExtents:
978         {
979             if (evinfo->rep.isStart)
980             {
981                 xShapeQueryExtentsReply *stuff = (xShapeQueryExtentsReply *)rep;
982
983                 REPLY (": bounding_shaped(%s)",
984                     stuff->boundingShaped ? "YES" : "NO");
985
986                 if (stuff->boundingShaped)
987                     REPLY (" bounding(%d,%d %dx%d)",
988                         stuff->xClipShape,
989                         stuff->yClipShape,
990                         stuff->widthClipShape,
991                         stuff->heightClipShape);
992                 else
993                     REPLY (" bounding(None)");
994
995
996                 REPLY (" clip_shaped(%s)",
997                     stuff->clipShaped ? "YES" : "NO");
998
999                 if (stuff->boundingShaped)
1000                     REPLY (" clip(%d,%d %dx%d)",
1001                         stuff->xBoundingShape,
1002                         stuff->yBoundingShape,
1003                         stuff->widthBoundingShape,
1004                         stuff->heightBoundingShape);
1005                 else
1006                     REPLY (" clip(None)");
1007
1008             }
1009             else
1010             {
1011                 return reply;
1012             }
1013
1014             return reply;
1015         }
1016
1017     case X_ShapeInputSelected:
1018         {
1019             if (evinfo->rep.isStart)
1020             {
1021                 xShapeInputSelectedReply *stuff = (xShapeInputSelectedReply *)rep;
1022
1023                 REPLY (" enable(%s)",
1024                     stuff->enabled ? "YES" : "NO");
1025             }
1026             else
1027             {
1028                 return reply;
1029             }
1030
1031             return reply;
1032         }
1033
1034     case X_ShapeGetRectangles:
1035         {
1036             if (evinfo->rep.isStart)
1037             {
1038                 xShapeGetRectanglesReply *stuff = (xShapeGetRectanglesReply *)rep;
1039
1040                 const char *ordering;
1041                 char dordering[10];
1042
1043                 switch (stuff->ordering)
1044                 {
1045                     case Unsorted:  ordering = "Unsorted"; break;
1046                     case YSorted:  ordering = "YSorted"; break;
1047                     case YXSorted:  ordering = "YXSorted"; break;
1048                     case YXBanded:  ordering = "YXBanded"; break;
1049                     default:  ordering = dordering; sprintf (dordering, "%d", stuff->ordering); break;
1050                 }
1051                 REPLY (": ordering(%s) nrects(%ld)",
1052                     ordering,
1053                     stuff->nrects);
1054             }
1055             else
1056             {
1057                 xRectangle *stuff = (xRectangle *)rep;
1058                 int i;
1059
1060                 REPLY ("Region");
1061                 REPLY ("(");
1062                 for (i = 0 ; i < evinfo->rep.size / sizeof(xRectangle) ; i ++)
1063                 {
1064                     REPLY ("[%d,%d %dx%d]",
1065                         stuff->x,
1066                         stuff->y,
1067                         stuff->width,
1068                         stuff->height);
1069
1070                     if(i != evinfo->rep.size / sizeof(xRectangle) - 1)
1071                         REPLY (", ");
1072                 }
1073                 REPLY (")");
1074
1075                 return reply;
1076             }
1077
1078             return reply;
1079         }
1080
1081     default:
1082             break;
1083     }
1084
1085     return reply;
1086 }
1087
1088 void
1089 xDbgEvlogXextDpmsGetBase (ExtensionInfo *extinfo)
1090 {
1091 #ifdef XDBG_CLIENT
1092     RETURN_IF_FAIL (extinfo != NULL);
1093
1094     extinfo->req_func = _EvlogRequestXextDpms;
1095     extinfo->evt_func = _EvlogEventXextDpms;
1096     extinfo->rep_func = _EvlogReplyXextDpms;
1097 #else
1098     ExtensionEntry *xext = CheckExtension (DPMSExtensionName);
1099     RETURN_IF_FAIL (xext != NULL);
1100     RETURN_IF_FAIL (extinfo != NULL);
1101
1102     extinfo->opcode = xext->base;
1103     extinfo->evt_base = xext->eventBase;
1104     extinfo->err_base = xext->errorBase;
1105     extinfo->req_func = _EvlogRequestXextDpms;
1106     extinfo->evt_func = _EvlogEventXextDpms;
1107     extinfo->rep_func = _EvlogReplyXextDpms;
1108 #endif
1109 }
1110
1111
1112 void
1113 xDbgEvlogXextShmGetBase (ExtensionInfo *extinfo)
1114 {
1115 #ifdef XDBG_CLIENT
1116     RETURN_IF_FAIL (extinfo != NULL);
1117
1118     extinfo->req_func = _EvlogRequestXextShm;
1119     extinfo->evt_func = _EvlogEventXextShm;
1120     extinfo->rep_func = _EvlogReplyXextShm;
1121 #else
1122     ExtensionEntry *xext = CheckExtension (SHMNAME);
1123     RETURN_IF_FAIL (xext != NULL);
1124     RETURN_IF_FAIL (extinfo != NULL);
1125
1126     extinfo->opcode = xext->base;
1127     extinfo->evt_base = xext->eventBase;
1128     extinfo->err_base = xext->errorBase;
1129     extinfo->req_func = _EvlogRequestXextShm;
1130     extinfo->evt_func = _EvlogEventXextShm;
1131     extinfo->rep_func = _EvlogReplyXextShm;
1132 #endif
1133 }
1134
1135
1136 void
1137 xDbgEvlogXextSyncGetBase (ExtensionInfo *extinfo)
1138 {
1139 #ifdef XDBG_CLIENT
1140     RETURN_IF_FAIL (extinfo != NULL);
1141
1142     extinfo->req_func = _EvlogRequestXextSync;
1143     extinfo->evt_func = _EvlogEventXextSync;
1144     extinfo->rep_func = _EvlogReplyXextSync;
1145 #else
1146     ExtensionEntry *xext = CheckExtension (SYNC_NAME);
1147     RETURN_IF_FAIL (xext != NULL);
1148     RETURN_IF_FAIL (extinfo != NULL);
1149
1150     extinfo->opcode = xext->base;
1151     extinfo->evt_base = xext->eventBase;
1152     extinfo->err_base = xext->errorBase;
1153     extinfo->req_func = _EvlogRequestXextSync;
1154     extinfo->evt_func = _EvlogEventXextSync;
1155     extinfo->rep_func = _EvlogReplyXextSync;
1156 #endif
1157
1158 }
1159
1160
1161 void
1162 xDbgEvlogXextXtestExt1GetBase (ExtensionInfo *extinfo)
1163 {
1164 #ifdef XDBG_CLIENT
1165     RETURN_IF_FAIL (extinfo != NULL);
1166
1167     extinfo->req_func = _EvlogRequestXextXtestExt1;
1168     extinfo->evt_func = _EvlogEventXextXtestExt1;
1169     extinfo->rep_func = _EvlogReplyXextXtestExt1;
1170 #else
1171     ExtensionEntry *xext = CheckExtension (XTestEXTENSION_NAME);
1172     RETURN_IF_FAIL (xext != NULL);
1173     RETURN_IF_FAIL (extinfo != NULL);
1174
1175     extinfo->opcode = xext->base;
1176     extinfo->evt_base = xext->eventBase;
1177     extinfo->err_base = xext->errorBase;
1178     extinfo->req_func = _EvlogRequestXextXtestExt1;
1179     extinfo->evt_func = _EvlogEventXextXtestExt1;
1180     extinfo->rep_func = _EvlogReplyXextXtestExt1;
1181 #endif
1182
1183 }
1184
1185
1186 void
1187 xDbgEvlogXextXtestGetBase (ExtensionInfo *extinfo)
1188 {
1189 #ifdef XDBG_CLIENT
1190     RETURN_IF_FAIL (extinfo != NULL);
1191
1192     extinfo->req_func = _EvlogRequestXextXtest;
1193     extinfo->evt_func = _EvlogEventXextXtest;
1194     extinfo->rep_func = _EvlogReplyXextXtest;
1195 #else
1196     ExtensionEntry *xext = CheckExtension (XTestExtensionName);
1197     RETURN_IF_FAIL (xext != NULL);
1198     RETURN_IF_FAIL (extinfo != NULL);
1199
1200     extinfo->opcode = xext->base;
1201     extinfo->evt_base = xext->eventBase;
1202     extinfo->err_base = xext->errorBase;
1203     extinfo->req_func = _EvlogRequestXextXtest;
1204     extinfo->evt_func = _EvlogEventXextXtest;
1205     extinfo->rep_func = _EvlogReplyXextXtest;
1206 #endif
1207 }
1208
1209 void
1210 xDbgEvlogXextShapeGetBase (ExtensionInfo *extinfo)
1211 {
1212 #ifdef XDBG_CLIENT
1213     RETURN_IF_FAIL (extinfo != NULL);
1214
1215     extinfo->req_func = _EvlogRequestXextShape;
1216     extinfo->evt_func = _EvlogEventXextShape;
1217     extinfo->rep_func = _EvlogReplyXextShape;
1218 #else
1219     ExtensionEntry *xext = CheckExtension (SHAPENAME);
1220     RETURN_IF_FAIL (xext != NULL);
1221     RETURN_IF_FAIL (extinfo != NULL);
1222
1223     extinfo->opcode = xext->base;
1224     extinfo->evt_base = xext->eventBase;
1225     extinfo->err_base = xext->errorBase;
1226     extinfo->req_func = _EvlogRequestXextShape;
1227     extinfo->evt_func = _EvlogEventXextShape;
1228     extinfo->rep_func = _EvlogReplyXextShape;
1229 #endif
1230 }