summaryrefslogtreecommitdiff
path: root/lib/libXi/src/XIPassiveGrab.c
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@cvs.openbsd.org>2014-09-28 17:22:59 +0000
committerMatthieu Herrb <matthieu@cvs.openbsd.org>2014-09-28 17:22:59 +0000
commitf7835ef9564bbf56eb86adc2c23d02fd12ebe606 (patch)
tree1a22a8268cf1df1ad8c19b63dfcb2267c0b47cd0 /lib/libXi/src/XIPassiveGrab.c
parent36d4dfbef442fbc555a47044ae213bb52fe51ba6 (diff)
Update to libXi 1.7.4
Diffstat (limited to 'lib/libXi/src/XIPassiveGrab.c')
-rw-r--r--lib/libXi/src/XIPassiveGrab.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/libXi/src/XIPassiveGrab.c b/lib/libXi/src/XIPassiveGrab.c
index baadccb1f..c74351685 100644
--- a/lib/libXi/src/XIPassiveGrab.c
+++ b/lib/libXi/src/XIPassiveGrab.c
@@ -44,6 +44,7 @@ _XIPassiveGrabDevice(Display* dpy, int deviceid, int grabtype, int detail,
xXIPassiveGrabDeviceReply reply;
xXIGrabModifierInfo *failed_mods;
int len = 0, i;
+ int ret = -1;
char *buff;
XExtDisplayInfo *extinfo = XInput_find_display(dpy);
@@ -54,11 +55,11 @@ _XIPassiveGrabDevice(Display* dpy, int deviceid, int grabtype, int detail,
if (mask->mask_len > INT_MAX - 3 ||
(mask->mask_len + 3)/4 >= 0xffff)
- return -1;
+ goto out;
buff = calloc(4, (mask->mask_len + 3)/4);
if (!buff)
- return -1;
+ goto out;
GetReq(XIPassiveGrabDevice, req);
req->reqType = extinfo->codes->major_opcode;
@@ -85,15 +86,11 @@ _XIPassiveGrabDevice(Display* dpy, int deviceid, int grabtype, int detail,
free(buff);
if (!_XReply(dpy, (xReply *)&reply, 0, xFalse))
- {
- UnlockDisplay(dpy);
- SyncHandle();
- return -1;
- }
+ goto out;
failed_mods = calloc(reply.num_modifiers, sizeof(xXIGrabModifierInfo));
if (!failed_mods)
- return -1;
+ goto out;
_XRead(dpy, (char*)failed_mods, reply.num_modifiers * sizeof(xXIGrabModifierInfo));
for (i = 0; i < reply.num_modifiers && i < num_modifiers; i++)
@@ -103,9 +100,12 @@ _XIPassiveGrabDevice(Display* dpy, int deviceid, int grabtype, int detail,
}
free(failed_mods);
+ ret = reply.num_modifiers;
+
+ out:
UnlockDisplay(dpy);
SyncHandle();
- return reply.num_modifiers;
+ return ret;
}
int
@@ -166,6 +166,7 @@ XIGrabTouchBegin(Display *dpy, int deviceid, Window grab_window,
LockDisplay(dpy);
if (_XiCheckExtInit(dpy, XInput_2_2, extinfo) == -1)
return -1;
+ UnlockDisplay(dpy);
/* FIXME: allow selection of GrabMode for paired devices? */
return _XIPassiveGrabDevice(dpy, deviceid, XIGrabtypeTouchBegin, 0,
@@ -248,6 +249,7 @@ XIUngrabTouchBegin(Display* display, int deviceid, Window grab_window,
LockDisplay(display);
if (_XiCheckExtInit(display, XInput_2_2, extinfo) == -1)
return -1;
+ UnlockDisplay(display);
return _XIPassiveUngrabDevice(display, deviceid, XIGrabtypeTouchBegin, 0,
grab_window, num_modifiers, modifiers);