[mutter/wip/multitouch: 6/8] devices-xi2: Enable touch events



commit 7414abe0dd1c90f6e8f69a031eb963b0d2739fa5
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Aug 2 19:21:36 2011 +0200

    devices-xi2: Enable touch events

 src/core/core.c         |    8 +++++++-
 src/core/devices-xi2.c  |   10 ++++++++++
 src/core/input-events.h |    5 +++++
 3 files changed, 22 insertions(+), 1 deletions(-)
---
diff --git a/src/core/core.c b/src/core/core.c
index f002df4..8da0701 100644
--- a/src/core/core.c
+++ b/src/core/core.c
@@ -27,6 +27,7 @@
 #include "core.h"
 #include "frame.h"
 #include "workspace-private.h"
+#include "input-events.h"
 #include <meta/prefs.h>
 #include <meta/errors.h>
 
@@ -840,6 +841,10 @@ meta_core_select_events (Display  *xdisplay,
     {
       XIEventMask mask;
 
+#ifdef HAVE_XTOUCH
+      evmask |= META_INPUT_TOUCH_EVENTS_MASK;
+#endif /* HAVE_XTOUCH */
+
       mask.deviceid = XIAllMasterDevices;
       mask.mask = meta_device_xi2_translate_event_mask (evmask,
                                                         &mask.mask_len);
@@ -866,7 +871,8 @@ meta_core_select_events (Display  *xdisplay,
       XISelectEvents (xdisplay, xwindow, &mask, 1);
 
       /* Unset any input event so they are only handled via XInput2 */
-      evmask &= ~(KeyPressMask | KeyReleaseMask |
+      evmask &= ~(META_INPUT_TOUCH_EVENTS_MASK |
+                  KeyPressMask | KeyReleaseMask |
                   ButtonPressMask | ButtonReleaseMask |
                   EnterWindowMask | LeaveWindowMask |
                   PointerMotionMask | PointerMotionHintMask |
diff --git a/src/core/devices-xi2.c b/src/core/devices-xi2.c
index cd6fb1b..303c2d4 100644
--- a/src/core/devices-xi2.c
+++ b/src/core/devices-xi2.c
@@ -25,6 +25,7 @@
 #include "devices-xi2.h"
 #include "display-private.h"
 #include "screen-private.h"
+#include "input-events.h"
 #include <X11/extensions/XInput2.h>
 
 /* Common functions */
@@ -97,6 +98,15 @@ meta_device_xi2_translate_event_mask (guint  evmask,
       XISetMask (mask, XI_FocusOut);
     }
 
+#ifdef HAVE_XTOUCH
+  if (evmask & META_INPUT_TOUCH_EVENTS_MASK)
+    {
+      XISetMask (mask, XI_TouchBegin);
+      XISetMask (mask, XI_TouchEnd);
+      XISetMask (mask, XI_TouchUpdate);
+    }
+#endif
+
   return mask;
 }
 
diff --git a/src/core/input-events.h b/src/core/input-events.h
index 939764d..0d99e8e 100644
--- a/src/core/input-events.h
+++ b/src/core/input-events.h
@@ -35,6 +35,11 @@
 #include "display-private.h"
 #include <meta/device-map.h>
 
+/* Add an extra flag for touch events in
+ * evmasks, an arbitrarily high bit is taken.
+ */
+#define META_INPUT_TOUCH_EVENTS_MASK (1L<<31)
+
 gboolean meta_input_event_get_type          (MetaDisplay *display,
                                              XEvent      *ev,
                                              guint       *ev_type);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]