[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

libxi: Changes to 'debian-unstable'



 debian/changelog                                                               |   17 
 debian/patches/0001-Initialize-extension-with-the-right-number-of-events.patch |  174 ----------
 debian/patches/series                                                          |    1 
 man/XAllowDeviceEvents.txt                                                     |   56 +--
 man/XGetDeviceProperty.txt                                                     |    5 
 man/XIQueryDevice.txt                                                          |    6 
 man/XSelectExtensionEvent.txt                                                  |    8 
 src/XExtInt.c                                                                  |   70 +++-
 src/XGetVers.c                                                                 |   24 -
 src/XIProperties.c                                                             |    1 
 src/XIQueryVersion.c                                                           |    1 
 src/XISelEv.c                                                                  |   33 -
 src/XIint.h                                                                    |    1 
 13 files changed, 152 insertions(+), 245 deletions(-)

New commits:
commit aeeb6237d48edf98d6361c4d1963ff5521cc3aab
Author: Julien Cristau <jcristau@debian.org>
Date:   Thu Nov 18 17:17:08 2010 +0100

    Add changelog entry and drop obsolete patch

diff --git a/debian/changelog b/debian/changelog
index 7d7fcd9..968e34b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,20 @@
+libxi (2:1.3-5) UNRELEASED; urgency=low
+
+  * Cherry-picked fixes from upstream:
+    - man: fix types for XGetSelectedExtensionEvents
+    - Initialize extension with the right number of events (obsoletes our
+      quilt patch)
+    - Don't unlock the Display twice
+    - Fix usage of uninitialized value
+    - Fix memory leak in XIGetSelectedEvents
+    - Always unlock display correctly
+    - man: improve readability of XAllowDeviceEvents
+    - man: fix typo in XIQueryDevice doc (closes: #598964)
+    - Fix typo when converting raw events from the wire
+    - man: XGetDeviceProperty(3) has no parameter 'pending'
+
+ -- Julien Cristau <jcristau@debian.org>  Thu, 18 Nov 2010 17:14:40 +0100
+
 libxi (2:1.3-4) unstable; urgency=low
 
   * Add udeb needed for the graphical installer: libxi6-udeb.
diff --git a/debian/patches/0001-Initialize-extension-with-the-right-number-of-events.patch b/debian/patches/0001-Initialize-extension-with-the-right-number-of-events.patch
deleted file mode 100644
index 6261652..0000000
--- a/debian/patches/0001-Initialize-extension-with-the-right-number-of-events.patch
+++ /dev/null
@@ -1,174 +0,0 @@
-From 5e87ce95525d6634066384b8dc829bb7c90ec008 Mon Sep 17 00:00:00 2001
-From: Peter Hutterer <peter.hutterer@who-t.net>
-Date: Wed, 9 Dec 2009 14:06:36 +1000
-Subject: [PATCH] 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>
----
- src/XExtInt.c  |   61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
- src/XGetVers.c |   24 ++++++++++++++-------
- src/XIint.h    |    1 +
- 3 files changed, 77 insertions(+), 9 deletions(-)
-
-Index: libxi/src/XExtInt.c
-===================================================================
---- libxi.orig/src/XExtInt.c
-+++ libxi/src/XExtInt.c
-@@ -173,6 +173,64 @@
-     "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)
-+    {
-+        fprintf(stderr,
-+                "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 +238,16 @@
-     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) {
-+	  XESetWireToEventCookie(dpy, dpyinfo->codes->major_opcode, XInputWireToCookie);
-+	  XESetCopyEventCookie(dpy, dpyinfo->codes->major_opcode, XInputCopyCookie);
-+      }
-     }
-     return dpyinfo;
- }
-Index: libxi/src/XGetVers.c
-===================================================================
---- libxi.orig/src/XGetVers.c
-+++ libxi/src/XGetVers.c
-@@ -72,19 +72,15 @@
-     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 @@
-     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 @@
- 	    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);
- }
-Index: libxi/src/XIint.h
-===================================================================
---- libxi.orig/src/XIint.h
-+++ libxi/src/XIint.h
-@@ -14,6 +14,7 @@
- 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(
diff --git a/debian/patches/series b/debian/patches/series
index 89c1e5c..e69de29 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +0,0 @@
-0001-Initialize-extension-with-the-right-number-of-events.patch

commit e9efb471f5396a25aee5650ed4b8f3733c3be2d2
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Tue Nov 2 11:22:01 2010 +1000

    man: XGetDeviceProperty(3) has no parameter 'pending'.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Julien Cristau <jcristau@debian.org>
    (cherry picked from commit 556246beaffb42e1f58d816542d91e360ea02080)

diff --git a/man/XGetDeviceProperty.txt b/man/XGetDeviceProperty.txt
index b557216..403aa96 100644
--- a/man/XGetDeviceProperty.txt
+++ b/man/XGetDeviceProperty.txt
@@ -19,7 +19,6 @@ SYNOPSIS
                            long offset,
                            long length,
                            Bool delete,
-                           Bool pending,
                            Atom req_type,
                            Atom *actual_type_return,
                            int *actual_format_return,
@@ -96,10 +95,6 @@ SYNOPSIS
           Specifies the offset in the specified property (in
           32-bit quantities) where the data is to be retrieved.
 
-   pending
-          Specifies whether to retrieve the pending state of the
-          property or the current state.
-
    property
           Specifies the property to modify or query.
 

commit dddf0a73aa712853029a70a65406ef827bf1563e
Author: Carlos Garnacho <carlosg@gnome.org>
Date:   Wed Oct 6 11:04:21 2010 +0200

    Fix typo when converting raw events from the wire.
    
    The raw values were being miscalculated, containing only the integral part
    of the FP3232, meanwhile normal valuators were mistakenly added the fractional
    part of its corresponding raw value.
    
    Signed-off-by: Carlos Garnacho <carlosg@gnome.org>
    Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    (cherry picked from commit f237427f897d1dc527494653735d4bb93d740546)
    (cherry picked from commit dc9d2fd462ef3ba5176c74a2456822fe1671053d)

diff --git a/src/XExtInt.c b/src/XExtInt.c
index 80b3fc7..db7aa78 100644
--- a/src/XExtInt.c
+++ b/src/XExtInt.c
@@ -1640,7 +1640,7 @@ wireToRawEvent(xXIRawEvent *in, XGenericEventCookie *cookie)
         out->valuators.values[i] = values->integral;
         out->valuators.values[i] += ((double)values->frac / (1 << 16) / (1 << 16));
         out->raw_values[i] = (values + bits)->integral;
-        out->valuators.values[i] += ((double)(values + bits)->frac / (1 << 16) / (1 << 16));
+        out->raw_values[i] += ((double)(values + bits)->frac / (1 << 16) / (1 << 16));
         values++;
     }
 

