diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2010-09-04 10:17:04 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2010-09-04 10:17:04 +0000 |
commit | cbc030cdfc49edabfbb826732f14257cd2d9d1b7 (patch) | |
tree | 3de5fd42e682be4d9c96c3a15180daa6e76c0176 /lib/libXi/src | |
parent | f75d648ac6d0910af211181f10653288f4e6f7e7 (diff) |
Update to libXi 1.3.2
Diffstat (limited to 'lib/libXi/src')
-rw-r--r-- | lib/libXi/src/Makefile.in | 8 | ||||
-rw-r--r-- | lib/libXi/src/XExtInt.c | 68 | ||||
-rw-r--r-- | lib/libXi/src/XGetVers.c | 24 | ||||
-rw-r--r-- | lib/libXi/src/XIProperties.c | 1 | ||||
-rw-r--r-- | lib/libXi/src/XIQueryVersion.c | 1 | ||||
-rw-r--r-- | lib/libXi/src/XISelEv.c | 35 | ||||
-rw-r--r-- | lib/libXi/src/XIint.h | 1 |
7 files changed, 104 insertions, 34 deletions
diff --git a/lib/libXi/src/Makefile.in b/lib/libXi/src/Makefile.in index a6d6ea56b..8dc82bed2 100644 --- a/lib/libXi/src/Makefile.in +++ b/lib/libXi/src/Makefile.in @@ -134,14 +134,12 @@ FFLAGS = @FFLAGS@ FILE_MAN_DIR = @FILE_MAN_DIR@ FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ GREP = @GREP@ -HAVE_ASCIIDOC_FALSE = @HAVE_ASCIIDOC_FALSE@ -HAVE_ASCIIDOC_TRUE = @HAVE_ASCIIDOC_TRUE@ HAVE_DOCTOOLS_FALSE = @HAVE_DOCTOOLS_FALSE@ HAVE_DOCTOOLS_TRUE = @HAVE_DOCTOOLS_TRUE@ -HAVE_XMLTO_FALSE = @HAVE_XMLTO_FALSE@ -HAVE_XMLTO_TRUE = @HAVE_XMLTO_TRUE@ INSTALL_CMD = @INSTALL_CMD@ INSTALL_DATA = @INSTALL_DATA@ +INSTALL_MANPAGES_FALSE = @INSTALL_MANPAGES_FALSE@ +INSTALL_MANPAGES_TRUE = @INSTALL_MANPAGES_TRUE@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ @@ -158,6 +156,7 @@ MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ MAKEINFO = @MAKEINFO@ MALLOC_ZERO_CFLAGS = @MALLOC_ZERO_CFLAGS@ +MAN_SUBSTS = @MAN_SUBSTS@ MISC_MAN_DIR = @MISC_MAN_DIR@ MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ NMEDIT = @NMEDIT@ @@ -180,6 +179,7 @@ XI_CFLAGS = @XI_CFLAGS@ XI_LIBS = @XI_LIBS@ XMALLOC_ZERO_CFLAGS = @XMALLOC_ZERO_CFLAGS@ XMLTO = @XMLTO@ +XORG_MAN_PAGE = @XORG_MAN_PAGE@ XTMALLOC_ZERO_CFLAGS = @XTMALLOC_ZERO_CFLAGS@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ diff --git a/lib/libXi/src/XExtInt.c b/lib/libXi/src/XExtInt.c index e87ead8a9..80b3fc7cb 100644 --- a/lib/libXi/src/XExtInt.c +++ b/lib/libXi/src/XExtInt.c @@ -173,6 +173,63 @@ static char *XInputErrorList[] = { "BadClass, invalid event class", /* BadClass */ }; +/* Get the version supported by the server to know which number of +* events are support. Otherwise, a wrong number of events may smash +* the Xlib-internal event processing vector. +* +* Since the extension hasn't been initialized yet, we need to +* manually get the opcode, then the version. +*/ +static int +_XiFindEventsSupported(Display *dpy) +{ + XExtCodes codes; + XExtensionVersion *extversion = NULL; + int nevents = 0; + + if (!XQueryExtension(dpy, INAME, &codes.major_opcode, + &codes.first_event, &codes.first_error)) + goto out; + + LockDisplay(dpy); + extversion = _XiGetExtensionVersionRequest(dpy, INAME, codes.major_opcode); + UnlockDisplay(dpy); + SyncHandle(); + + if (!extversion || !extversion->present) + goto out; + + if (extversion->major_version >= 2) + nevents = IEVENTS; /* number is fixed, XI2 adds GenericEvents only */ + else if (extversion->major_version <= 0) + { + printf("XInput_find_display: invalid extension version %d.%d\n", + extversion->major_version, extversion->minor_version); + goto out; + } + else + { + switch(extversion->minor_version) + { + case XI_Add_DeviceProperties_Minor: + nevents = XI_DevicePropertyNotify + 1; + break; + case XI_Add_DevicePresenceNotify_Minor: + nevents = XI_DevicePresenceNotify + 1; + break; + default: + nevents = XI_DeviceButtonstateNotify + 1; + break; + } + } + +out: + if (extversion) + XFree(extversion); + return nevents; +} + + _X_HIDDEN XExtDisplayInfo *XInput_find_display (Display *dpy) { @@ -180,12 +237,17 @@ XExtDisplayInfo *XInput_find_display (Display *dpy) if (!xinput_info) { if (!(xinput_info = XextCreateExtension())) return NULL; } if (!(dpyinfo = XextFindDisplay (xinput_info, dpy))) { + int nevents = _XiFindEventsSupported(dpy); + dpyinfo = XextAddDisplay (xinput_info, dpy, xinput_extension_name, &xinput_extension_hooks, - IEVENTS, NULL); - XESetWireToEventCookie(dpy, dpyinfo->codes->major_opcode, XInputWireToCookie); - XESetCopyEventCookie(dpy, dpyinfo->codes->major_opcode, XInputCopyCookie); + nevents, NULL); + if (dpyinfo->codes) /* NULL if XI doesn't exist on the server */ + { + XESetWireToEventCookie(dpy, dpyinfo->codes->major_opcode, XInputWireToCookie); + XESetCopyEventCookie(dpy, dpyinfo->codes->major_opcode, XInputCopyCookie); + } } return dpyinfo; } diff --git a/lib/libXi/src/XGetVers.c b/lib/libXi/src/XGetVers.c index 3b500aeea..47186178c 100644 --- a/lib/libXi/src/XGetVers.c +++ b/lib/libXi/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); } diff --git a/lib/libXi/src/XIProperties.c b/lib/libXi/src/XIProperties.c index 045cc715f..0f77e5849 100644 --- a/lib/libXi/src/XIProperties.c +++ b/lib/libXi/src/XIProperties.c @@ -150,6 +150,7 @@ XIChangeProperty(Display* dpy, int deviceid, Atom property, Atom type, default: /* BadValue will be generated */ ; + len = 0; } /* we use data instead of Data32 and friends to avoid Xlib's braindead diff --git a/lib/libXi/src/XIQueryVersion.c b/lib/libXi/src/XIQueryVersion.c index a14e9c987..1e4f9a443 100644 --- a/lib/libXi/src/XIQueryVersion.c +++ b/lib/libXi/src/XIQueryVersion.c @@ -60,7 +60,6 @@ _xiQueryVersion(Display * dpy, int *major, int *minor, XExtDisplayInfo *info) if (!info || !info->data) { *major = 0; *minor = 0; - UnlockDisplay(dpy); return BadRequest; } diff --git a/lib/libXi/src/XISelEv.c b/lib/libXi/src/XISelEv.c index bdc4fd1b0..f1f3fa425 100644 --- a/lib/libXi/src/XISelEv.c +++ b/lib/libXi/src/XISelEv.c @@ -48,11 +48,14 @@ XISelectEvents(Display* dpy, Window win, XIEventMask* masks, int num_masks) xXIEventMask mask; int i; int len = 0; + int r = Success; XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); - if (_XiCheckExtInit(dpy, Dont_Check, info) == -1) - return (NoSuchExtension); + if (_XiCheckExtInit(dpy, Dont_Check, info) == -1) { + r = NoSuchExtension; + goto out; + } GetReq(XISelectEvents, req); req->reqType = info->codes->major_opcode; @@ -85,9 +88,10 @@ XISelectEvents(Display* dpy, Window win, XIEventMask* masks, int num_masks) free(buff); } +out: UnlockDisplay(dpy); SyncHandle(); - return Success; + return r; } @@ -100,14 +104,12 @@ XIGetSelectedEvents(Display* dpy, Window win, int *num_masks_return) xXIEventMask *mask_in = NULL, *mi; xXIGetSelectedEventsReq *req; xXIGetSelectedEventsReply reply; - XExtDisplayInfo *info = XInput_find_display(dpy); + + *num_masks_return = -1; LockDisplay(dpy); if (_XiCheckExtInit(dpy, Dont_Check, info) == -1) - { - *num_masks_return = -1; - return NULL; - } + goto out; GetReq(XIGetSelectedEvents, req); @@ -116,17 +118,17 @@ XIGetSelectedEvents(Display* dpy, Window win, int *num_masks_return) req->win = win; if (!_XReply(dpy, (xReply *) &reply, 0, xFalse)) - goto error; + goto out; if (reply.num_masks == 0) { *num_masks_return = 0; - return NULL; + goto out; } mask_in = Xmalloc(reply.length * 4); if (!mask_in) - goto error; + goto out; _XRead(dpy, (char*)mask_in, reply.length * 4); @@ -144,7 +146,7 @@ XIGetSelectedEvents(Display* dpy, Window win, int *num_masks_return) mask_out = Xmalloc(len); if (!mask_out) - goto error; + goto out; mi = mask_in; mask = (unsigned char*)&mask_out[reply.num_masks]; @@ -161,14 +163,11 @@ XIGetSelectedEvents(Display* dpy, Window win, int *num_masks_return) *num_masks_return = reply.num_masks; - return mask_out; +out: + Xfree(mask_in); -error: - if (mask_in) - Xfree(mask_in); - *num_masks_return = -1; UnlockDisplay(dpy); SyncHandle(); - return NULL; + return mask_out; } diff --git a/lib/libXi/src/XIint.h b/lib/libXi/src/XIint.h index 400c92077..00e84d354 100644 --- a/lib/libXi/src/XIint.h +++ b/lib/libXi/src/XIint.h @@ -14,6 +14,7 @@ extern XExtDisplayInfo *XInput_find_display(Display *); extern int _XiCheckExtInit(Display *, int, XExtDisplayInfo *); extern XExtensionVersion *_XiGetExtensionVersion(Display *, _Xconst char *, XExtDisplayInfo *); +extern XExtensionVersion* _XiGetExtensionVersionRequest(Display *dpy, _Xconst char *name, int xi_opcode); extern Status _xiQueryVersion(Display *dpy, int*, int*, XExtDisplayInfo *); extern Status _XiEventToWire( |