[PATCH v3 libXi] Handle new XIAllowEvent request size

Peter Hutterer peter.hutterer at who-t.net
Wed Feb 8 01:18:17 PST 2012


inputproto 2.1.99.6 restored the previous request for ABI compatibility
reasons, and it introduced a new XI 2.2 specific define.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 configure.ac        |    2 +-
 src/XIAllowEvents.c |   23 ++++++++++++++---------
 2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/configure.ac b/configure.ac
index 481cf44..46f2fb8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,7 +28,7 @@ XORG_WITH_ASCIIDOC(8.4.5)
 XORG_CHECK_MALLOC_ZERO
 
 # Obtain compiler/linker options for dependencies
-PKG_CHECK_MODULES(XI, [xproto >= 7.0.13] [x11 >= 1.4.99.1] [xextproto >= 7.0.3] [xext >= 1.0.99.1] [inputproto >= 2.1.99.3])
+PKG_CHECK_MODULES(XI, [xproto >= 7.0.13] [x11 >= 1.4.99.1] [xextproto >= 7.0.3] [xext >= 1.0.99.1] [inputproto >= 2.1.99.6])
 
 # Check for xmlto and asciidoc for man page conversion
 # (only needed by people building tarballs)
diff --git a/src/XIAllowEvents.c b/src/XIAllowEvents.c
index d987549..c8d997a 100644
--- a/src/XIAllowEvents.c
+++ b/src/XIAllowEvents.c
@@ -33,13 +33,16 @@
 #include <X11/extensions/extutil.h>
 #include "XIint.h"
 
+/* for GetRequest() to work */
+#define X_XI2_2AllowEvents X_XIAllowEvents
+
 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;
+    xXI2_2AllowEventsReq *req_XI22;
 
     XExtDisplayInfo *extinfo = XInput_find_display(dpy);
 
@@ -47,13 +50,15 @@ _XIAllowEvents(Display *dpy, int deviceid, int event_mode, Time time,
     if (_XiCheckExtInit(dpy, XInput_2_0, extinfo) == -1)
 	return (NoSuchExtension);
 
-    /* 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;
-    }
+    if (_XiCheckExtInit(dpy, XInput_2_2, extinfo) == 0)
+        have_XI22 = True;
 
-    GetReqSized(XIAllowEvents, req_len, req);
+    if (have_XI22)
+    {
+        GetReq(XI2_2AllowEvents, req_XI22);
+        req = (xXIAllowEventsReq*)req_XI22;
+    } else
+        GetReq(XIAllowEvents, req);
 
     req->reqType = extinfo->codes->major_opcode;
     req->ReqType = X_XIAllowEvents;
@@ -62,8 +67,8 @@ _XIAllowEvents(Display *dpy, int deviceid, int event_mode, Time time,
     req->time = time;
 
     if (have_XI22) {
-        req->touchid = touchid;
-        req->grab_window = grab_window;
+        req_XI22->touchid = touchid;
+        req_XI22->grab_window = grab_window;
     }
 
     UnlockDisplay(dpy);
-- 
1.7.7.5



More information about the xorg-devel mailing list