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