Xi: fix swapped grab mode args for keyboard devices in XIGrabDevice

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.

Signed-off-by: Rui Matos <tiagomatos@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Rui Matos 2013-04-13 04:22:54 +02:00 committed by Peter Hutterer
parent d16284687d
commit 9003399708

View File

@ -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,