[PATCH 2/2] Xi: fix swapped grab mode args for keyboard devices in XIGrabDevice

Rui Matos tiagomatos at gmail.com
Fri Apr 12 19:22:54 PDT 2013


The protocol says that the grab_mode argument applies to the device
being grabbed and paired_device_mode to the paired master
device. GrabDevice() however takes in a pointer mode and a keyboard
mode and so we have to swap the values according the type of device
being grabbed.
---
 Xi/xigrabdev.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/Xi/xigrabdev.c b/Xi/xigrabdev.c
index 09186e8..63d95bc 100644
--- a/Xi/xigrabdev.c
+++ b/Xi/xigrabdev.c
@@ -67,6 +67,8 @@ ProcXIGrabDevice(ClientPtr client)
     uint8_t status;
     GrabMask mask = { 0 };
     int mask_len;
+    unsigned int keyboard_mode;
+    unsigned int pointer_mode;
 
     REQUEST(xXIGrabDeviceReq);
     REQUEST_AT_LEAST_SIZE(xXIGrabDeviceReq);
@@ -78,6 +80,15 @@ ProcXIGrabDevice(ClientPtr client)
     if (!IsMaster(dev))
         stuff->paired_device_mode = GrabModeAsync;
 
+    if (IsKeyboardDevice(dev)) {
+        keyboard_mode = stuff->grab_mode;
+        pointer_mode = stuff->paired_device_mode;
+    }
+    else {
+        keyboard_mode = stuff->paired_device_mode;
+        pointer_mode = stuff->grab_mode;
+    }
+
     if (XICheckInvalidMaskBits(client, (unsigned char *) &stuff[1],
                                stuff->mask_len * 4) != Success)
         return BadValue;
@@ -91,8 +102,8 @@ ProcXIGrabDevice(ClientPtr client)
     xi2mask_set_one_mask(mask.xi2mask, dev->id, (unsigned char *) &stuff[1],
                          mask_len);
 
-    ret = GrabDevice(client, dev, stuff->grab_mode,
-                     stuff->paired_device_mode,
+    ret = GrabDevice(client, dev, pointer_mode,
+                     keyboard_mode,
                      stuff->grab_window,
                      stuff->owner_events,
                      stuff->time,
-- 
1.8.1.4



More information about the xorg-devel mailing list