add supplementary log massage of each major extension
[platform/adaptation/xf86-module-xdbg.git] / common / xdbg_evlog_composite.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 #include <X11/extensions/Xcomposite.h>
55 #include <X11/extensions/compositeproto.h>
56
57 #include "xdbg_types.h"
58 #include "xdbg_evlog_composite.h"
59
60 static char *
61 _EvlogRequestComposite(xReq *req, char *reply, int *len)
62 {
63     xReq *stuff = req;
64
65     switch (stuff->data)
66     {
67     case X_CompositeRedirectWindow:
68         {
69             xCompositeRedirectWindowReq *stuff = (xCompositeRedirectWindowReq *)req;
70             REPLY (": XID(0x%lx) Update(%d)",
71                 stuff->window,
72                 stuff->update);
73
74             return reply;
75         }
76
77     case X_CompositeRedirectSubwindows:
78         {
79             xCompositeRedirectSubwindowsReq *stuff = (xCompositeRedirectSubwindowsReq *)req;
80             REPLY (": XID(0x%lx) Update(%d)",
81                 stuff->window,
82                 stuff->update);
83
84             return reply;
85         }
86
87     case X_CompositeUnredirectWindow:
88         {
89             xCompositeUnredirectWindowReq *stuff = (xCompositeUnredirectWindowReq *)req;
90             REPLY (": XID(0x%lx) Update(%d)",
91                 stuff->window,
92                 stuff->update);
93
94             return reply;
95         }
96
97     case X_CompositeUnredirectSubwindows:
98         {
99             xCompositeUnredirectSubwindowsReq *stuff = (xCompositeUnredirectSubwindowsReq *)req;
100             REPLY (": XID(0x%lx) Update(%d)",
101                 stuff->window,
102                 stuff->update);
103
104             return reply;
105         }
106
107     case X_CompositeNameWindowPixmap:
108         {
109             xCompositeNameWindowPixmapReq *stuff = (xCompositeNameWindowPixmapReq *)req;
110             REPLY (": XID(0x%lx) Pixmap(0x%lx)",
111                 stuff->window,
112                 stuff->pixmap);
113
114             return reply;
115         }
116
117     default:
118             break;
119     }
120
121     return reply;
122 }
123
124 static char *
125 _EvlogEventComposite (xEvent *evt, int first_base, char *reply, int *len)
126 {
127     xEvent *stuff = evt;
128
129     switch ((stuff->u.u.type & 0x7F) - first_base)
130     {
131
132     default:
133             break;
134     }
135
136     return reply;
137 }
138
139
140 void
141 xDbgEvlogCompositeGetBase (void *dpy, ExtensionInfo *extinfo)
142 {
143 #ifdef XDBG_CLIENT
144     Display *d = (Display*)dpy;
145
146     RETURN_IF_FAIL (d != NULL);
147     RETURN_IF_FAIL (extinfo != NULL);
148
149     if (!XQueryExtension(d, COMPOSITE_NAME, &extinfo->opcode, &extinfo->evt_base, &extinfo->err_base))
150     {
151         fprintf (stderr, "[UTILX] no Composite extension. \n");
152         return;
153     }
154     extinfo->req_func = _EvlogRequestComposite;
155     extinfo->evt_func = _EvlogEventComposite;
156 #else
157     ExtensionEntry *xext = CheckExtension (COMPOSITE_NAME);
158     RETURN_IF_FAIL (xext != NULL);
159
160     extinfo->opcode = xext->base;
161     extinfo->evt_base = xext->eventBase;
162     extinfo->err_base = xext->errorBase;
163     extinfo->req_func = _EvlogRequestComposite;
164     extinfo->evt_func = _EvlogEventComposite;
165 #endif
166 }