[mutter/wip/multitouch: 4/8] input-events: Add meta_input_event_ignored()



commit 75e2fefe1c403d32dd989a348dce6236bcf6b196
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Aug 2 19:19:00 2011 +0200

    input-events: Add meta_input_event_ignored()
    
    This function tells whether an input event should be ignored,
    the only current reason being the duplication of touch events
    and their emulated XI2 pointer event counterparts.

 src/core/input-events.c |   30 ++++++++++++++++++++++++++++++
 src/core/input-events.h |    3 +++
 2 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/src/core/input-events.c b/src/core/input-events.c
index b8ac5da..bebfd6f 100644
--- a/src/core/input-events.c
+++ b/src/core/input-events.c
@@ -148,6 +148,36 @@ meta_input_event_is_type (MetaDisplay *display,
   return (type == ev_type);
 }
 
+gboolean
+meta_input_event_ignore (MetaDisplay *display,
+                         XEvent      *ev)
+{
+#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_Motion:
+        case XI_ButtonPress:
+        case XI_ButtonRelease:
+          if (((XIDeviceEvent *) xev)->flags & XIPointerEmulated)
+            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 356cd16..d0e5af0 100644
--- a/src/core/input-events.h
+++ b/src/core/input-events.h
@@ -42,6 +42,9 @@ gboolean meta_input_event_is_type           (MetaDisplay *display,
                                              XEvent      *ev,
                                              guint        ev_type);
 
+gboolean meta_input_event_ignore            (MetaDisplay *display,
+                                             XEvent      *ev);
+
 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]