commit 1f3c2d947dbf1020cd8ed19ff0f96da2037694a4
Author: Julien Cristau <jcristau@debian.org>
Date:   Sun Oct 3 17:04:57 2010 +0200

    man: fix typo in XIQueryDevice doc
    
    Don't pretend this is XIQueryPointer.
    
    Debian bug#598964
    Reported-by: Joachim Breitner <nomeata@debian.org>
    Signed-off-by: Julien Cristau <jcristau@debian.org>
    (cherry picked from commit abc26c71b6032683b89085a7ebcd40ca81cdf3f2)
    (cherry picked from commit b7c8e70f3f93e5ff1b64bff33b802d53c867adf8)

diff --git a/man/XIQueryDevice.txt b/man/XIQueryDevice.txt
index 9fd0ee7..2b1f76f 100644
--- a/man/XIQueryDevice.txt
+++ b/man/XIQueryDevice.txt
@@ -11,9 +11,9 @@ SYNOPSIS
 
    #include <X11/extensions/XInput2.h>
 
-   XIDeviceInfo* XIQueryPointer( Display *display,
-                                 int deviceid,
-                                 int *ndevices_return);
+   XIDeviceInfo* XIQueryDevice( Display *display,
+                                int deviceid,
+                                int *ndevices_return);
 
    XIFreeDeviceInfo( XIDeviceInfo *info);
 

