Xi: Add support for XI2 active grabs and ungrabs.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
c11ef87931
commit
bb5418d490
11
Xi/extinit.c
11
Xi/extinit.c
|
@ -120,6 +120,7 @@ SOFTWARE.
|
||||||
#include "ungrdevk.h"
|
#include "ungrdevk.h"
|
||||||
#include "warpdevp.h"
|
#include "warpdevp.h"
|
||||||
#include "xiselectev.h"
|
#include "xiselectev.h"
|
||||||
|
#include "xigrabdev.h"
|
||||||
#include "xisetdevfocus.h"
|
#include "xisetdevfocus.h"
|
||||||
#include "xiproperty.h"
|
#include "xiproperty.h"
|
||||||
|
|
||||||
|
@ -242,7 +243,9 @@ static int (*ProcIVector[])(ClientPtr) = {
|
||||||
ProcXIQueryVersion, /* 47 */
|
ProcXIQueryVersion, /* 47 */
|
||||||
ProcXIQueryDevice, /* 48 */
|
ProcXIQueryDevice, /* 48 */
|
||||||
ProcXISetDeviceFocus, /* 49 */
|
ProcXISetDeviceFocus, /* 49 */
|
||||||
ProcXIGetDeviceFocus /* 50 */
|
ProcXIGetDeviceFocus, /* 50 */
|
||||||
|
ProcXIGrabDevice, /* 51 */
|
||||||
|
ProcXIUngrabDevice /* 52 */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* For swapped clients */
|
/* For swapped clients */
|
||||||
|
@ -297,7 +300,9 @@ static int (*SProcIVector[])(ClientPtr) = {
|
||||||
SProcXIQueryVersion, /* 47 */
|
SProcXIQueryVersion, /* 47 */
|
||||||
SProcXIQueryDevice, /* 48 */
|
SProcXIQueryDevice, /* 48 */
|
||||||
SProcXISetDeviceFocus, /* 49 */
|
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);
|
SRepXIGetClientPointer(client, len, (xXIGetClientPointerReply*) rep);
|
||||||
else if (rep->RepType == X_XIQueryDevice)
|
else if (rep->RepType == X_XIQueryDevice)
|
||||||
SRepXIQueryDevice(client, len, (xXIQueryDeviceReply*)rep);
|
SRepXIQueryDevice(client, len, (xXIQueryDeviceReply*)rep);
|
||||||
|
else if (rep->RepType == X_XIGrabDevice)
|
||||||
|
SRepXIGrabDevice(client, len, (xXIGrabDeviceReply *) rep);
|
||||||
else {
|
else {
|
||||||
FatalError("XINPUT confused sending swapped reply");
|
FatalError("XINPUT confused sending swapped reply");
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,8 @@ ProcXIGrabDevice(ClientPtr client)
|
||||||
DeviceIntPtr dev;
|
DeviceIntPtr dev;
|
||||||
xXIGrabDeviceReply rep;
|
xXIGrabDeviceReply rep;
|
||||||
int ret = Success;
|
int ret = Success;
|
||||||
int status;
|
uint8_t status;
|
||||||
|
GrabMask mask;
|
||||||
|
|
||||||
REQUEST(xXIGrabDeviceReq);
|
REQUEST(xXIGrabDeviceReq);
|
||||||
REQUEST_AT_LEAST_SIZE(xXIGetDeviceFocusReq);
|
REQUEST_AT_LEAST_SIZE(xXIGetDeviceFocusReq);
|
||||||
|
@ -75,14 +76,17 @@ ProcXIGrabDevice(ClientPtr client)
|
||||||
if (!dev->isMaster)
|
if (!dev->isMaster)
|
||||||
stuff->paired_device_mode = GrabModeAsync;
|
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,
|
ret = GrabDevice(client, dev, stuff->grab_mode,
|
||||||
stuff->paired_device_mode,
|
stuff->paired_device_mode,
|
||||||
stuff->grab_window,
|
stuff->grab_window,
|
||||||
stuff->owner_events,
|
stuff->owner_events,
|
||||||
stuff->time,
|
stuff->time,
|
||||||
0 /* mask */,
|
&mask,
|
||||||
GRABTYPE_XI2,
|
GRABTYPE_XI2,
|
||||||
None /* cursor */,
|
stuff->cursor,
|
||||||
None /* confineTo */,
|
None /* confineTo */,
|
||||||
&status);
|
&status);
|
||||||
|
|
||||||
|
@ -100,3 +104,50 @@ ProcXIGrabDevice(ClientPtr client)
|
||||||
return ret;
|
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);
|
||||||
|
}
|
||||||
|
|
|
@ -29,4 +29,9 @@
|
||||||
int ProcXIGrabDevice(ClientPtr client);
|
int ProcXIGrabDevice(ClientPtr client);
|
||||||
int SProcXIGrabDevice(ClientPtr client);
|
int SProcXIGrabDevice(ClientPtr client);
|
||||||
|
|
||||||
|
int ProcXIUngrabDevice(ClientPtr client);
|
||||||
|
int SProcXIUngrabDevice(ClientPtr client);
|
||||||
|
|
||||||
|
void SRepXIGrabDevice(ClientPtr client, int size, xXIGrabDeviceReply * rep);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue