diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2009-12-09 13:59:57 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2010-02-22 13:19:13 +1000 |
commit | 299de21b2ab3cfa2078823215f84da67e7b3d1a3 (patch) | |
tree | 03b47b6d386c1a7baa56654e6dd658da26eb871b /src/XGetVers.c | |
parent | 4debc545611edd35f8fd35a52f4adf4263e49200 (diff) |
Initialize extension with the right number of events.
If the server supports a lower XI version than the client, the Xlib-internal
event vector may be smashed. See libXext for more details.
http://cgit.freedesktop.org/xorg/lib/libXext/commit/?id=83fdb27df4ddc2fb088ddf2ec65f0db6b7c57287
This patch queries the server for the supported XI extension before
registering the extension with Xlib. The number of events registered depends
on the server version.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Julien Cristau <jcristau@debian.org>
Diffstat (limited to 'src/XGetVers.c')
-rw-r--r-- | src/XGetVers.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/XGetVers.c b/src/XGetVers.c index 3b500ae..4718617 100644 --- a/src/XGetVers.c +++ b/src/XGetVers.c @@ -72,19 +72,15 @@ XGetExtensionVersion(register Display * dpy, _Xconst char *name) return (ext); } -_X_HIDDEN XExtensionVersion * -_XiGetExtensionVersion(register Display * dpy, _Xconst char *name, - XExtDisplayInfo *info) +_X_HIDDEN XExtensionVersion* +_XiGetExtensionVersionRequest(Display *dpy, _Xconst char *name, int xi_opcode) { xGetExtensionVersionReq *req; xGetExtensionVersionReply rep; XExtensionVersion *ext; - if (_XiCheckExtInit(dpy, Dont_Check, info) == -1) - return ((XExtensionVersion *) NoSuchExtension); - GetReq(GetExtensionVersion, req); - req->reqType = info->codes->major_opcode; + req->reqType = xi_opcode; req->ReqType = X_GetExtensionVersion; req->nbytes = strlen(name); req->length += (unsigned)(req->nbytes + 3) >> 2; @@ -93,6 +89,7 @@ _XiGetExtensionVersion(register Display * dpy, _Xconst char *name, if (!_XReply(dpy, (xReply *) & rep, 0, xTrue)) { return (XExtensionVersion *) NULL; } + ext = (XExtensionVersion *) Xmalloc(sizeof(XExtensionVersion)); if (ext) { ext->present = rep.present; @@ -101,5 +98,16 @@ _XiGetExtensionVersion(register Display * dpy, _Xconst char *name, ext->minor_version = rep.minor_version; } } - return (ext); + + return ext; +} + +_X_HIDDEN XExtensionVersion * +_XiGetExtensionVersion(register Display * dpy, _Xconst char *name, + XExtDisplayInfo *info) +{ + if (_XiCheckExtInit(dpy, Dont_Check, info) == -1) + return ((XExtensionVersion *) NoSuchExtension); + + return _XiGetExtensionVersionRequest(dpy, name, info->codes->major_opcode); } |