input: use a GrabMask union in GrabDevice to allow for XI2 masks.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2009-04-12 17:38:28 +10:00
parent 6bb4b5b937
commit c94ea5bc05
5 changed files with 27 additions and 6 deletions

View File

@ -104,6 +104,7 @@ ProcXGrabDevice(ClientPtr client)
int rc; int rc;
xGrabDeviceReply rep; xGrabDeviceReply rep;
DeviceIntPtr dev; DeviceIntPtr dev;
GrabMask mask;
struct tmask tmp[EMASKSIZE]; struct tmask tmp[EMASKSIZE];
REQUEST(xGrabDeviceReq); REQUEST(xGrabDeviceReq);
@ -126,10 +127,12 @@ ProcXGrabDevice(ClientPtr client)
X_GrabDevice)) != Success) X_GrabDevice)) != Success)
return rc; return rc;
mask.xi = tmp[stuff->deviceid].mask;
rc = GrabDevice(client, dev, stuff->other_devices_mode, rc = GrabDevice(client, dev, stuff->other_devices_mode,
stuff->this_device_mode, stuff->grabWindow, stuff->this_device_mode, stuff->grabWindow,
stuff->ownerEvents, stuff->time, stuff->ownerEvents, stuff->time,
tmp[stuff->deviceid].mask, FALSE, None, None, &mask, FALSE, None, None,
&rep.status); &rep.status);
if (rc != Success) if (rc != Success)

View File

@ -4395,6 +4395,7 @@ ProcGrabPointer(ClientPtr client)
xGrabPointerReply rep; xGrabPointerReply rep;
DeviceIntPtr device = PickPointer(client); DeviceIntPtr device = PickPointer(client);
GrabPtr grab; GrabPtr grab;
GrabMask mask;
WindowPtr confineTo; WindowPtr confineTo;
CursorPtr oldCursor; CursorPtr oldCursor;
REQUEST(xGrabPointerReq); REQUEST(xGrabPointerReq);
@ -4431,9 +4432,11 @@ ProcGrabPointer(ClientPtr client)
oldCursor = grab->cursor; oldCursor = grab->cursor;
} }
mask.core = stuff->eventMask;
rc = GrabDevice(client, device, stuff->pointerMode, stuff->keyboardMode, rc = GrabDevice(client, device, stuff->pointerMode, stuff->keyboardMode,
stuff->grabWindow, stuff->ownerEvents, stuff->time, stuff->grabWindow, stuff->ownerEvents, stuff->time,
stuff->eventMask, GRABTYPE_CORE, stuff->cursor, &mask, GRABTYPE_CORE, stuff->cursor,
stuff->confineTo, &rep.status); stuff->confineTo, &rep.status);
if (rc != Success) if (rc != Success)
return rc; return rc;
@ -4551,7 +4554,7 @@ ProcUngrabPointer(ClientPtr client)
int int
GrabDevice(ClientPtr client, DeviceIntPtr dev, GrabDevice(ClientPtr client, DeviceIntPtr dev,
unsigned pointer_mode, unsigned keyboard_mode, Window grabWindow, unsigned pointer_mode, unsigned keyboard_mode, Window grabWindow,
unsigned ownerEvents, Time ctime, Mask mask, unsigned ownerEvents, Time ctime, GrabMask *mask,
int grabtype, Cursor curs, Window confineToWin, CARD8 *status) int grabtype, Cursor curs, Window confineToWin, CARD8 *status)
{ {
WindowPtr pWin, confineTo; WindowPtr pWin, confineTo;
@ -4643,7 +4646,12 @@ GrabDevice(ClientPtr client, DeviceIntPtr dev,
tempGrab.ownerEvents = ownerEvents; tempGrab.ownerEvents = ownerEvents;
tempGrab.keyboardMode = keyboard_mode; tempGrab.keyboardMode = keyboard_mode;
tempGrab.pointerMode = pointer_mode; tempGrab.pointerMode = pointer_mode;
tempGrab.eventMask = mask; if (grabtype == GRABTYPE_CORE)
tempGrab.eventMask = mask->core;
else if (grabtype == GRABTYPE_XI)
tempGrab.eventMask = mask->xi;
else
memcpy(tempGrab.xi2mask, mask->xi2mask, sizeof(tempGrab.xi2mask));
tempGrab.device = dev; tempGrab.device = dev;
tempGrab.cursor = cursor; tempGrab.cursor = cursor;
tempGrab.confineTo = confineTo; tempGrab.confineTo = confineTo;
@ -4666,13 +4674,16 @@ ProcGrabKeyboard(ClientPtr client)
REQUEST(xGrabKeyboardReq); REQUEST(xGrabKeyboardReq);
int result; int result;
DeviceIntPtr keyboard = PickKeyboard(client); DeviceIntPtr keyboard = PickKeyboard(client);
GrabMask mask;
REQUEST_SIZE_MATCH(xGrabKeyboardReq); REQUEST_SIZE_MATCH(xGrabKeyboardReq);
memset(&rep, 0, sizeof(xGrabKeyboardReply)); memset(&rep, 0, sizeof(xGrabKeyboardReply));
mask.core = KeyPressMask | KeyReleaseMask;
result = GrabDevice(client, keyboard, stuff->pointerMode, result = GrabDevice(client, keyboard, stuff->pointerMode,
stuff->keyboardMode, stuff->grabWindow, stuff->ownerEvents, stuff->keyboardMode, stuff->grabWindow, stuff->ownerEvents,
stuff->time, KeyPressMask | KeyReleaseMask, GRABTYPE_CORE, None, None, stuff->time, &mask, GRABTYPE_CORE, None, None,
&rep.status); &rep.status);
if (result != Success) if (result != Success)

View File

@ -433,7 +433,7 @@ extern int GrabDevice(
Window /* grabWindow */, Window /* grabWindow */,
unsigned /* ownerEvents */, unsigned /* ownerEvents */,
Time /* ctime */, Time /* ctime */,
Mask /* mask */, GrabMask* /* mask */,
int /* grabtype */, int /* grabtype */,
Cursor /* curs */, Cursor /* curs */,
Window /* confineToWin */, Window /* confineToWin */,

View File

@ -103,6 +103,7 @@ typedef struct _OtherClients *OtherClientsPtr;
typedef struct _InputClients *InputClientsPtr; typedef struct _InputClients *InputClientsPtr;
typedef struct _DeviceIntRec *DeviceIntPtr; typedef struct _DeviceIntRec *DeviceIntPtr;
typedef struct _ClassesRec *ClassesPtr; typedef struct _ClassesRec *ClassesPtr;
typedef union _GrabMask GrabMask;
typedef struct _EventList { typedef struct _EventList {
xEvent* event; xEvent* event;

View File

@ -156,6 +156,12 @@ typedef enum {
GRABTYPE_XI2 GRABTYPE_XI2
} GrabType; } GrabType;
union _GrabMask {
Mask core;
Mask xi;
char xi2mask[EMASKSIZE][XI2MASKSIZE];
};
/** /**
* Central struct for device grabs. * Central struct for device grabs.
* The same struct is used for both core grabs and device grabs, with * The same struct is used for both core grabs and device grabs, with