[PATCH 03/11] dix: simplify button press check for passive grabs

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


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

diff --git a/dix/events.c b/dix/events.c
index efe596b..bc981a2 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -2046,6 +2046,21 @@ out:
 }
 
 
+/**
+ * @return TRUE if the event provided is any of core, XI or XI2 button
+ * press.
+ */
+static BOOL
+IsButtonPressEvent(xEvent *pEvents)
+{
+    int type = pEvents->u.u.type;
+
+    if (((XI2_EVENT(pEvents) && ((xGenericEvent*)pEvents)->evtype == XI_ButtonPress)) ||
+            type == DeviceButtonPress || type == ButtonPress)
+        return TRUE;
+    else
+        return FALSE;
+}
 
 /**
  * Deliver events to a window. At this point, we do not yet know if the event
@@ -2129,10 +2144,7 @@ DeliverEventsToWindow(DeviceIntPtr pDev, WindowPtr pWin, xEvent
      * Note that since core events are delivered first, an implicit grab may
      * be activated on a core grab, stopping the XI events.
      */
-    if ((type == DeviceButtonPress || type == ButtonPress ||
-        ((XI2_EVENT(pEvents) && ((xGenericEvent*)pEvents)->evtype == XI_ButtonPress)))
-            && deliveries
-            && (!grab))
+    if (IsButtonPressEvent(pEvents) && deliveries && (!grab))
     {
 	GrabRec tempGrab;
         OtherInputMasks *inputMasks;
-- 
1.7.4.4



More information about the xorg-devel mailing list