1
From 9950e5b2e2019698a3ddc3eac608a43a974860ea Mon Sep 17 00:00:00 2001
2
From: Chase Douglas <chase.douglas@canonical.com>
3
Date: Tue, 25 Jan 2011 22:35:07 -0500
4
Subject: [PATCH] Gesture patch
9
src/evdev-grail.c | 304 ++++++++++++++++++++++++++++++++++++++++++++++++++++
10
src/evdev-grail.h | 9 ++
11
src/evdev.c | 28 ++++--
13
src/gestureproto.h | 132 +++++++++++++++++++++++
14
7 files changed, 493 insertions(+), 9 deletions(-)
15
create mode 100644 src/evdev-grail.c
16
create mode 100644 src/evdev-grail.h
17
create mode 100644 src/gestureproto.h
1
diff --git a/configure.ac b/configure.ac
2
index b4b0bad..86a18ae 100644
21
@@ -65,6 +65,22 @@ sdkdir=`$PKG_CONFIG --variable=sdkdir xo
5
@@ -68,6 +68,22 @@ sdkdir=`$PKG_CONFIG --variable=sdkdir xorg-server`
22
6
AC_ARG_WITH([sdkdir], [], [sdkdir="$withval"])
42
26
AC_SUBST([DRIVER_NAME])
28
diff --git a/src/Makefile.am b/src/Makefile.am
29
index b8d0dd9..7d05a50 100644
44
30
--- a/src/Makefile.am
45
31
+++ b/src/Makefile.am
46
@@ -32,8 +32,15 @@ AM_CPPFLAGS =-I$(top_srcdir)/include
47
@DRIVER_NAME@_drv_la_LDFLAGS = -module -avoid-version
32
@@ -29,12 +29,17 @@ AM_CFLAGS = $(XORG_CFLAGS) $(CWARNFLAGS)
33
AM_CPPFLAGS =-I$(top_srcdir)/include
35
@DRIVER_NAME@_drv_la_LTLIBRARIES = @DRIVER_NAME@_drv.la
36
-@DRIVER_NAME@_drv_la_LDFLAGS = -module -avoid-version
37
+@DRIVER_NAME@_drv_la_LDFLAGS = -module -avoid-version @GRAIL_LIBS@
38
@DRIVER_NAME@_drv_la_LIBADD = $(MTDEV_LIBS)
48
39
@DRIVER_NAME@_drv_ladir = @inputdir@
50
+@DRIVER_NAME@_drv_la_LIBADD = @GRAIL_LIBS@
53
42
+GRAIL_SRC=evdev-grail.c evdev-grail.h
203
195
+ memset(clients, 0, sizeof(struct grail_client_info) * max_clients);
197
+ /* Find the root window. */
198
+ for (root_window = child_window; root_window->parent;
199
+ root_window = root_window->parent);
202
+ * Check for a root client with SYSFLAG1 set. SYSFLAG1 is effectively an
203
+ * active grab for system gestures. We assume only one client has SYSFLAG1
206
+ window = child_window;
209
+ /* Check if any gestures have been selected on this window. */
210
+ if (wGestureMasks(window))
212
+ GestureClientsPtr client;
214
+ /* For each client */
215
+ for (client = wGestureMasks(window)->clients; client;
216
+ client = client->next)
220
+ /* If the client has set the SYSFLAG1 bit */
221
+ if (BitIsOn(client->gestureMask[0], GRAIL_TYPE_SYSFLAG1))
223
+ /* For each recognized gesture */
224
+ grail_mask_foreach(type, types, type_bytes)
226
+ if (type == GRAIL_TYPE_SYSFLAG1)
230
+ * Check if this client selected for this gesture.
231
+ * Request may be for this device or all devices.
233
+ if (BitIsOn(client->gestureMask[pInfo->dev->id], type) ||
234
+ BitIsOn(client->gestureMask[0], type))
237
+ /* Set up new client in array */
238
+ clients[0].id.client = CLIENT_ID(client->resource);
239
+ clients[0].id.root = root_window->drawable.id;
240
+ clients[0].id.child = child_window->drawable.id;
241
+ clients[0].id.event = root_window->drawable.id;
242
+ grail_mask_clear(clients[0].mask,
243
+ DIM_GRAIL_TYPE_BYTES);
247
+ /* Set this gesture bit in the client's gesture mask */
248
+ SetBit(clients[0].mask, type);
254
+ * Either we found a gesture, or we stop looking for SYSFLAG1
258
+ SetBit(clients[0].mask, GRAIL_TYPE_SYSFLAG1);
266
+ window = window->parent;
206
270
+ * Traverse the window hierarchy looking for a window with a client
207
271
+ * selecting for one of the recognized gestures.
222
286
+ /* For each recognized gesture */
223
287
+ grail_mask_foreach(type, types, type_bytes)
289
+ if (type == GRAIL_TYPE_SYSFLAG1)
225
292
+ /* Check if any client selected for this gesture on the window */
226
293
+ if (BitIsOn(wGestureMasks(window)->mask, type))
228
295
+ GestureClientsPtr client;
231
+ for (root_window = window; root_window->parent;
232
+ root_window = root_window->parent);
234
297
+ /* For each client that selected for gestures on this window */
235
298
+ for (client = wGestureMasks(window)->clients; client;
236
299
+ client = client->next)
394
462
#define ArrayLength(a) (sizeof(a) / (sizeof((a)[0])))
396
464
#define MIN_KEYCODE 8
397
@@ -829,7 +836,7 @@ EvdevProcessSyncEvent(InputInfoPtr pInfo
465
@@ -897,7 +904,7 @@ EvdevProcessSyncEvent(InputInfoPtr pInfo, struct input_event *ev)
398
466
* Process the events from the device; nothing is actually posted to the server
399
467
* until an EV_SYN event is received.
403
471
EvdevProcessEvent(InputInfoPtr pInfo, struct input_event *ev)
405
473
switch (ev->type) {
406
@@ -863,7 +870,14 @@ EvdevReadInput(InputInfoPtr pInfo)
474
@@ -931,17 +938,14 @@ EvdevReadInput(InputInfoPtr pInfo)
408
476
while (len == sizeof(ev))
410
- len = read(pInfo->fd, &ev, sizeof(ev));
412
+ EvdevPtr pEvdev = pInfo->private;
480
EvdevPtr pEvdev = pInfo->private;
483
- len = mtdev_get(pEvdev->mtdev, pInfo->fd, ev, NUM_EVENTS) *
484
- sizeof(struct input_event);
414
485
+ if (pEvdev->grail)
415
486
+ len = grail_pull(pEvdev->grail, pInfo->fd);
488
- len = read(pInfo->fd, &ev, sizeof(ev));
490
- len = read(pInfo->fd, &ev, sizeof(ev));
418
492
+ len = read(pInfo->fd, &ev, sizeof(ev));
421
495
if (errno == ENODEV) /* May happen after resume */
422
@@ -881,6 +895,11 @@ EvdevReadInput(InputInfoPtr pInfo)
496
@@ -959,6 +963,11 @@ EvdevReadInput(InputInfoPtr pInfo)
431
505
/* The kernel promises that we always only read a complete
432
506
* event, so len != sizeof ev is an error. */
433
507
if (len % sizeof(ev[0])) {
434
@@ -1305,7 +1324,7 @@ EvdevAddAbsClass(DeviceIntPtr device)
435
memset(pEvdev->old_vals, -1, num_axes * sizeof(int));
436
atoms = malloc(pEvdev->num_vals * sizeof(Atom));
438
- for (axis = ABS_X; i < MAX_VALUATORS && axis <= ABS_MAX; axis++) {
439
+ for (axis = ABS_X; i < MAX_VALUATORS && axis <= ABS_MISC; axis++) {
440
pEvdev->axis_map[axis] = -1;
441
if (!TestBit(axis, pEvdev->abs_bitmask))
443
@@ -1328,7 +1347,7 @@ EvdevAddAbsClass(DeviceIntPtr device)
447
- for (axis = ABS_X; axis <= ABS_MAX; axis++) {
448
+ for (axis = ABS_X; axis <= ABS_MISC; axis++) {
449
int axnum = pEvdev->axis_map[axis];
450
int resolution = 10000;
452
@@ -1394,6 +1413,8 @@ EvdevAddAbsClass(DeviceIntPtr device)
461
@@ -1761,6 +1782,7 @@ EvdevProc(DeviceIntPtr device, int what)
508
@@ -1613,6 +1622,7 @@ EvdevProc(DeviceIntPtr device, int what)
510
mtdev_close(pEvdev->mtdev);
465
512
+ GrailClose(pInfo);
466
513
EvdevRemoveDevice(pInfo);
467
514
pEvdev->min_maj = 0;
516
@@ -1850,6 +1860,8 @@ EvdevProbe(InputInfoPtr pInfo)
517
xf86Msg(X_PROBED, "%s: Found absolute axes\n", pInfo->name);
518
pEvdev->flags |= EVDEV_ABSOLUTE_EVENTS;
522
if ((TestBit(ABS_X, pEvdev->abs_bitmask) &&
523
TestBit(ABS_Y, pEvdev->abs_bitmask))) {
524
xf86Msg(X_PROBED, "%s: Found x and y absolute axes\n", pInfo->name);
525
diff --git a/src/evdev.h b/src/evdev.h
526
index 3c49e91..6b67104 100644
469
527
--- a/src/evdev.h
470
528
+++ b/src/evdev.h
471
@@ -196,8 +196,14 @@ typedef struct {
529
@@ -205,8 +205,14 @@ typedef struct {
472
530
/* Event queue used to defer keyboard/button events until EV_SYN time. */
474
532
EventQueueRec queue[EVDEV_MAXQUEUE];
483
541
/* Event posting functions */
484
542
void EvdevQueueKbdEvent(InputInfoPtr pInfo, struct input_event *ev, int value);
485
543
void EvdevQueueButtonEvent(InputInfoPtr pInfo, int button, int value);
544
diff --git a/src/gestureproto.h b/src/gestureproto.h
546
index 0000000..a60dcb8
487
548
+++ b/src/gestureproto.h
488
549
@@ -0,0 +1,132 @@