commit 9eab6d6dcff18acf9ac81cf618ae17f18a6e6331
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Mon Aug 2 15:40:32 2010 +1000

    man: improve readability of XAllowDeviceEvents.
    
    Parse the options to event-mode as a list. This requires un-indenting the
    rest, otherwise the asciidoc/xmlto conversion will indent the trailing
    paragraphs more than the list
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    (cherry picked from commit 3f2814a0f9193cb33b44ef53059a4b349cf4cabc)
    (cherry picked from commit 5178b897167b54a78d6577441f1e27b797823f46)

diff --git a/man/XAllowDeviceEvents.txt b/man/XAllowDeviceEvents.txt
index 91d358c..ba7fde3 100644
--- a/man/XAllowDeviceEvents.txt
+++ b/man/XAllowDeviceEvents.txt
@@ -34,16 +34,16 @@ SYNOPSIS
 DESCRIPTION
 -----------
 
-   The XAllowDeviceEvents function releases some queued events if
-   the client has caused a device to freeze. It has no effect if
-   the specified time is earlier than the last-grab time of the
-   most recent active grab for the client and device, or if the
-   specified time is later than the current X server time.
+The XAllowDeviceEvents function releases some queued events if
+the client has caused a device to freeze. It has no effect if
+the specified time is earlier than the last-grab time of the
+most recent active grab for the client and device, or if the
+specified time is later than the current X server time.
 
-   The following describes the processing that occurs depending on
-   what constant you pass to the event_mode argument.
+The following describes the processing that occurs depending on
+what constant you pass to the event_mode argument.
 
-   AsyncThisDevice If the specified device is frozen by the
+   * AsyncThisDevice - If the specified device is frozen by the
    client, event processing for that device continues as usual. If
    the device is frozen multiple times by the client on behalf of
    multiple separate grabs, AsyncThisDevice thaws for
@@ -51,7 +51,7 @@ DESCRIPTION
    not frozen by the client, but the device need not be grabbed by
    the client.
 
-   SyncThisDevice If the specified device is frozen and actively
+   * SyncThisDevice - If the specified device is frozen and actively
    grabbed by the client, event processing for that device
    continues normally until the next key or button event is
    reported to the client. At this time, the specified device
@@ -60,7 +60,7 @@ DESCRIPTION
    SyncThisDevice has no effect if the specified device is not
    frozen by the client or is not grabbed by the client.
 
