[PATCH 19/21] Add GrabIsPointerGrab and GrabIsKeyboardGrab helpers

Peter Hutterer peter.hutterer at who-t.net
Thu Dec 8 19:36:20 PST 2011


No functional changes

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 Xi/exevents.c      |    8 ++------
 dix/grabs.c        |   17 +++++++++++++++++
 include/dixgrabs.h |    2 ++
 3 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/Xi/exevents.c b/Xi/exevents.c
index d4ee185..3e19029 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -1001,9 +1001,7 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device)
         case ET_KeyRelease:
             if (grab && device->deviceGrab.fromPassiveGrab &&
                 (key == device->deviceGrab.activatingKey) &&
-                (device->deviceGrab.grab->type == KeyPress ||
-                 device->deviceGrab.grab->type == DeviceKeyPress ||
-                 device->deviceGrab.grab->type == XI_KeyPress))
+                GrabIsKeyboardGrab(device->deviceGrab.grab))
                 deactivateDeviceGrab = TRUE;
             break;
         case ET_ButtonPress:
@@ -1023,9 +1021,7 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device)
             event->detail.button = b->map[key];
             if (grab && !b->buttonsDown &&
                 device->deviceGrab.fromPassiveGrab &&
-                (device->deviceGrab.grab->type == ButtonPress ||
-                 device->deviceGrab.grab->type == DeviceButtonPress ||
-                 device->deviceGrab.grab->type == XI_ButtonPress))
+                GrabIsPointerGrab(device->deviceGrab.grab))
                 deactivateDeviceGrab = TRUE;
         default:
             break;
diff --git a/dix/grabs.c b/dix/grabs.c
index aced130..0157b78 100644
--- a/dix/grabs.c
+++ b/dix/grabs.c
@@ -60,6 +60,7 @@ SOFTWARE.
 #include "dixgrabs.h"
 #include "xace.h"
 #include "exevents.h"
+#include "exglobals.h"
 #include "inpututils.h"
 
 #define BITMASK(i) (((Mask)1) << ((i) & 31))
@@ -737,3 +738,19 @@ DeletePassiveGrabFromList(GrabPtr pMinuendGrab)
 
 #undef UPDATE
 }
+
+Bool
+GrabIsPointerGrab(GrabPtr grab)
+{
+    return (grab->type == ButtonPress ||
+            grab->type == DeviceButtonPress ||
+            grab->type == XI_ButtonPress);
+}
+
+Bool
+GrabIsKeyboardGrab(GrabPtr grab)
+{
+   return (grab->type == KeyPress ||
+           grab->type == DeviceKeyPress ||
+           grab->type == XI_KeyPress);
+}
diff --git a/include/dixgrabs.h b/include/dixgrabs.h
index 65ff45d..ea88770 100644
--- a/include/dixgrabs.h
+++ b/include/dixgrabs.h
@@ -64,4 +64,6 @@ extern _X_EXPORT int AddPassiveGrabToList(
 extern _X_EXPORT Bool DeletePassiveGrabFromList(
 	GrabPtr /* pMinuendGrab */);
 
+extern Bool GrabIsPointerGrab(GrabPtr grab);
+extern Bool GrabIsKeyboardGrab(GrabPtr grab);
 #endif /* DIXGRABS_H */
-- 
1.7.7.1



More information about the xorg-devel mailing list