diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2009-05-31 21:29:47 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2009-06-02 13:25:49 +1000 |
commit | 2174d35d5cdc475699be968a0c1b1aa82566171f (patch) | |
tree | 9bce3101f63becc0255837ce1d23abbaf15d5d54 /src | |
parent | b1dedc1293a854360d44856cd603d339ce95c777 (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>
Diffstat (limited to 'src')
-rw-r--r-- | src/XExtInt.c | 6 | ||||
-rw-r--r-- | src/XIQueryVersion.c | 20 | ||||
-rw-r--r-- | src/XIint.h | 6 |
3 files changed, 25 insertions, 7 deletions
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 |