add supplementary log massage of each major extension
[platform/adaptation/xf86-module-xdbg.git] / common / xdbg_evlog_randr.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/Xrandr.h>
56 #include <X11/extensions/randrproto.h>
57
58
59 #include "xdbg_types.h"
60 #include "xdbg_evlog_randr.h"
61
62 static char *
63 _EvlogRequestRandr (xReq *req, char *reply, int *len)
64 {
65     xReq *stuff = req;
66
67     switch (stuff->data)
68     {
69     case X_RRGetScreenSizeRange:
70         {
71             xRRGetScreenSizeRangeReq *stuff = (xRRGetScreenSizeRangeReq *)req;
72             REPLY (": XID(0x%lx)",
73                 stuff->window);
74
75             return reply;
76         }
77
78     case X_RRSetScreenSize:
79         {
80             xRRSetScreenSizeReq *stuff = (xRRSetScreenSizeReq *)req;
81             REPLY (": XID(0x%lx) size(%dx%d) milliSize(%ldx%ld)",
82                 stuff->window,
83                 stuff->width,
84                 stuff->height,
85                 stuff->widthInMillimeters,
86                 stuff->heightInMillimeters);
87
88             return reply;
89         }
90
91     case X_RRGetScreenResources:
92         {
93             xRRGetScreenResourcesReq *stuff = (xRRGetScreenResourcesReq *)req;
94             REPLY (": XID(0x%lx)",
95                 stuff->window);
96
97             return reply;
98         }
99
100     case X_RRGetOutputInfo:
101         {
102             xRRGetOutputInfoReq *stuff = (xRRGetOutputInfoReq *)req;
103             REPLY (": XID(0x%lx)",
104                 stuff->output);
105
106             return reply;
107         }
108
109     case X_RRListOutputProperties:
110         {
111             xRRListOutputPropertiesReq *stuff = (xRRListOutputPropertiesReq *)req;
112             REPLY (": XID(0x%lx)",
113                 stuff->output);
114
115             return reply;
116         }
117
118     case X_RRQueryOutputProperty:
119         {
120             xRRQueryOutputPropertyReq *stuff = (xRRQueryOutputPropertyReq *)req;
121             REPLY (": XID(0x%lx) Property(0x%lx)",
122                 stuff->output,
123                 stuff->property);
124
125             return reply;
126         }
127
128     case X_RRConfigureOutputProperty:
129         {
130             xRRConfigureOutputPropertyReq *stuff = (xRRConfigureOutputPropertyReq *)req;
131             REPLY (": XID(0x%lx) Property(0x%lx)",
132                 stuff->output,
133                 stuff->property);
134
135             return reply;
136         }
137
138     case X_RRChangeOutputProperty:
139         {
140             xRRChangeOutputPropertyReq *stuff = (xRRChangeOutputPropertyReq *)req;
141             REPLY (": XID(0x%lx) Property(0x%lx) Type(0x%lx) Format(%d) nUnits(%ld)",
142                 stuff->output,
143                 stuff->property,
144                 stuff->type,
145                 stuff->format,
146                 stuff->nUnits);
147
148             return reply;
149         }
150
151     case X_RRDeleteOutputProperty:
152         {
153             xRRDeleteOutputPropertyReq *stuff = (xRRDeleteOutputPropertyReq *)req;
154             REPLY (": XID(0x%lx) Property(0x%lx)",
155                 stuff->output,
156                 stuff->property);
157
158             return reply;
159         }
160
161     case X_RRGetOutputProperty:
162         {
163             xRRGetOutputPropertyReq *stuff = (xRRGetOutputPropertyReq *)req;
164             REPLY (": XID(0x%lx) Property(0x%lx) Type(0x%lx) longOffset(%ld) longLength(%ld)",
165                 stuff->output,
166                 stuff->property,
167                 stuff->type,
168                 stuff->longOffset,
169                 stuff->longLength);
170
171             return reply;
172         }
173
174     case X_RRGetCrtcInfo:
175         {
176             xRRGetCrtcInfoReq *stuff = (xRRGetCrtcInfoReq *)req;
177             REPLY (": XID(0x%lx)",
178                 stuff->crtc);
179
180             return reply;
181         }
182
183     case X_RRSetCrtcConfig:
184         {
185             xRRSetCrtcConfigReq *stuff = (xRRSetCrtcConfigReq *)req;
186             REPLY (": XID(0x%lx) Coordinate(%d,%d) Rotation(%d)",
187                 stuff->crtc,
188                 stuff->x,
189                 stuff->y,
190                 stuff->rotation);
191
192             return reply;
193         }
194
195     case X_RRGetScreenResourcesCurrent:
196         {
197             xRRGetScreenResourcesCurrentReq *stuff = (xRRGetScreenResourcesCurrentReq *)req;
198             REPLY (": XID(0x%lx)",
199                 stuff->window);
200
201             return reply;
202         }
203
204     default:
205             break;
206     }
207
208     return reply;
209 }
210
211
212 static char *
213 _EvlogEventRandr (xEvent *evt, int first_base, char *reply, int *len)
214 {
215     xEvent *stuff = evt;
216
217     switch ((stuff->u.u.type & 0x7F) - first_base)
218     {
219     case RRScreenChangeNotify:
220         {
221             xRRScreenChangeNotifyEvent *stuff = (xRRScreenChangeNotifyEvent *) evt;
222             REPLY (": Root(0x%lx) Window(0x%lx) sizeID(%d) subPixel(%d) Pixel(%d,%d) Milli(%d,%d)",
223                 stuff->root,
224                 stuff->window,
225                 stuff->sizeID,
226                 stuff->subpixelOrder,
227                 stuff->widthInPixels,
228                 stuff->heightInPixels,
229                 stuff->widthInMillimeters,
230                 stuff->heightInMillimeters);
231
232             return reply;
233         }
234
235     case RRNotify:
236         {
237             switch(stuff->u.u.detail)
238             {
239             case RRNotify_CrtcChange:
240                 {
241                     xRRCrtcChangeNotifyEvent *stuff = (xRRCrtcChangeNotifyEvent *) evt;
242                     REPLY (": XID(0x%lx) Crtc(0x%lx) Mode(0x%lx) size(%udx%ud) coord(%d,%d)",
243                         stuff->window,
244                         stuff->crtc,
245                         stuff->mode,
246                         stuff->width,
247                         stuff->height,
248                         stuff->x,
249                         stuff->y);
250
251                     return reply;
252                 }
253
254             case RRNotify_OutputChange:
255                 {
256                     xRROutputChangeNotifyEvent *stuff = (xRROutputChangeNotifyEvent *) evt;
257                     REPLY (": XID(0x%lx) Output(0x%lx) Crtc(0x%lx) Mode(0x%lx)",
258                         stuff->window,
259                         stuff->output,
260                         stuff->crtc,
261                         stuff->mode);
262
263                     return reply;
264                 }
265
266             case RRNotify_OutputProperty:
267                 {
268                     xRROutputPropertyNotifyEvent *stuff = (xRROutputPropertyNotifyEvent *) evt;
269                     REPLY (": XID(0x%lx) Output(0x%lx) Atom(0x%lx)",
270                         stuff->window,
271                         stuff->output,
272                         stuff->atom);
273
274                     return reply;
275                 }
276
277             case RRNotify_ProviderChange:
278                 {
279                     xRRProviderChangeNotifyEvent *stuff = (xRRProviderChangeNotifyEvent *) evt;
280                     REPLY (": XID(0x%lx) Provider(0x%lx)",
281                         stuff->window,
282                         stuff->provider);
283
284                     return reply;
285                 }
286
287             case RRNotify_ProviderProperty:
288                 {
289                     xRRProviderPropertyNotifyEvent *stuff = (xRRProviderPropertyNotifyEvent *) evt;
290                     REPLY (": XID(0x%lx) Provider(0x%lx) Atom(0x%lx)",
291                         stuff->window,
292                         stuff->provider,
293                         stuff->atom);
294
295                     return reply;
296                 }
297
298             case RRNotify_ResourceChange:
299                 {
300                     xRRResourceChangeNotifyEvent *stuff = (xRRResourceChangeNotifyEvent *) evt;
301                     REPLY (": XID(0x%lx)",
302                         stuff->window);
303
304                     return reply;
305                 }
306
307             default:
308                     break;
309             }
310         }
311
312     default:
313             break;
314     }
315
316     return reply;
317 }
318
319
320 void
321 xDbgEvlogRandrGetBase (void *dpy, ExtensionInfo *extinfo)
322 {
323 #ifdef XDBG_CLIENT
324     Display *d = (Display*)dpy;
325
326     RETURN_IF_FAIL (d != NULL);
327     RETURN_IF_FAIL (extinfo != NULL);
328
329     if (!XQueryExtension(d, RANDR_NAME, &extinfo->opcode, &extinfo->evt_base, &extinfo->err_base))
330     {
331         fprintf (stderr, "[UTILX] no Randr extension. \n");
332         return;
333     }
334     extinfo->req_func = _EvlogRequestRandr;
335     extinfo->evt_func = _EvlogEventRandr;
336 #else
337     ExtensionEntry *xext = CheckExtension (RANDR_NAME);
338     RETURN_IF_FAIL (xext != NULL);
339
340     extinfo->opcode = xext->base;
341     extinfo->evt_base = xext->eventBase;
342     extinfo->err_base = xext->errorBase;
343     extinfo->req_func = _EvlogRequestRandr;
344     extinfo->evt_func = _EvlogEventRandr;
345 #endif
346 }