-   ReplayThisDevice If the specified device is actively grabbed by
+   * ReplayThisDevice - If the specified device is actively grabbed by
    the client and is frozen as the result of an event having been
    sent to the client (either from the activation of a
    GrabDeviceButton or from a previous AllowDeviceEvents with mode
@@ -72,14 +72,14 @@ DESCRIPTION
    not grabbed by the client or if it is not frozen as the result
    of an event.
 
-   AsyncOtherDevices If the remaining devices are frozen by the
+   * AsyncOtherDevices - If the remaining devices are frozen by the
    client, event processing for them continues as usual. If the
    other devices are frozen multiple times by the client on behalf
    of multiple grabs, AsyncOtherDevices "thaws" for all.
    AsyncOtherDevices has no effect if the devices are not frozen
    by the client.
 
-   SyncAll If all devices are frozen by the client, event
+   * SyncAll - If all devices are frozen by the client, event
    processing (for all devices) continues normally until the next
    button or key event is reported to the client for a grabbed
    device, at which time all devices again appear to freeze.
@@ -92,27 +92,27 @@ DESCRIPTION
    subsequent freeze for SyncAll will only freeze each device
    once.
 
-   AsyncAll If all devices are frozen by the client, event
+   * AsyncAll - If all devices are frozen by the client, event
    processing for all devices continues normally. If any device is
    frozen multiple times by the client on behalf of multiple
    separate grabs, AsyncAll thaws for all. AsyncAll has no effect
    unless all devices are frozen by the client.
 
-   AsyncThisDevice, SyncThisDevice, and ReplayThisDevice have no
-   effect on the processing of events from the remaining
-   devices.AsyncOtherDevices has no effect on the processing of
-   events from the specified device. When the event_mode is
-   SyncAll or AsyncAll, the device parameter is ignored.
-
-   It is possible for several grabs of different devices by the
-   same or different clients to be active simultaneously. If a
-   device is frozen on behalf of any grab, no event processing is
-   performed for the device. It is possible for a single device to
-   be frozen because of several grabs. In this case, the freeze
-   must be released on behalf of each grab before events can again
-   be processed.
-
-   XAllowDeviceEvents can generate a BadDevice or BadValue error.
+AsyncThisDevice, SyncThisDevice, and ReplayThisDevice have no
+effect on the processing of events from the remaining
+devices.AsyncOtherDevices has no effect on the processing of
+events from the specified device. When the event_mode is
+SyncAll or AsyncAll, the device parameter is ignored.
+
+It is possible for several grabs of different devices by the
+same or different clients to be active simultaneously. If a
+device is frozen on behalf of any grab, no event processing is
+performed for the device. It is possible for a single device to
+be frozen because of several grabs. In this case, the freeze
+must be released on behalf of each grab before events can again
+be processed.
+
+XAllowDeviceEvents can generate a BadDevice or BadValue error.
 
 DIAGNOSTICS
 -------------

commit 51bd24b0d9dbb5e7384956911e5126e467fc2678
Author: Pauli Nieminen <ext-pauli.nieminen@nokia.com>
Date:   Fri Jun 18 11:32:36 2010 +0300

    Always unlock display correctly
    
    XISelectEvents and XIGetSelectedEvents were not unlocking display in all
    return paths.
    
    Reported-by: Julien Cristau <jcristau@debian.org>
    Signed-off-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com>
    (cherry picked from commit 8daf961d0fe6a1433c8248d984618a7e22ff88b8)
    (cherry picked from commit b764411d074f0379810b7e921473504b539cfdf3)

diff --git a/src/XISelEv.c b/src/XISelEv.c
index 3c1f018..dad890e 100644
--- a/src/XISelEv.c
+++ b/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;
 
 }
 
@@ -101,13 +105,11 @@ XIGetSelectedEvents(Display* dpy, Window win, int *num_masks_return)
     xXIGetSelectedEventsReq *req;
     xXIGetSelectedEventsReply reply;
 
+    *num_masks_return = -1;
     XExtDisplayInfo *info = XInput_find_display(dpy);
     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,16 +163,11 @@ XIGetSelectedEvents(Display* dpy, Window win, int *num_masks_return)
 
     *num_masks_return = reply.num_masks;
 
+out:
     Xfree(mask_in);
 
-    return mask_out;
-
-error:
-    if (mask_in)
-        Xfree(mask_in);
-    *num_masks_return = -1;
     UnlockDisplay(dpy);
     SyncHandle();
-    return NULL;
 
+    return mask_out;
 }

commit bc027f52efbd568e17857b9187255d76dcb25ceb
Author: Pauli Nieminen <ext-pauli.nieminen@nokia.com>
Date:   Mon Jun 14 10:05:36 2010 +0300

    Fix memory leak in XIGetSelectedEvents
    
    mask_in was leaking for every successfull XIGetSelectedEvents.
    
    Signed-off-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com>
    Reviewed-by: Julien Cristau <jcristau@debian.org>
    (cherry picked from commit b953bf7b9775e5970776a21ae3f7919592289c92)
    (cherry picked from commit e116a06d5964e51623d68c329119be87d3ce8ab0)

