Xi: Add support for XI2 active grabs and ungrabs.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2009-04-12 22:22:21 +10:00
parent c11ef87931
commit bb5418d490
3 changed files with 68 additions and 5 deletions

View File

@ -120,6 +120,7 @@ SOFTWARE.
#include "ungrdevk.h"
#include "warpdevp.h"
#include "xiselectev.h"
#include "xigrabdev.h"
#include "xisetdevfocus.h"
#include "xiproperty.h"
@ -242,7 +243,9 @@ static int (*ProcIVector[])(ClientPtr) = {
ProcXIQueryVersion, /* 47 */
ProcXIQueryDevice, /* 48 */
ProcXISetDeviceFocus, /* 49 */
ProcXIGetDeviceFocus /* 50 */
ProcXIGetDeviceFocus, /* 50 */
ProcXIGrabDevice, /* 51 */
ProcXIUngrabDevice /* 52 */
};
/* For swapped clients */
@ -297,7 +300,9 @@ static int (*SProcIVector[])(ClientPtr) = {
SProcXIQueryVersion, /* 47 */
SProcXIQueryDevice, /* 48 */
SProcXISetDeviceFocus, /* 49 */
SProcXIGetDeviceFocus /* 50 */
SProcXIGetDeviceFocus, /* 50 */
SProcXIGrabDevice, /* 51 */
SProcXIUngrabDevice /* 52 */
};
/*****************************************************************
@ -488,6 +493,8 @@ SReplyIDispatch(ClientPtr client, int len, xGrabDeviceReply * rep)
SRepXIGetClientPointer(client, len, (xXIGetClientPointerReply*) rep);
else if (rep->RepType == X_XIQueryDevice)
SRepXIQueryDevice(client, len, (xXIQueryDeviceReply*)rep);
else if (rep->RepType == X_XIGrabDevice)
SRepXIGrabDevice(client, len, (xXIGrabDeviceReply *) rep);
else {
FatalError("XINPUT confused sending swapped reply");
}

View File

@ -63,7 +63,8 @@ ProcXIGrabDevice(ClientPtr client)
DeviceIntPtr dev;
xXIGrabDeviceReply rep;
int ret = Success;
int status;
uint8_t status;
GrabMask mask;
REQUEST(xXIGrabDeviceReq);
REQUEST_AT_LEAST_SIZE(xXIGetDeviceFocusReq);
@ -75,14 +76,17 @@ ProcXIGrabDevice(ClientPtr client)
if (!dev->isMaster)
stuff->paired_device_mode = GrabModeAsync;
memset(mask.xi2mask, 0, sizeof(mask.xi2mask));
memcpy(mask.xi2mask, (char*)&stuff[1], stuff->mask_len * 4);
ret = GrabDevice(client, dev, stuff->grab_mode,
stuff->paired_device_mode,
stuff->grab_window,
stuff->owner_events,
stuff->time,
0 /* mask */,
&mask,
GRABTYPE_XI2,
None /* cursor */,
stuff->cursor,
None /* confineTo */,
&status);
@ -100,3 +104,50 @@ ProcXIGrabDevice(ClientPtr client)
return ret;
}
int
SProcXIUngrabDevice(ClientPtr client)
{
char n;
REQUEST(xXIUngrabDeviceReq);
swaps(&stuff->length, n);
swaps(&stuff->deviceid, n);
swapl(&stuff->time, n);
return ProcXIUngrabDevice(client);
}
int
ProcXIUngrabDevice(ClientPtr client)
{
DeviceIntPtr dev;
GrabPtr grab;
int ret = Success;
TimeStamp time;
REQUEST(xXIUngrabDeviceReq);
ret = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess);
if (ret != Success)
return ret;
grab = dev->deviceGrab.grab;
time = ClientTimeToServerTime(stuff->time);
if ((CompareTimeStamps(time, currentTime) != LATER) &&
(CompareTimeStamps(time, dev->deviceGrab.grabTime) != EARLIER) &&
(grab) && SameClient(grab, client) && grab->grabtype == GRABTYPE_XI2)
(*dev->deviceGrab.DeactivateGrab) (dev);
return Success;
}
void SRepXIGrabDevice(ClientPtr client, int size, xXIGrabDeviceReply * rep)
{
char n;
swaps(&rep->sequenceNumber, n);
swapl(&rep->length, n);
WriteToClient(client, size, (char *)rep);
}

View File

@ -29,4 +29,9 @@
int ProcXIGrabDevice(ClientPtr client);
int SProcXIGrabDevice(ClientPtr client);
int ProcXIUngrabDevice(ClientPtr client);
int SProcXIUngrabDevice(ClientPtr client);
void SRepXIGrabDevice(ClientPtr client, int size, xXIGrabDeviceReply * rep);
#endif