[PATCH 11/11] dix: add is_xi2_event_of_type helper function.

Peter Hutterer peter.hutterer at who-t.net
Tue May 10 21:49:50 PDT 2011


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 dix/events.c |   23 ++++++++++++++---------
 1 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/dix/events.c b/dix/events.c
index 7885e86..f3af5ee 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -190,6 +190,11 @@ is_xi2_event(const xEvent *event)
            ((xGenericEvent*)event)->extension == IReqCode;
 }
 
+static inline BOOL
+is_xi2_event_of_type(const xEvent *event, int type)
+{
+    return is_xi2_event(event) && ((xGenericEvent*)event)->evtype == type;
+}
 
 /**
  * Used to indicate a implicit passive grab created by a ButtonPress event.
@@ -2105,7 +2110,7 @@ IsButtonPressEvent(xEvent *pEvents)
 {
     int type = pEvents->u.u.type;
 
-    if (((is_xi2_event(pEvents) && ((xGenericEvent*)pEvents)->evtype == XI_ButtonPress)) ||
+    if (is_xi2_event_of_type(pEvents, XI_ButtonPress) ||
             type == DeviceButtonPress || type == ButtonPress)
         return TRUE;
     else
@@ -2340,14 +2345,14 @@ FixUpEventFromWindow(
     {
         xXIDeviceEvent* event = (xXIDeviceEvent*)xE;
 
-        if (event->evtype == XI_RawKeyPress ||
-            event->evtype == XI_RawKeyRelease ||
-            event->evtype == XI_RawButtonPress ||
-            event->evtype == XI_RawButtonRelease ||
-            event->evtype == XI_RawMotion ||
-            event->evtype == XI_DeviceChanged ||
-            event->evtype == XI_HierarchyChanged ||
-            event->evtype == XI_PropertyEvent)
+        if (is_xi2_event_of_type(xE, XI_RawKeyRelease)    ||
+            is_xi2_event_of_type(xE, XI_RawKeyRelease)    ||
+            is_xi2_event_of_type(xE, XI_RawButtonPress)   ||
+            is_xi2_event_of_type(xE, XI_RawButtonRelease) ||
+            is_xi2_event_of_type(xE, XI_RawMotion)        ||
+            is_xi2_event_of_type(xE, XI_DeviceChanged)    ||
+            is_xi2_event_of_type(xE, XI_HierarchyChanged) ||
+            is_xi2_event_of_type(xE, XI_PropertyEvent))
             return;
 
         event->root = RootWindow(pSprite)->drawable.id;
-- 
1.7.4.4



More information about the xorg-devel mailing list