diff --git a/src/XISelEv.c b/src/XISelEv.c
index bdc4fd1..3c1f018 100644
--- a/src/XISelEv.c
+++ b/src/XISelEv.c
@@ -161,6 +161,8 @@ XIGetSelectedEvents(Display* dpy, Window win, int *num_masks_return)
 
     *num_masks_return = reply.num_masks;
 
+    Xfree(mask_in);
+
     return mask_out;
 
 error:

commit abe783205b5c41616161c2c74b317dbe12385ce0
Author: Pauli Nieminen <ext-pauli.nieminen@nokia.com>
Date:   Fri Jun 11 17:30:44 2010 +0300

    Fix usage of uninitialized value
    
    In error case length of extra data could be uninitialized. This would
    result randomly sized request later in function.
    
    Signed-off-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com>
    Reviewed-by: Julien Cristau <jcristau@debian.org>
    (cherry picked from commit 6199f89992e2b6ba5f96833f4f4087b61ca61ac5)
    (cherry picked from commit e2a82e587b528e2d1b352ee89d9f0b4ad5450f0a)

diff --git a/src/XIProperties.c b/src/XIProperties.c
index 045cc71..0f77e58 100644
--- a/src/XIProperties.c
+++ b/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

commit 93d706757582805ef2cb7b868d27a13679bb9bdc
Author: Jamey Sharp <jamey@minilop.net>
Date:   Fri Apr 9 17:31:00 2010 -0700

    Don't unlock the Display twice.
    
    _xiQueryVersion's caller must wrap it in a LockDisplay/UnlockDisplay
    pair, so it shouldn't call UnlockDisplay itself.
    
    Signed-off-by: Jamey Sharp <jamey@minilop.net>
    (cherry picked from commit 54fbe5759aa961dccc618b35573845f847675570)
    (cherry picked from commit 9ab5ba3eabc58f5154b25f4f1de631c2fdaec3ce)

diff --git a/src/XIQueryVersion.c b/src/XIQueryVersion.c
index a14e9c9..1e4f9a4 100644
--- a/src/XIQueryVersion.c
+++ b/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;
         }
 

commit 0f6950fc53b2cffc560551a2625a980b1db695f8
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Wed Dec 9 13:59:57 2009 +1000

    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>
    (cherry picked from commit 299de21b2ab3cfa2078823215f84da67e7b3d1a3)
    (cherry picked from commit 87b6e5822532f63b63dc926cbf6788726b83812d)

diff --git a/src/XExtInt.c b/src/XExtInt.c
index e87ead8..80b3fc7 100644
--- a/src/XExtInt.c
+++ b/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/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);
 }
diff --git a/src/XIint.h b/src/XIint.h
index 400c920..00e84d3 100644
--- a/src/XIint.h
+++ b/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(

commit 8ce148ef9d28a16930666eceb1073a34aacc27cb
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Thu Feb 18 16:52:12 2010 +1000

    man: fix types for XGetSelectedExtensionEvents.
    
    The return values are of type XEventClass** and int*, respectively.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Dan Nicholson <dbn.lists@gmail.com>
    (cherry picked from commit d7e421f97db74332783ae885f6835f84133c92b5)
    (cherry picked from commit 7b3e496d17b85fd2ec245194376628263ce31cab)

diff --git a/man/XSelectExtensionEvent.txt b/man/XSelectExtensionEvent.txt
index a31ca40..cbcfffe 100644
--- a/man/XSelectExtensionEvent.txt
+++ b/man/XSelectExtensionEvent.txt
@@ -20,10 +20,10 @@ SYNOPSIS
 
    XGetSelectedExtensionEvents( Display *display,
                                 Window w,
-                                int this_client_event_count_return,
-                                XEventClass *this_client_event_list_return,
-                                int all_clients_event_count_return,
-                                XEventClass *all_clients_event_list_return);
+                                int *this_client_event_count_return,
+                                XEventClass **this_client_event_list_return,
+                                int *all_clients_event_count_return,
+                                XEventClass **all_clients_event_list_return);
 
    display
           Specifies the connection to the X server.


Reply to: