tizen 2.3 release
[adaptation/xorg/driver/xserver-xorg-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 #include <X11/extensions/composite.h>
57
58 #include "xdbg_types.h"
59 #include "xdbg_evlog_composite.h"
60 #include "xdbg_evlog.h"
61
62 static char *
63 _EvlogRequestComposite(EvlogInfo *evinfo, int detail_level, char *reply, int *len)
64 {
65     xReq *req = evinfo->req.ptr;
66
67     switch (req->data)
68     {
69     case X_CompositeRedirectWindow:
70         {
71             xCompositeRedirectWindowReq *stuff = (xCompositeRedirectWindowReq *)req;
72             REPLY (": XID(0x%x)",
73                 (unsigned int)stuff->window);
74
75             if (detail_level >= EVLOG_PRINT_DETAIL)
76             {
77                 REPLY (" update(%d)",
78                     stuff->update);
79             }
80
81             return reply;
82         }
83
84     case X_CompositeRedirectSubwindows:
85         {
86             xCompositeRedirectSubwindowsReq *stuff = (xCompositeRedirectSubwindowsReq *)req;
87             REPLY (": XID(0x%x)",
88                 (unsigned int)stuff->window);
89
90             if (detail_level >= EVLOG_PRINT_DETAIL)
91             {
92                 REPLY (" update(%d)",
93                     stuff->update);
94             }
95
96             return reply;
97         }
98
99     case X_CompositeUnredirectWindow:
100         {
101             xCompositeUnredirectWindowReq *stuff = (xCompositeUnredirectWindowReq *)req;
102             REPLY (": XID(0x%x)",
103                 (unsigned int)stuff->window);
104
105             if (detail_level >= EVLOG_PRINT_DETAIL)
106             {
107                 REPLY (" update(%d)",
108                     stuff->update);
109             }
110
111             return reply;
112         }
113
114     case X_CompositeUnredirectSubwindows:
115         {
116             xCompositeUnredirectSubwindowsReq *stuff = (xCompositeUnredirectSubwindowsReq *)req;
117             REPLY (": XID(0x%x)",
118                 (unsigned int)stuff->window);
119
120             if (detail_level >= EVLOG_PRINT_DETAIL)
121             {
122                 REPLY (" update(%d)",
123                     stuff->update);
124             }
125
126             return reply;
127         }
128
129     case X_CompositeNameWindowPixmap:
130         {
131             xCompositeNameWindowPixmapReq *stuff = (xCompositeNameWindowPixmapReq *)req;
132             REPLY (": XID(0x%x) Pixmap(0x%x)",
133                 (unsigned int)stuff->window,
134                 (unsigned int)stuff->pixmap);
135
136             return reply;
137         }
138
139 #ifdef _F_INPUT_REDIRECTION_
140     case X_CompositeSetCoordinateTransform:
141         {
142             xCompositeSetCoordinateTransformReq *stuff = (xCompositeSetCoordinateTransformReq *)req;
143             REPLY (": XID(0x%x) (%.3f,%.3f,%.3f) (%.3f,%.3f,%.3f) (%.3f,%.3f,%.3f)",
144                 (unsigned int)stuff->window,
145                 (float)pixman_fixed_to_double(stuff->transform.matrix11), (float)pixman_fixed_to_double(stuff->transform.matrix12), (float)pixman_fixed_to_double(stuff->transform.matrix13),
146                 (float)pixman_fixed_to_double(stuff->transform.matrix21), (float)pixman_fixed_to_double(stuff->transform.matrix22), (float)pixman_fixed_to_double(stuff->transform.matrix23),
147                 (float)pixman_fixed_to_double(stuff->transform.matrix31), (float)pixman_fixed_to_double(stuff->transform.matrix32), (float)pixman_fixed_to_double(stuff->transform.matrix33));
148
149             return reply;
150         }
151 #endif
152
153     default:
154             break;
155     }
156
157     return reply;
158 }
159
160 static char *
161 _EvlogEventComposite (EvlogInfo *evinfo, int first_base, int detail_level, char *reply, int *len)
162 {
163     xEvent *evt = evinfo->evt.ptr;
164
165     switch ((evt->u.u.type & 0x7F) - first_base)
166     {
167
168     default:
169             break;
170     }
171
172     return reply;
173 }
174
175 static char *
176 _EvlogReplyComposite (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
177 {
178 #if 0
179     xGenericReply *rep = evinfo->rep.ptr;
180
181     switch (evinfo->rep.reqData)
182     {
183
184     default:
185             break;
186     }
187
188 #endif
189     return reply;
190 }
191
192 void
193 xDbgEvlogCompositeGetBase (ExtensionInfo *extinfo)
194 {
195 #ifdef XDBG_CLIENT
196     RETURN_IF_FAIL (extinfo != NULL);
197
198     extinfo->req_func = _EvlogRequestComposite;
199     extinfo->evt_func = _EvlogEventComposite;
200     extinfo->rep_func = _EvlogReplyComposite;
201 #else
202     ExtensionEntry *xext = CheckExtension (COMPOSITE_NAME);
203     RETURN_IF_FAIL (xext != NULL);
204     RETURN_IF_FAIL (extinfo != NULL);
205
206     extinfo->opcode = xext->base;
207     extinfo->evt_base = xext->eventBase;
208     extinfo->err_base = xext->errorBase;
209     extinfo->req_func = _EvlogRequestComposite;
210     extinfo->evt_func = _EvlogEventComposite;
211     extinfo->rep_func = _EvlogReplyComposite;
212 #endif
213 }