summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2009-05-31 21:29:47 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2009-06-02 13:25:49 +1000
commit2174d35d5cdc475699be968a0c1b1aa82566171f (patch)
tree9bce3101f63becc0255837ce1d23abbaf15d5d54
parentb1dedc1293a854360d44856cd603d339ce95c777 (diff)
Return BadRequest from XIQueryVersion if XI2 isn't supported.
XIQueryVersion (like all other calls) makes sure XGetExtensionVersion is called beforehand anyway. So if that doesn't match 2.0 or higher, return BadRquest before issuing the real request (which would trigger a BadRequest error). This way, clients can use XIQueryVersion without having to set up the error handler. XIQueryVersion is now guaranteed to return the server-supported version. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--man/XIQueryVersion.txt31
-rw-r--r--src/XExtInt.c6
-rw-r--r--src/XIQueryVersion.c20
-rw-r--r--src/XIint.h6
4 files changed, 52 insertions, 11 deletions
diff --git a/man/XIQueryVersion.txt b/man/XIQueryVersion.txt
index 422e51f..53118ed 100644
--- a/man/XIQueryVersion.txt
+++ b/man/XIQueryVersion.txt
@@ -30,13 +30,36 @@ DESCRIPTION
-----------
XIQueryVersion announces the client's supported XI2 version to
- the server and returns server's supported version. The server
- may treat a client differently depending on the version support
- announced. The major_version_inout must be 2 or greater,
- otherwise a BadValue error occurs.
+ the server and returns server's supported X Input version. Clients
+ are required to use XIQueryVersion instead of XGetExtensionVersion
+ if they use XI2 calls. The server may treat a client differently
+ depending on the supported version announced by the client.
+ The major_version_inout must be 2 or greater, otherwise a BadValue
+ error occurs.
+
+ If the server does not support XI2, XIQueryVersion returns BadRequest
+ to the client. Otherwise, XIQueryVersion returns Success. In both
+ cases major_version_inout and minor_version_inout are set to the
+ server's supported version.
XIQueryVersion can generate a BadValue error.
+
+EXAMPLES
+--------
+
+ int rc;
+ int major = 2;
+ int minor = 0;
+
+ rc = XIQueryVersion(dpy, &major, &minor);
+ if (rc == Success)
+ printf("XI2 supported. (%d.%d)\n", major, minor);
+ else if (rc == BadRequest)
+ printf("No XI2 support. (%d.%d only)\n", major, minor);
+ else
+ printf("Internal error\n");
+
DIAGNOSTICS
-----------
diff --git a/src/XExtInt.c b/src/XExtInt.c
index a0cc3b0..b2890f9 100644
--- a/src/XExtInt.c
+++ b/src/XExtInt.c
@@ -140,12 +140,6 @@ wireToPropertyEvent(xXIPropertyEvent *in, XIPropertyEvent *out);
static /* const */ XEvent emptyevent;
-typedef struct _XInputData
-{
- XEvent data;
- XExtensionVersion *vers;
-} XInputData;
-
static /* const */ XExtensionHooks xinput_extension_hooks = {
NULL, /* create_gc */
NULL, /* copy_gc */
diff --git a/src/XIQueryVersion.c b/src/XIQueryVersion.c
index 851d0d4..a14e9c9 100644
--- a/src/XIQueryVersion.c
+++ b/src/XIQueryVersion.c
@@ -50,8 +50,26 @@ _xiQueryVersion(Display * dpy, int *major, int *minor, XExtDisplayInfo *info)
xXIQueryVersionReq *req;
xXIQueryVersionReply rep;
- if (_XiCheckExtInit(dpy, Dont_Check, info) == -1)
+ /* This could mean either a malloc problem, or supported
+ version < XInput_2_0 */
+ if (_XiCheckExtInit(dpy, XInput_2_0, info) == -1)
+ {
+ XExtensionVersion *ext;
+ XExtDisplayInfo *info = XInput_find_display(dpy);
+
+ if (!info || !info->data) {
+ *major = 0;
+ *minor = 0;
+ UnlockDisplay(dpy);
+ return BadRequest;
+ }
+
+ ext = ((XInputData*)info->data)->vers;
+
+ *major = ext->major_version;
+ *minor = ext->minor_version;
return BadRequest;
+ }
GetReq(XIQueryVersion, req);
req->reqType = info->codes->major_opcode;
diff --git a/src/XIint.h b/src/XIint.h
index 9cf6bc4..63e33f1 100644
--- a/src/XIint.h
+++ b/src/XIint.h
@@ -23,4 +23,10 @@ extern Status _XiEventToWire(
register int * /* count */
);
+typedef struct _XInputData
+{
+ XEvent data;
+ XExtensionVersion *vers;
+} XInputData;
+
#endif