summaryrefslogtreecommitdiff
path: root/src/XIAllowEvents.c
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2011-09-14 22:33:57 -0700
committerPeter Hutterer <peter.hutterer@who-t.net>2011-12-21 15:32:05 +1000
commite73e2fe95dab3e0048b24d16327adbe54326ff3f (patch)
tree8189d07cfc14fd6eabbfc343faa1157a665e9bad /src/XIAllowEvents.c
parent7888d14a499062a1c3b333f31f1330cecf1e97c1 (diff)
downloadxorg-lib-libXi-e73e2fe95dab3e0048b24d16327adbe54326ff3f.tar.gz
Implement support for XI 2.2
Adds support for the new TouchClass for multitouch-capable servers/devices. New events: XITouchOwnershipEvent New event types handled: XITouchBegin, XITouchUpdate, XITouchEnd XIRawTouchBegin, XIRawTouchUpdate, XIRawTouchEnd New functions: XIGrabTouchBegin ... passive grabs on touches XIUngrabTouchBegin XIAllowTouchEvents ... Allow/reject touch event sequences New XIQueryDevice classes: XITouchClassInfo Requires libX11 1.5 for GetReqSized Co-authored by: Chase Douglas <chase.douglas@canonical.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'src/XIAllowEvents.c')
-rw-r--r--src/XIAllowEvents.c46
1 files changed, 43 insertions, 3 deletions
diff --git a/src/XIAllowEvents.c b/src/XIAllowEvents.c
index d4da6d0..d987549 100644
--- a/src/XIAllowEvents.c
+++ b/src/XIAllowEvents.c
@@ -33,9 +33,12 @@
#include <X11/extensions/extutil.h>
#include "XIint.h"
-Status
-XIAllowEvents(Display *dpy, int deviceid, int event_mode, Time time)
+static Status
+_XIAllowEvents(Display *dpy, int deviceid, int event_mode, Time time,
+ unsigned int touchid, Window grab_window)
{
+ Bool have_XI22 = True;
+ int req_len = sz_xXIAllowEventsReq; /* in bytes */
xXIAllowEventsReq *req;
XExtDisplayInfo *extinfo = XInput_find_display(dpy);
@@ -44,14 +47,51 @@ XIAllowEvents(Display *dpy, int deviceid, int event_mode, Time time)
if (_XiCheckExtInit(dpy, XInput_2_0, extinfo) == -1)
return (NoSuchExtension);
- GetReq(XIAllowEvents, req);
+ /* 2.2's XIAllowEvents is 8 bytes longer than 2.0 */
+ if (_XiCheckExtInit(dpy, XInput_2_2, extinfo) == -1) {
+ req_len -= 8;
+ have_XI22 = False;
+ }
+
+ GetReqSized(XIAllowEvents, req_len, req);
+
req->reqType = extinfo->codes->major_opcode;
req->ReqType = X_XIAllowEvents;
req->deviceid = deviceid;
req->mode = event_mode;
req->time = time;
+ if (have_XI22) {
+ req->touchid = touchid;
+ req->grab_window = grab_window;
+ }
+
UnlockDisplay(dpy);
SyncHandle();
return Success;
}
+
+Status
+XIAllowEvents(Display *dpy, int deviceid, int event_mode, Time time)
+{
+ return _XIAllowEvents(dpy, deviceid, event_mode, time, 0, None);
+}
+
+Status
+XIAllowTouchEvents(Display *dpy, int deviceid, unsigned int touchid,
+ Window grab_window, int event_mode)
+{
+ int status;
+ XExtDisplayInfo *extinfo = XInput_find_display(dpy);
+
+ LockDisplay(dpy);
+ if (_XiCheckExtInit(dpy, XInput_2_2, extinfo) == -1)
+ return (NoSuchExtension);
+
+ status = _XIAllowEvents(dpy, deviceid, event_mode, CurrentTime, touchid, grab_window);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return status;
+}