add supplementary log massage of each major extension
[platform/adaptation/xf86-module-xdbg.git] / common / xdbg_evlog_gesture.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/gesture.h>
55 #include <X11/extensions/gestureproto.h>
56
57
58 #include "xdbg_types.h"
59 #include "xdbg_evlog_gesture.h"
60
61 static char *
62 _EvlogRequestGesture(xReq *req, char *reply, int *len)
63 {
64     xReq *stuff = req;
65
66     switch (stuff->data)
67     {
68     case X_GestureSelectEvents:
69         {
70             xGestureSelectEventsReq *stuff = (xGestureSelectEventsReq *)req;
71             REPLY (": XID(0x%lx)",
72                 stuff->window);
73
74             return reply;
75         }
76
77     case X_GestureGetSelectedEvents:
78         {
79             xGestureGetSelectedEventsReq *stuff = (xGestureGetSelectedEventsReq *)req;
80             REPLY (": XID(0x%lx)",
81                 stuff->window);
82
83             return reply;
84         }
85
86     case X_GestureGrabEvent:
87         {
88             xGestureGrabEventReq *stuff = (xGestureGrabEventReq *)req;
89             REPLY (": XID(0x%lx) EventType(0x%lx), Num_finger(%d)",
90                 stuff->window,
91                 stuff->eventType,
92                 stuff->num_finger);
93
94             return reply;
95         }
96
97     case X_GestureUngrabEvent:
98         {
99             xGestureUngrabEventReq *stuff = (xGestureUngrabEventReq *)req;
100             REPLY (": XID(0x%lx) EventType(0x%lx), Num_finger(%d)",
101                 stuff->window,
102                 stuff->eventType,
103                 stuff->num_finger);
104
105             return reply;
106         }
107
108     default:
109             break;
110     }
111
112     return reply;
113 }
114
115 static char *
116 _EvlogEventGesture (xEvent *evt, int first_base, char *reply, int *len)
117 {
118     xEvent *stuff = evt;
119
120     switch ((stuff->u.u.type & 0x7F) - first_base)
121     {
122     case GestureNotifyFlick:
123         {
124             xGestureNotifyFlickEvent *stuff = (xGestureNotifyFlickEvent *) evt;
125             REPLY (": XID(0x%lx) Direction(%d) Distance(%d) Duration(%ldms) Angle(0x%lx)",
126                 stuff->window,
127                 stuff->direction,
128                 stuff->distance,
129                 stuff->duration,
130                 stuff->angle);
131
132             return reply;
133         }
134
135     case GestureNotifyPan:
136         {
137             xGestureNotifyPanEvent *stuff = (xGestureNotifyPanEvent *) evt;
138             REPLY (": XID(0x%lx) Direction(%d) Distance(%d) Duration(%ldms) coord(%d,%d)",
139                 stuff->window,
140                 stuff->direction,
141                 stuff->distance,
142                 stuff->duration,
143                 stuff->dx,
144                 stuff->dy);
145
146             return reply;
147         }
148
149     case GestureNotifyPinchRotation:
150         {
151             xGestureNotifyPinchRotationEvent *stuff = (xGestureNotifyPinchRotationEvent *) evt;
152             REPLY (": XID(0x%lx) Distance(%d) Coord(%d,%d) Zoom(0x%lx) Angle(0x%lx)",
153                 stuff->window,
154                 stuff->distance,
155                 stuff->cx,
156                 stuff->cy,
157                 stuff->zoom,
158                 stuff->angle);
159
160             return reply;
161         }
162
163     case GestureNotifyTap:
164         {
165             xGestureNotifyTapEvent *stuff = (xGestureNotifyTapEvent *) evt;
166             REPLY (": XID(0x%lx) Coord(%d,%d) tapRepeat(%d) Interval(%ldms)",
167                 stuff->window,
168                 stuff->cx,
169                 stuff->cy,
170                 stuff->tap_repeat,
171                 stuff->interval);
172
173             return reply;
174         }
175
176     case GestureNotifyTapNHold:
177         {
178             xGestureNotifyTapNHoldEvent *stuff = (xGestureNotifyTapNHoldEvent *) evt;
179             REPLY (": XID(0x%lx) Coord(%d,%d) Interval(%ldms) Holdtime(%ldms)",
180                 stuff->window,
181                 stuff->cx,
182                 stuff->cy,
183                 stuff->interval,
184                 stuff->holdtime);
185
186             return reply;
187         }
188
189     case GestureNotifyHold:
190         {
191             xGestureNotifyHoldEvent *stuff = (xGestureNotifyHoldEvent *) evt;
192             REPLY (": XID(0x%lx) Coord(%d,%d) Holdtime(%ldms)",
193                 stuff->window,
194                 stuff->cx,
195                 stuff->cy,
196                 stuff->holdtime);
197
198             return reply;
199         }
200
201     case GestureNotifyGroup:
202         {
203             xGestureNotifyGroupEvent *stuff = (xGestureNotifyGroupEvent *) evt;
204             REPLY (": XID(0x%lx) groupID(%d) groupNum(%d)",
205                 stuff->window,
206                 stuff->groupid,
207                 stuff->num_group);
208
209             return reply;
210         }
211
212     default:
213             break;
214     }
215
216     return reply;
217 }
218
219
220 void
221 xDbgEvlogGestureGetBase (void *dpy, ExtensionInfo *extinfo)
222 {
223 #ifdef XDBG_CLIENT
224     Display *d = (Display*)dpy;
225
226     RETURN_IF_FAIL (d != NULL);
227
228     if (!XQueryExtension(d, GESTURE_EXT_NAME, &extinfo->opcode, &extinfo->evt_base, &extinfo->err_base))
229     {
230         fprintf (stderr, "[UTILX] no Gesture extension. \n");
231         return;
232     }
233     extinfo->req_func = _EvlogRequestGesture;
234     extinfo->evt_func = _EvlogEventGesture;
235 #else
236     ExtensionEntry *xext = CheckExtension (GESTURE_EXT_NAME);
237     RETURN_IF_FAIL (xext != NULL);
238
239     extinfo->opcode = xext->base;
240     extinfo->evt_base = xext->eventBase;
241     extinfo->err_base = xext->errorBase;
242     extinfo->req_func = _EvlogRequestGesture;
243     extinfo->evt_func = _EvlogEventGesture;
244 #endif
245 }