Fix double unlock when _XiCheckExtInit return -1.

_XiCheckExtInit unlocks the display if it fails and returns -1. Most callers
account for it properly, but few didn't.

Signed-off-by: Michal Srb <msrb@suse.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
XIChangeHierarchy: Add missing unlock.

When num_changes <= 0 or Xmalloc fails, the display has to be unlocked.

Signed-off-by: Michal Srb <msrb@suse.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Do not return NoSuchExtension casted to pointer as an error.

Several functions were returning NoSuchExtension casted to a pointer in case of
an error. Often in parallel with returning NULL in case of another error. It is
undocumented and certainly wrong.

Signed-off-by: Michal Srb <msrb@suse.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
XIGetClientPointer: Return False on error.

Not NoSuchExtension which is 1 = True!

Signed-off-by: Michal Srb <msrb@suse.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Fix logic in _XIAllowEvents and prevent double unlock.

Replacing the second _XiCheckExtInit with _XiCheckVersion prevents possible
double unlock as _XiCheckExtInit actually unlocks the display when it returns
-1.

Signed-off-by: Michal Srb <msrb@suse.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Refactor XGetExtensionVersion.

_XiGetExtensionVersion was called from XGetExtensionVersion and from
_XiCheckExtInit. When called from _XiCheckExtInit, nothing accounted for the
fact that it can return ((XExtensionVersion *) NoSuchExtension) in case of
error. Also it recursively calls _XiCheckExtInit potentionally causing multiple
unlocks if _XiCheckExtInit fails.
-> Remove it and call directly _XiGetExtensionVersionRequest and only call
_XiCheckExtInit only from XGetExtensionVersion.

Signed-off-by: Michal Srb <msrb@suse.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
XIGrabDevice: Unlock display in error path.

Signed-off-by: Michal Srb <msrb@suse.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>