From c27e00ceceed3fea011c98c0e70ab568bf0687c6 Mon Sep 17 00:00:00 2001 From: Jamey Sharp Date: Sun, 15 Oct 2006 00:26:21 -0700 Subject: Don't call XInput_find_display in _XiCheckExtInit, while the Display lock is held. All callers of _XiCheckExtInit have already called XInput_find_display first outside the lock, so just pass their copy of the XExtDisplayInfo structure down. Besides being more correct, this should be slightly faster. :-) Thanks to Magnus Kessler for identifying the bug and proposing a workaround. --- src/XAllowDv.c | 2 +- src/XChgDCtl.c | 2 +- src/XChgFCtl.c | 2 +- src/XChgKMap.c | 2 +- src/XChgKbd.c | 2 +- src/XChgPnt.c | 2 +- src/XChgProp.c | 2 +- src/XCloseDev.c | 2 +- src/XDevBell.c | 2 +- src/XExtInt.c | 4 ++-- src/XGMotion.c | 2 +- src/XGetBMap.c | 2 +- src/XGetDCtl.c | 2 +- src/XGetFCtl.c | 2 +- src/XGetKMap.c | 2 +- src/XGetMMap.c | 2 +- src/XGetProp.c | 2 +- src/XGetVers.c | 2 +- src/XGrDvBut.c | 2 +- src/XGrDvKey.c | 2 +- src/XGrabDev.c | 2 +- src/XGtFocus.c | 2 +- src/XGtSelect.c | 2 +- src/XIint.h | 2 +- src/XListDev.c | 2 +- src/XOpenDev.c | 2 +- src/XQueryDv.c | 2 +- src/XSelect.c | 2 +- src/XSetBMap.c | 2 +- src/XSetDVal.c | 2 +- src/XSetMMap.c | 2 +- src/XSetMode.c | 2 +- src/XSndExEv.c | 2 +- src/XUngrDev.c | 2 +- src/XUngrDvB.c | 2 +- src/XUngrDvK.c | 2 +- 36 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/XAllowDv.c b/src/XAllowDv.c index 94a27ca..7fd2a07 100644 --- a/src/XAllowDv.c +++ b/src/XAllowDv.c @@ -71,7 +71,7 @@ XAllowDeviceEvents(dpy, dev, event_mode, time) XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); - if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) + if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) return (NoSuchExtension); GetReq(AllowDeviceEvents, req); diff --git a/src/XChgDCtl.c b/src/XChgDCtl.c index a196523..9e71475 100644 --- a/src/XChgDCtl.c +++ b/src/XChgDCtl.c @@ -74,7 +74,7 @@ XChangeDeviceControl(dpy, dev, control, d) XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); - if (_XiCheckExtInit(dpy, XInput_Add_XChangeDeviceControl) == -1) + if (_XiCheckExtInit(dpy, XInput_Add_XChangeDeviceControl, info) == -1) return (NoSuchExtension); GetReq(ChangeDeviceControl, req); diff --git a/src/XChgFCtl.c b/src/XChgFCtl.c index 32c7b24..e499b41 100644 --- a/src/XChgFCtl.c +++ b/src/XChgFCtl.c @@ -73,7 +73,7 @@ XChangeFeedbackControl(dpy, dev, mask, f) XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); - if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) + if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) return (NoSuchExtension); GetReq(ChangeFeedbackControl, req); diff --git a/src/XChgKMap.c b/src/XChgKMap.c index d0a334f..73de754 100644 --- a/src/XChgKMap.c +++ b/src/XChgKMap.c @@ -74,7 +74,7 @@ XChangeDeviceKeyMapping(dpy, dev, first, syms_per_code, keysyms, count) XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); - if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) + if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) return (NoSuchExtension); GetReq(ChangeDeviceKeyMapping, req); diff --git a/src/XChgKbd.c b/src/XChgKbd.c index feba239..1b01207 100644 --- a/src/XChgKbd.c +++ b/src/XChgKbd.c @@ -70,7 +70,7 @@ XChangeKeyboardDevice(dpy, dev) XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); - if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) + if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) return (NoSuchExtension); GetReq(ChangeKeyboardDevice, req); diff --git a/src/XChgPnt.c b/src/XChgPnt.c index 9e0a617..6123398 100644 --- a/src/XChgPnt.c +++ b/src/XChgPnt.c @@ -72,7 +72,7 @@ XChangePointerDevice(dpy, dev, xaxis, yaxis) XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); - if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) + if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) return (NoSuchExtension); GetReq(ChangePointerDevice, req); diff --git a/src/XChgProp.c b/src/XChgProp.c index 6939cb3..0c7377f 100644 --- a/src/XChgProp.c +++ b/src/XChgProp.c @@ -73,7 +73,7 @@ XChangeDeviceDontPropagateList(dpy, window, count, events, mode) XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); - if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) + if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) return (NoSuchExtension); GetReq(ChangeDeviceDontPropagateList, req); diff --git a/src/XCloseDev.c b/src/XCloseDev.c index 71e792a..ca19860 100644 --- a/src/XCloseDev.c +++ b/src/XCloseDev.c @@ -69,7 +69,7 @@ XCloseDevice(dpy, dev) XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); - if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) + if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) return (NoSuchExtension); GetReq(CloseDevice, req); diff --git a/src/XDevBell.c b/src/XDevBell.c index 276a1b8..73f2e35 100644 --- a/src/XDevBell.c +++ b/src/XDevBell.c @@ -71,7 +71,7 @@ XDeviceBell(dpy, dev, feedbackclass, feedbackid, percent) XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); - if (_XiCheckExtInit(dpy, XInput_Add_XDeviceBell) == -1) + if (_XiCheckExtInit(dpy, XInput_Add_XDeviceBell, info) == -1) return (NoSuchExtension); GetReq(DeviceBell, req); diff --git a/src/XExtInt.c b/src/XExtInt.c index aa838ef..b7297dc 100644 --- a/src/XExtInt.c +++ b/src/XExtInt.c @@ -191,12 +191,12 @@ _xidevicebusy(dpy, error) */ int -_XiCheckExtInit(dpy, version_index) +_XiCheckExtInit(dpy, version_index, info) register Display *dpy; register int version_index; + XExtDisplayInfo *info; { XExtensionVersion *ext; - XExtDisplayInfo *info = XInput_find_display(dpy); XInputCheckExtension(dpy, info, -1); diff --git a/src/XGMotion.c b/src/XGMotion.c index abcc06a..daa8792 100644 --- a/src/XGMotion.c +++ b/src/XGMotion.c @@ -85,7 +85,7 @@ Time stop; XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); - if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) + if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) return ((XDeviceTimeCoord *) NoSuchExtension); GetReq(GetDeviceMotionEvents, req); diff --git a/src/XGetBMap.c b/src/XGetBMap.c index 1eaaa23..15cad74 100644 --- a/src/XGetBMap.c +++ b/src/XGetBMap.c @@ -81,7 +81,7 @@ XGetDeviceButtonMapping(dpy, device, map, nmap) xGetDeviceButtonMappingReply rep; LockDisplay(dpy); - if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) + if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) return (NoSuchExtension); GetReq(GetDeviceButtonMapping, req); diff --git a/src/XGetDCtl.c b/src/XGetDCtl.c index 139f7e7..8d034bf 100644 --- a/src/XGetDCtl.c +++ b/src/XGetDCtl.c @@ -78,7 +78,7 @@ XGetDeviceControl(dpy, dev, control) XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); - if (_XiCheckExtInit(dpy, XInput_Add_XChangeDeviceControl) == -1) + if (_XiCheckExtInit(dpy, XInput_Add_XChangeDeviceControl, info) == -1) return ((XDeviceControl *) NoSuchExtension); GetReq(GetDeviceControl, req); diff --git a/src/XGetFCtl.c b/src/XGetFCtl.c index 0101fc0..af4578c 100644 --- a/src/XGetFCtl.c +++ b/src/XGetFCtl.c @@ -78,7 +78,7 @@ XGetFeedbackControl(dpy, dev, num_feedbacks) XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); - if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) + if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) return ((XFeedbackState *) NoSuchExtension); GetReq(GetFeedbackControl, req); diff --git a/src/XGetKMap.c b/src/XGetKMap.c index 59f6f93..0381e86 100644 --- a/src/XGetKMap.c +++ b/src/XGetKMap.c @@ -76,7 +76,7 @@ XGetDeviceKeyMapping(register Display * dpy, XDevice * dev, XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); - if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) + if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) return ((KeySym *) NoSuchExtension); GetReq(GetDeviceKeyMapping, req); diff --git a/src/XGetMMap.c b/src/XGetMMap.c index 4a8c32f..ef92281 100644 --- a/src/XGetMMap.c +++ b/src/XGetMMap.c @@ -72,7 +72,7 @@ XGetDeviceModifierMapping(dpy, dev) XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); - if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) + if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) return ((XModifierKeymap *) NoSuchExtension); GetReq(GetDeviceModifierMapping, req); diff --git a/src/XGetProp.c b/src/XGetProp.c index 0ea8ceb..71d844b 100644 --- a/src/XGetProp.c +++ b/src/XGetProp.c @@ -75,7 +75,7 @@ Window window; XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); - if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) + if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) return ((XEventClass *) NoSuchExtension); GetReq(GetDeviceDontPropagateList, req); diff --git a/src/XGetVers.c b/src/XGetVers.c index ef41fea..d3c765a 100644 --- a/src/XGetVers.c +++ b/src/XGetVers.c @@ -82,7 +82,7 @@ _XiGetExtensionVersion(register Display * dpy, _Xconst char *name, XExtDisplayIn xGetExtensionVersionReply rep; XExtensionVersion *ext; - if (_XiCheckExtInit(dpy, Dont_Check) == -1) + if (_XiCheckExtInit(dpy, Dont_Check, info) == -1) return ((XExtensionVersion *) NoSuchExtension); GetReq(GetExtensionVersion, req); diff --git a/src/XGrDvBut.c b/src/XGrDvBut.c index fbc26ba..6e35099 100644 --- a/src/XGrDvBut.c +++ b/src/XGrDvBut.c @@ -80,7 +80,7 @@ XGrabDeviceButton(dpy, dev, button, modifiers, modifier_device, XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); - if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) + if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) return (NoSuchExtension); GetReq(GrabDeviceButton, req); diff --git a/src/XGrDvKey.c b/src/XGrDvKey.c index 6731e2c..1389753 100644 --- a/src/XGrDvKey.c +++ b/src/XGrDvKey.c @@ -80,7 +80,7 @@ XGrabDeviceKey(dpy, dev, key, modifiers, modifier_device, XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); - if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) + if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) return (NoSuchExtension); GetReq(GrabDeviceKey, req); diff --git a/src/XGrabDev.c b/src/XGrabDev.c index 536e369..92f1c11 100644 --- a/src/XGrabDev.c +++ b/src/XGrabDev.c @@ -78,7 +78,7 @@ XGrabDevice(dpy, dev, grab_window, ownerEvents, event_count, event_list, XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); - if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) + if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) return (NoSuchExtension); GetReq(GrabDevice, req); diff --git a/src/XGtFocus.c b/src/XGtFocus.c index 08cebd9..4e63918 100644 --- a/src/XGtFocus.c +++ b/src/XGtFocus.c @@ -73,7 +73,7 @@ XGetDeviceFocus(dpy, dev, focus, revert_to, time) XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); - if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) + if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) return (NoSuchExtension); GetReq(GetDeviceFocus, req); diff --git a/src/XGtSelect.c b/src/XGtSelect.c index 0f63caf..9f596fd 100644 --- a/src/XGtSelect.c +++ b/src/XGtSelect.c @@ -76,7 +76,7 @@ XGetSelectedExtensionEvents(dpy, w, this_client_count, this_client_list, XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); - if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) + if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) return (NoSuchExtension); GetReq(GetSelectedExtensionEvents, req); diff --git a/src/XIint.h b/src/XIint.h index ae6d33f..f35619c 100644 --- a/src/XIint.h +++ b/src/XIint.h @@ -10,7 +10,7 @@ extern XExtDisplayInfo *XInput_find_display(Display *); -extern int _XiCheckExtInit(Display *, int); +extern int _XiCheckExtInit(Display *, int, XExtDisplayInfo *); extern XExtensionVersion *_XiGetExtensionVersion(Display *, _Xconst char *, XExtDisplayInfo *); diff --git a/src/XListDev.c b/src/XListDev.c index ea9aa62..b9a617d 100644 --- a/src/XListDev.c +++ b/src/XListDev.c @@ -82,7 +82,7 @@ XListInputDevices(dpy, ndevices) XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); - if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) + if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) return ((XDeviceInfo *) NULL); GetReq(ListInputDevices, req); diff --git a/src/XOpenDev.c b/src/XOpenDev.c index ed168a6..d220330 100644 --- a/src/XOpenDev.c +++ b/src/XOpenDev.c @@ -72,7 +72,7 @@ XOpenDevice(dpy, id) XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); - if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) + if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) return ((XDevice *) NoSuchExtension); GetReq(OpenDevice, req); diff --git a/src/XQueryDv.c b/src/XQueryDv.c index a3a75f2..540f224 100644 --- a/src/XQueryDv.c +++ b/src/XQueryDv.c @@ -76,7 +76,7 @@ XQueryDeviceState(dpy, dev) XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); - if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) + if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) return ((XDeviceState *) NoSuchExtension); GetReq(QueryDeviceState, req); diff --git a/src/XSelect.c b/src/XSelect.c index b23829a..af0fb84 100644 --- a/src/XSelect.c +++ b/src/XSelect.c @@ -71,7 +71,7 @@ XSelectExtensionEvent(dpy, w, event_list, count) XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); - if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) + if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) return (NoSuchExtension); GetReq(SelectExtensionEvent, req); diff --git a/src/XSetBMap.c b/src/XSetBMap.c index bdfe501..cad6976 100644 --- a/src/XSetBMap.c +++ b/src/XSetBMap.c @@ -75,7 +75,7 @@ XSetDeviceButtonMapping(dpy, device, map, nmap) XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); - if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) + if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) return (NoSuchExtension); GetReq(SetDeviceButtonMapping, req); req->reqType = info->codes->major_opcode; diff --git a/src/XSetDVal.c b/src/XSetDVal.c index 6b382f1..43702b0 100644 --- a/src/XSetDVal.c +++ b/src/XSetDVal.c @@ -74,7 +74,7 @@ XSetDeviceValuators(dpy, dev, valuators, first_valuator, num_valuators) XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); - if (_XiCheckExtInit(dpy, XInput_Add_XSetDeviceValuators) == -1) + if (_XiCheckExtInit(dpy, XInput_Add_XSetDeviceValuators, info) == -1) return (NoSuchExtension); GetReq(SetDeviceValuators, req); diff --git a/src/XSetMMap.c b/src/XSetMMap.c index b0838f6..1077433 100644 --- a/src/XSetMMap.c +++ b/src/XSetMMap.c @@ -72,7 +72,7 @@ XSetDeviceModifierMapping(dpy, dev, modmap) XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); - if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) + if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) return (NoSuchExtension); GetReqExtra(SetDeviceModifierMapping, mapSize, req); diff --git a/src/XSetMode.c b/src/XSetMode.c index 278c4ff..94e2b3d 100644 --- a/src/XSetMode.c +++ b/src/XSetMode.c @@ -71,7 +71,7 @@ XSetDeviceMode(dpy, dev, mode) XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); - if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) + if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) return (NoSuchExtension); GetReq(SetDeviceMode, req); diff --git a/src/XSndExEv.c b/src/XSndExEv.c index 6d65745..71431cd 100644 --- a/src/XSndExEv.c +++ b/src/XSndExEv.c @@ -81,7 +81,7 @@ XSendExtensionEvent(dpy, dev, dest, prop, count, list, event) XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); - if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) + if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) return (NoSuchExtension); /* call through display to find proper conversion routine */ diff --git a/src/XUngrDev.c b/src/XUngrDev.c index ecc8887..70ba03d 100644 --- a/src/XUngrDev.c +++ b/src/XUngrDev.c @@ -70,7 +70,7 @@ XUngrabDevice(dpy, dev, time) XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); - if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) + if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) return (NoSuchExtension); GetReq(UngrabDevice, req); diff --git a/src/XUngrDvB.c b/src/XUngrDvB.c index 07f2c3f..77dbe77 100644 --- a/src/XUngrDvB.c +++ b/src/XUngrDvB.c @@ -73,7 +73,7 @@ XUngrabDeviceButton(dpy, dev, button, modifiers, modifier_dev, grab_window) XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); - if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) + if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) return (NoSuchExtension); GetReq(UngrabDeviceButton, req); diff --git a/src/XUngrDvK.c b/src/XUngrDvK.c index e9e4cdf..0ae3178 100644 --- a/src/XUngrDvK.c +++ b/src/XUngrDvK.c @@ -73,7 +73,7 @@ XUngrabDeviceKey(dpy, dev, key, modifiers, modifier_dev, grab_window) XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); - if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) + if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) return (NoSuchExtension); GetReq(UngrabDeviceKey, req); -- cgit v1.2.3