summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Xi/extinit.c11
-rw-r--r--Xi/xigrabdev.c57
-rw-r--r--Xi/xigrabdev.h5
3 files changed, 68 insertions, 5 deletions
diff --git a/Xi/extinit.c b/Xi/extinit.c
index 9b1310bb7..9d3b5e613 100644
--- a/Xi/extinit.c
+++ b/Xi/extinit.c
@@ -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");
}
diff --git a/Xi/xigrabdev.c b/Xi/xigrabdev.c
index ef055f5d7..0e86aa374 100644
--- a/Xi/xigrabdev.c
+++ b/Xi/xigrabdev.c
@@ -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);
+}
diff --git a/Xi/xigrabdev.h b/Xi/xigrabdev.h
index 327d4d562..61369978e 100644
--- a/Xi/xigrabdev.h
+++ b/Xi/xigrabdev.h
@@ -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