[mutter/wip/multitouch: 5/8] input-events: Add meta_input_event_get_touch_id()



commit 2cf5a0f01a20191eddcee9427722a5e3fd69193b
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Aug 2 19:20:43 2011 +0200

    input-events: Add meta_input_event_get_touch_id()
    
    This function returns the touch ID generating an input event,
    if any.

 src/core/input-events.c |   31 +++++++++++++++++++++++++++++++
 src/core/input-events.h |    4 ++++
 2 files changed, 35 insertions(+), 0 deletions(-)
---
diff --git a/src/core/input-events.c b/src/core/input-events.c
index bebfd6f..46e7554 100644
--- a/src/core/input-events.c
+++ b/src/core/input-events.c
@@ -178,6 +178,37 @@ meta_input_event_ignore (MetaDisplay *display,
       return FALSE;
 }
 
+gboolean
+meta_input_event_get_touch_id (MetaDisplay *display,
+                               XEvent      *ev,
+                               guint       *touch_id)
+{
+#if defined(HAVE_XINPUT2) && defined(HAVE_XTOUCH)
+  if (ev->type == GenericEvent &&
+      ev->xcookie.extension == display->xinput2_opcode)
+    {
+      XIEvent *xev;
+
+      g_assert (display->have_xinput2 == TRUE);
+      xev = (XIEvent *) ev->xcookie.data;
+
+      switch (xev->evtype)
+        {
+        case XI_TouchBegin:
+        case XI_TouchEnd:
+        case XI_TouchUpdate:
+          if (touch_id)
+            *touch_id = ((XIDeviceEvent *) xev)->detail;
+          return TRUE;
+        default:
+          return FALSE;
+        }
+    }
+#endif /* HAVE_XINPUT2 && HAVE_XTOUCH */
+
+  return FALSE;
+}
+
 Window
 meta_input_event_get_window (MetaDisplay *display,
                              XEvent      *ev)
diff --git a/src/core/input-events.h b/src/core/input-events.h
index d0e5af0..939764d 100644
--- a/src/core/input-events.h
+++ b/src/core/input-events.h
@@ -45,6 +45,10 @@ gboolean meta_input_event_is_type           (MetaDisplay *display,
 gboolean meta_input_event_ignore            (MetaDisplay *display,
                                              XEvent      *ev);
 
+gboolean meta_input_event_get_touch_id      (MetaDisplay *display,
+                                             XEvent      *ev,
+                                             guint       *touch_id);
+
 Window   meta_input_event_get_window        (MetaDisplay *display,
                                              XEvent      *ev);
 Window   meta_input_event_get_root_window   (MetaDisplay *display,



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