add supplementary log massage of each major extension
[adaptation/xorg/driver/xserver-xorg-module-xdbg.git] / common / xdbg_evlog_damage.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/Xdamage.h>
55 #include <X11/extensions/damageproto.h>
56
57
58 #include "xdbg_types.h"
59 #include "xdbg_evlog_damage.h"
60
61 static char *
62 _EvlogRequestDamage(xReq *req, char *reply, int *len)
63 {
64     xReq *stuff = req;
65
66     switch (stuff->data)
67     {
68     case X_DamageCreate:
69         {
70             xDamageCreateReq *stuff = (xDamageCreateReq *)req;
71             REPLY (": XID(0x%lx) Drawable(0x%lx) level(%d)",
72                 stuff->damage,
73                 stuff->drawable,
74                 stuff->level);
75
76             return reply;
77         }
78
79     case X_DamageDestroy:
80         {
81             xDamageDestroyReq *stuff = (xDamageDestroyReq *)req;
82             REPLY (": XID(0x%lx)",
83                 stuff->damage);
84
85             return reply;
86         }
87
88     default:
89             break;
90     }
91
92     return reply;
93 }
94
95 static char*
96 _EvlogEventDamage (xEvent *evt, int first_base, char *reply, int *len)
97 {
98     xEvent *stuff = evt;
99
100     switch ((stuff->u.u.type & 0x7F) - first_base)
101     {
102     case XDamageNotify:
103         {
104             xDamageNotifyEvent *stuff = (xDamageNotifyEvent*)evt;
105             REPLY (": XID(0x%lx) Damage(0x%lx) area(%d,%d %dx%d) geo(%d,%d %dx%d)",
106                 stuff->drawable,
107                 stuff->damage,
108                 stuff->area.x,
109                 stuff->area.y,
110                 stuff->area.width,
111                 stuff->area.height,
112                 stuff->geometry.x,
113                 stuff->geometry.y,
114                 stuff->geometry.width,
115                 stuff->geometry.height);
116
117             return reply;
118         }
119
120     default:
121             break;
122     }
123
124     return reply;
125 }
126
127 void
128 xDbgEvlogDamageGetBase (void *dpy, ExtensionInfo *extinfo)
129 {
130 #ifdef XDBG_CLIENT
131     Display *d = (Display*)dpy;
132
133     RETURN_IF_FAIL (d != NULL);
134     RETURN_IF_FAIL (extinfo != NULL);
135
136     if (!XQueryExtension(d, DAMAGE_NAME, &extinfo->opcode, &extinfo->evt_base, &extinfo->err_base))
137     {
138         fprintf (stderr, "[UTILX] no Damage extension. \n");
139         return;
140     }
141
142     extinfo->req_func = _EvlogRequestDamage;
143     extinfo->evt_func = _EvlogEventDamage;
144 #else
145     ExtensionEntry *xext = CheckExtension (DAMAGE_NAME);
146     RETURN_IF_FAIL (xext != NULL);
147
148     extinfo->opcode = xext->base;
149     extinfo->evt_base = xext->eventBase;
150     extinfo->err_base = xext->errorBase;
151     extinfo->req_func = _EvlogRequestDamage;
152     extinfo->evt_func = _EvlogEventDamage;
153 #endif
154 }