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

xorg-server: Changes to 'upstream-unstable'



Rebased ref, commits from common ancestor:
commit 9acb64f54ee9dd2fe41afda159b919280850ad8e
Author: Matt Dew <marcoz@osource.org>
Date:   Thu Sep 12 21:17:40 2013 -0600

    bump version from 1.14.2.902 to 1.14.3

diff --git a/configure.ac b/configure.ac
index 68484db..9bc7c73 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,9 +26,9 @@ dnl
 dnl Process this file with autoconf to create configure.
 
 AC_PREREQ(2.60)
-AC_INIT([xorg-server], 1.14.2.902, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
-RELEASE_DATE="2013-08-22"
-RELEASE_NAME="Act semi-normal-rc2"
+AC_INIT([xorg-server], 1.14.3, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
+RELEASE_DATE="2013-09-12"
+RELEASE_NAME="September Rain"
 AC_CONFIG_SRCDIR([Makefile.am])
 AM_INIT_AUTOMAKE([foreign dist-bzip2])
 

commit af1c57152e10cfa55843e6330cffc6a3c8c517d3
Author: Chris Clayton <chris2553@googlemail.com>
Date:   Wed Sep 4 15:42:04 2013 +1000

    kdrive: fix build error on gcc 4.8 for out-of-bounds array access
    
    I'm getting a error building xorg-server-1.14.1.902 with thelatest snapshot
    of gcc-4.8:
    
    input.c:225:43: error: array subscript is above array bounds
    [-Werror=array-bounds]
    
    This is because kdNumInputFds can become equal to KD_MAX_INPUT_FDS in
    KdRegisterFd(). This means that in KdUnregisterFd(), kdInputFds[j + 1] can
    be beyond the end of the array.
    
    Signed-off-by: Chris Clayton <chris2553@googlemail.com>
    Reviewed-by: Keith Packard <keithp@keithp.com>
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index b1068bb..09aae44 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -221,7 +221,7 @@ KdUnregisterFd(void *closure, int fd, Bool do_close)
             if (do_close)
                 close(kdInputFds[i].fd);
             kdNumInputFds--;
-            for (j = i; j < kdNumInputFds; j++)
+            for (j = i; j < (kdNumInputFds - 1); j++)
                 kdInputFds[j] = kdInputFds[j + 1];
             break;
         }

commit 0e37fefea5e91dfdcd18ffd941daa7d05cc3180d
Author: Matt Dew <marcoz@osource.org>
Date:   Thu Aug 22 17:43:51 2013 -0600

    bump rev number from 1.14.2.901 to 1.14.2.902

diff --git a/configure.ac b/configure.ac
index 271e49d..68484db 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,9 +26,9 @@ dnl
 dnl Process this file with autoconf to create configure.
 
 AC_PREREQ(2.60)
-AC_INIT([xorg-server], 1.14.2.901, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
-RELEASE_DATE="2013-07-25"
-RELEASE_NAME="Act semi-normal-rc1"
+AC_INIT([xorg-server], 1.14.2.902, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
+RELEASE_DATE="2013-08-22"
+RELEASE_NAME="Act semi-normal-rc2"
 AC_CONFIG_SRCDIR([Makefile.am])
 AM_INIT_AUTOMAKE([foreign dist-bzip2])
 

commit 917c11ff97eb302d3c2d0565c8dd6d93101d6466
Author: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Date:   Tue Jul 30 15:31:24 2013 +0200

    test/xi2: fix protocol-xiqueryversion test
    
    The old code was broken and allowed setting client version >= XIVersion,
    this was fixed in the previous patch, but updating the value for XIVersion
    broke the tests, so fix the tests too.
    
    Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
    Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    (cherry picked from commit b6e5c4669e0db391966deb397e8c975ec7f0124d)

diff --git a/test/xi2/protocol-xiqueryversion.c b/test/xi2/protocol-xiqueryversion.c
index aff0237..ed75c89 100644
--- a/test/xi2/protocol-xiqueryversion.c
+++ b/test/xi2/protocol-xiqueryversion.c
@@ -44,8 +44,8 @@
 #include "extinit.h"            /* for XInputExtensionInit */
 #include "scrnintstr.h"
 #include "xiqueryversion.h"
-
 #include "protocol-common.h"
+#include "exglobals.h"
 
 extern XExtensionVersion XIVersion;
 
@@ -54,8 +54,8 @@ struct test_data {
     int minor_client;
     int major_server;
     int minor_server;
-    int major_cached;
-    int minor_cached;
+    int major_expected;
+    int minor_expected;
 };
 
 static void
@@ -93,13 +93,8 @@ reply_XIQueryVersion_multiple(ClientPtr client, int len, char *data, void *closu
     reply_check_defaults(rep, len, XIQueryVersion);
     assert(rep->length == 0);
 
-    if (versions->major_cached == -1) {
-        versions->major_cached = rep->major_version;
-        versions->minor_cached = rep->minor_version;
-    }
-
-    assert(versions->major_cached == rep->major_version);
-    assert(versions->minor_cached == rep->minor_version);
+    assert(versions->major_expected == rep->major_version);
+    assert(versions->minor_expected == rep->minor_version);
 }
 
 /**
@@ -199,6 +194,7 @@ test_XIQueryVersion_multiple(void)
 {
     xXIQueryVersionReq request;
     ClientRec client;
+    XIClientPtr pXIClient;
     struct test_data versions;
     int rc;
 
@@ -213,28 +209,26 @@ test_XIQueryVersion_multiple(void)
     userdata = (void *) &versions;
 
     /* run 1 */
-    versions.major_cached = -1;
-    versions.minor_cached = -1;
 
-    /* client is lower than server, noncached */
-    request.major_version = 2;
-    request.minor_version = 1;
+    /* client is lower than server, nonexpected */
+    versions.major_expected = request.major_version = 2;
+    versions.minor_expected = request.minor_version = 1;
     rc = ProcXIQueryVersion(&client);
     assert(rc == Success);
 
-    /* client is higher than server, cached */
+    /* client is higher than server, no change */
     request.major_version = 2;
     request.minor_version = 3;
     rc = ProcXIQueryVersion(&client);
     assert(rc == Success);
 
-    /* client is equal, cached */
+    /* client tries to set higher version, stays same */
     request.major_version = 2;
     request.minor_version = 2;
     rc = ProcXIQueryVersion(&client);
     assert(rc == Success);
 
-    /* client is low than cached */
+    /* client tries to set lower version, no change */
     request.major_version = 2;
     request.minor_version = 0;
     rc = ProcXIQueryVersion(&client);
@@ -243,20 +237,24 @@ test_XIQueryVersion_multiple(void)
     /* run 2 */
     client = init_client(request.length, &request);
     XIVersion.major_version = 2;
-    XIVersion.minor_version = 2;
-    versions.major_cached = -1;
-    versions.minor_cached = -1;
+    XIVersion.minor_version = 3;
 
-    request.major_version = 2;
-    request.minor_version = 2;
+    versions.major_expected = request.major_version = 2;
+    versions.minor_expected = request.minor_version = 2;
     rc = ProcXIQueryVersion(&client);
     assert(rc == Success);
 
+    /* client bumps version from 2.2 to 2.3 */
     request.major_version = 2;
-    request.minor_version = 3;
+    versions.minor_expected = request.minor_version = 3;
     rc = ProcXIQueryVersion(&client);
     assert(rc == Success);
 
+    /* real version is changed, too! */
+    pXIClient = dixLookupPrivate(&client.devPrivates, XIClientPrivateKey);
+    assert(pXIClient->minor_version == 3);
+
+    /* client tries to set lower version, no change */
     request.major_version = 2;
     request.minor_version = 1;
     rc = ProcXIQueryVersion(&client);
@@ -265,20 +263,22 @@ test_XIQueryVersion_multiple(void)
     /* run 3 */
     client = init_client(request.length, &request);
     XIVersion.major_version = 2;
-    XIVersion.minor_version = 2;
-    versions.major_cached = -1;
-    versions.minor_cached = -1;
+    XIVersion.minor_version = 3;
 
-    request.major_version = 2;
-    request.minor_version = 3;
+    versions.major_expected = request.major_version = 2;
+    versions.minor_expected = request.minor_version = 3;
     rc = ProcXIQueryVersion(&client);
     assert(rc == Success);
 
     request.major_version = 2;
-    request.minor_version = 2;
+    versions.minor_expected = request.minor_version = 2;
     rc = ProcXIQueryVersion(&client);
     assert(rc == Success);
 
+    /* but real client version must not be lowered */
+    pXIClient = dixLookupPrivate(&client.devPrivates, XIClientPrivateKey);
+    assert(pXIClient->minor_version == 3);
+
     request.major_version = 2;
     request.minor_version = 1;
     rc = ProcXIQueryVersion(&client);

commit 804836c53083fdb9f43be6f51740df5d12d57cb4
Author: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Date:   Tue Jul 30 14:45:21 2013 +0200

    Xi: Clamp XIClient maximal version to XIVersion
    
    Do not allow setting client version to an arbitrary value >= XIVersion.
    Fixes a test error with test/xi2/protocol-xiqueryversion.c, introduced by
    commit 4360514d1c "Xi: Allow clients to ask for 2.3 and then 2.2 without failing"
    
    Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
    Reviewed-by: Keith Packard <keithp@keithp.com>
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    (cherry picked from commit 500e844a24962c9e70abb3d614f1973013b2de73)

diff --git a/Xi/xiqueryversion.c b/Xi/xiqueryversion.c
index 6c7b9c0..c705f78 100644
--- a/Xi/xiqueryversion.c
+++ b/Xi/xiqueryversion.c
@@ -70,12 +70,21 @@ ProcXIQueryVersion(ClientPtr client)
 
     pXIClient = dixLookupPrivate(&client->devPrivates, XIClientPrivateKey);
 
+    if (version_compare(XIVersion.major_version, XIVersion.minor_version,
+                stuff->major_version, stuff->minor_version) > 0) {
+        major = stuff->major_version;
+        minor = stuff->minor_version;
+    } else {
+        major = XIVersion.major_version;
+        minor = XIVersion.minor_version;
+    }
+
     if (pXIClient->major_version) {
 
         /* Check to see if the client has only ever asked
          * for version 2.2 or higher
          */
-        if (version_compare(stuff->major_version, stuff->minor_version, 2, 2) >= 0 &&
+        if (version_compare(major, minor, 2, 2) >= 0 &&
             version_compare(pXIClient->major_version, pXIClient->minor_version, 2, 2) >= 0)
         {
 
@@ -84,16 +93,14 @@ ProcXIQueryVersion(ClientPtr client)
              * version to the client but leave the server internal
              * version set to the highest requested value
              */
-            major = stuff->major_version;
-            minor = stuff->minor_version;
-            if (version_compare(stuff->major_version, stuff->minor_version,
+            if (version_compare(major, minor,
                                 pXIClient->major_version, pXIClient->minor_version) > 0)
             {
-                pXIClient->major_version = stuff->major_version;
-                pXIClient->minor_version = stuff->minor_version;
+                pXIClient->major_version = major;
+                pXIClient->minor_version = minor;
             }
         } else {
-            if (version_compare(stuff->major_version, stuff->minor_version,
+            if (version_compare(major, minor,
                                 pXIClient->major_version, pXIClient->minor_version) < 0) {
 
                 client->errorValue = stuff->major_version;
@@ -103,16 +110,6 @@ ProcXIQueryVersion(ClientPtr client)
             minor = pXIClient->minor_version;
         }
     } else {
-        if (version_compare(XIVersion.major_version, XIVersion.minor_version,
-                    stuff->major_version, stuff->minor_version) > 0) {
-            major = stuff->major_version;
-            minor = stuff->minor_version;
-        }
-        else {
-            major = XIVersion.major_version;
-            minor = XIVersion.minor_version;
-        }
-
         pXIClient->major_version = major;
         pXIClient->minor_version = minor;
     }

commit 7250c310b50c96709f2082e7752fc889557abc26
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Tue Aug 13 10:50:25 2013 +1000

    Revert "test: fix XIQueryVersion check for new behaviour"
    
    This reverts commit cdcb708678c4785cd7b026b90e316691176e5244.

diff --git a/test/xi2/protocol-xiqueryversion.c b/test/xi2/protocol-xiqueryversion.c
index 2289c8d..aff0237 100644
--- a/test/xi2/protocol-xiqueryversion.c
+++ b/test/xi2/protocol-xiqueryversion.c
@@ -96,16 +96,10 @@ reply_XIQueryVersion_multiple(ClientPtr client, int len, char *data, void *closu
     if (versions->major_cached == -1) {
         versions->major_cached = rep->major_version;
         versions->minor_cached = rep->minor_version;
-    } else if (versions->major_cached >= 2 &&
-               versions->minor_cached >= 2) {
-        /* First request was for 2.2 or higher, reply
-           must be 2.2 or higher, whichever requested */
-        assert(rep->major_version >= 2);
-        assert(rep->minor_version >= 2);
-    } else {
-        assert(versions->major_cached == rep->major_version);
-        assert(versions->minor_cached == rep->minor_version);
     }
+
+    assert(versions->major_cached == rep->major_version);
+    assert(versions->minor_cached == rep->minor_version);
 }
 
 /**

commit cdcb708678c4785cd7b026b90e316691176e5244
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Tue Jul 30 08:03:12 2013 +1000

    test: fix XIQueryVersion check for new behaviour
    
    As of 4360514d1cc8e3132f93f56172d291074e8c770f, XIQueryVersion supports
    requesting versions 2.2+ in random order, only 2.0 and 2.1 are restricted.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    (cherry picked from commit a5abf790183798ad8aa2c29c056df3647777cfbd)

diff --git a/test/xi2/protocol-xiqueryversion.c b/test/xi2/protocol-xiqueryversion.c
index aff0237..2289c8d 100644
--- a/test/xi2/protocol-xiqueryversion.c
+++ b/test/xi2/protocol-xiqueryversion.c
@@ -96,10 +96,16 @@ reply_XIQueryVersion_multiple(ClientPtr client, int len, char *data, void *closu
     if (versions->major_cached == -1) {
         versions->major_cached = rep->major_version;
         versions->minor_cached = rep->minor_version;
+    } else if (versions->major_cached >= 2 &&
+               versions->minor_cached >= 2) {
+        /* First request was for 2.2 or higher, reply
+           must be 2.2 or higher, whichever requested */
+        assert(rep->major_version >= 2);
+        assert(rep->minor_version >= 2);
+    } else {
+        assert(versions->major_cached == rep->major_version);
+        assert(versions->minor_cached == rep->minor_version);
     }
-
-    assert(versions->major_cached == rep->major_version);
-    assert(versions->minor_cached == rep->minor_version);
 }
 
 /**

commit e6da18f67516dcee394cd0eff591a255b59fe544
Author: Keith Packard <keithp@keithp.com>
Date:   Wed Jul 10 22:42:55 2013 -0700

    Xi: Allow clients to ask for 2.3 and then 2.2 without failing
    
    This allows different sub-systems within the same application to
    request different Xi versions without either getting old behaviour
    everywhere or simply failing with a BadValue.
    
    Signed-off-by: Keith Packard <keithp@keithp.com>
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    (cherry picked from commit 4360514d1cc8e3132f93f56172d291074e8c770f)

diff --git a/Xi/xiqueryversion.c b/Xi/xiqueryversion.c
index b807a53..6c7b9c0 100644
--- a/Xi/xiqueryversion.c
+++ b/Xi/xiqueryversion.c
@@ -71,13 +71,37 @@ ProcXIQueryVersion(ClientPtr client)
     pXIClient = dixLookupPrivate(&client->devPrivates, XIClientPrivateKey);
 
     if (pXIClient->major_version) {
-        if (version_compare(stuff->major_version, stuff->minor_version,
-                            pXIClient->major_version, pXIClient->minor_version) < 0) {
-            client->errorValue = stuff->major_version;
-            return BadValue;
+
+        /* Check to see if the client has only ever asked
+         * for version 2.2 or higher
+         */
+        if (version_compare(stuff->major_version, stuff->minor_version, 2, 2) >= 0 &&
+            version_compare(pXIClient->major_version, pXIClient->minor_version, 2, 2) >= 0)
+        {
+
+            /* As of version 2.2, Peter promises to never again break
+             * backward compatibility, so we'll return the requested
+             * version to the client but leave the server internal
+             * version set to the highest requested value
+             */
+            major = stuff->major_version;
+            minor = stuff->minor_version;
+            if (version_compare(stuff->major_version, stuff->minor_version,
+                                pXIClient->major_version, pXIClient->minor_version) > 0)
+            {
+                pXIClient->major_version = stuff->major_version;
+                pXIClient->minor_version = stuff->minor_version;
+            }
+        } else {
+            if (version_compare(stuff->major_version, stuff->minor_version,
+                                pXIClient->major_version, pXIClient->minor_version) < 0) {
+
+                client->errorValue = stuff->major_version;
+                return BadValue;
+            }
+            major = pXIClient->major_version;
+            minor = pXIClient->minor_version;
         }
-        major = pXIClient->major_version;
-        minor = pXIClient->minor_version;
     } else {
         if (version_compare(XIVersion.major_version, XIVersion.minor_version,
                     stuff->major_version, stuff->minor_version) > 0) {

commit 0857f3c72d0d1bf5eac52f084e9a1adf077e7397
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Mon Jul 22 13:43:07 2013 +1000

    dix: set the valuator mask to ensure XI 1.x events have data
    
    XI 1.x only allows for first + num valuators, so if a device sends data for
    valuators 0 and 2+ only (i.e. valuator 1 is missing) we still need to get
    the data for that from somewhere.
    XI 1.x uses the hack of an unset valuator mask to get the right coordinates,
    i.e. we set the value but don't set the mask for it so XI2 events have the
    right mask.
    
    For an absolute device in relative mode, this broke in b28a1af55cf, the
    value was now always 0. This wasn't visible on the cursor, only in an XI 1.x
    client. The GIMP e.g. sees jumps to x/0 every few events.
    
    Drop the condition introduced in b28a1af55cf, data in valuators is always
    absolute, regardless of the mode.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    (cherry picked from commit 3d8756631070c440cefa31b35fea3d407f187810)

diff --git a/dix/getevents.c b/dix/getevents.c
index dfe4652..dd1b253 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -239,7 +239,7 @@ set_valuators(DeviceIntPtr dev, DeviceEvent *event, ValuatorMask *mask)
                 SetBit(event->valuators.mode, i);
             event->valuators.data[i] = valuator_mask_get_double(mask, i);
         }
-        else if (valuator_get_mode(dev, i) == Absolute)
+        else
             event->valuators.data[i] = dev->valuator->axisVal[i];
     }
 }

commit ef54bd89b17f3dd1f854435339f66d357121c64c
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Wed Jul 24 11:50:00 2013 +1000

    dix: check the xi2mask, not the grab type for touch listeners
    
    grab->type is only non-zero for passive grabs. We're checking an active grab
    here, so we need to check if the touch mask is set on the grab.
    
    Test case: grab the device, then start two simultaneous touches. The
    grabbing client won't see the second touchpoints because grab->type is 0
    and the second touch is not an emulating pointer.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    (cherry picked from commit 4fb686d6a6777950f0e0d55b848cd2af4cbad372)

diff --git a/dix/touch.c b/dix/touch.c
index a4b6d7e..a7ea213 100644
--- a/dix/touch.c
+++ b/dix/touch.c
@@ -895,8 +895,7 @@ TouchAddActiveGrabListener(DeviceIntPtr dev, TouchPointInfoPtr ti,
 
     if (!ti->emulate_pointer &&
         grab->grabtype == XI2 &&
-        (grab->type != XI_TouchBegin && grab->type != XI_TouchEnd &&
-         grab->type != XI_TouchUpdate))
+        !xi2mask_isset(grab->xi2mask, dev, XI_TouchBegin))
         return;
 
     TouchAddGrabListener(dev, ti, ev, grab);
diff --git a/include/inputstr.h b/include/inputstr.h
index 85be885..2da72c1 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -195,7 +195,7 @@ typedef struct _GrabRec {
     unsigned keyboardMode:1;
     unsigned pointerMode:1;
     enum InputLevel grabtype;
-    CARD8 type;                 /* event type */
+    CARD8 type;                 /* event type for passive grabs, 0 for active grabs */
     DetailRec modifiersDetail;
     DeviceIntPtr modifierDevice;
     DetailRec detail;           /* key or button */

commit 4ebd618bc5ef71507e708e7191091828eca3a7e8
Author: Matt Dew <marcoz@osource.org>
Date:   Thu Jul 25 22:24:00 2013 -0600

    Bah, bad rev number. Fixed:  changed 1.14.3-rc1 to 1.14.2.901

diff --git a/configure.ac b/configure.ac
index 8738813..271e49d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,7 +26,7 @@ dnl
 dnl Process this file with autoconf to create configure.
 
 AC_PREREQ(2.60)
-AC_INIT([xorg-server], 1.14.3-rc1, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
+AC_INIT([xorg-server], 1.14.2.901, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
 RELEASE_DATE="2013-07-25"
 RELEASE_NAME="Act semi-normal-rc1"
 AC_CONFIG_SRCDIR([Makefile.am])

commit fef66ffe7a7e899a9126a1e431b94d881163b00d
Author: Matt Dew <marcoz@osource.org>
Date:   Thu Jul 25 22:02:26 2013 -0600

    bump rev from 1.14.2 to 1.14.3-rc1

diff --git a/configure.ac b/configure.ac
index 99e3cd6..8738813 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,9 +26,9 @@ dnl
 dnl Process this file with autoconf to create configure.
 
 AC_PREREQ(2.60)
-AC_INIT([xorg-server], 1.14.2, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
-RELEASE_DATE="2013-06-25"
-RELEASE_NAME="Act Abnormal"
+AC_INIT([xorg-server], 1.14.3-rc1, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
+RELEASE_DATE="2013-07-25"
+RELEASE_NAME="Act semi-normal-rc1"
 AC_CONFIG_SRCDIR([Makefile.am])
 AM_INIT_AUTOMAKE([foreign dist-bzip2])
 

commit 2cd62dc02b67c70d2417b2ccd307ead9596a2967
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Fri Mar 1 08:43:58 2013 +1000

    Xi: return !Success from DeliverTouchEmulatedEvent if we didn't deliver
    
    All callers currently ignore the new value, so this patch has no effect.
    Inverse call graph:
    
    DeliverTouchEmulatedEvent
            DeliverEmulatedMotionEvent              Ignores value
            DeliverTouchBeginEvent
                    DeliverTouchEvent
                            DeliverTouchEvents      Ignores value
            DeliverTouchEndEvent
                    DeliverTouchEvent
                            DeliverTouchEvents      Ignores value
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Keith Packard <keithp@keithp.com>
    (cherry picked from commit 9978b57b8d94f061d72a67b99a02b0ba16a11429)

diff --git a/Xi/exevents.c b/Xi/exevents.c
index 91281ae..067e6b3 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -1373,7 +1373,7 @@ DeliverTouchEmulatedEvent(DeviceIntPtr dev, TouchPointInfoPtr ti,
 
     /* We don't deliver pointer events to non-owners */
     if (!TouchResourceIsOwner(ti, listener->listener))
-        return Success;
+        return !Success;
 
     nevents = TouchConvertToPointerEvent(ev, &motion, &button);
     BUG_RETURN_VAL(nevents == 0, BadValue);
@@ -1395,7 +1395,7 @@ DeliverTouchEmulatedEvent(DeviceIntPtr dev, TouchPointInfoPtr ti,
             /* 'grab' is the passive grab, but if the grab isn't active,
              * don't deliver */
             if (!dev->deviceGrab.grab)
-                return Success;
+                return !Success;
 
             if (grab->ownerEvents) {
                 WindowPtr focus = NullWindow;

commit c203568905bcbb65fb1e079b626d2c1e90ecb72d
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Mon May 13 15:22:12 2013 +1000

    Xi: fix warning - remove unused 'rc'
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    (cherry picked from commit fd5ea0237db6d725a48f76b706135df9d3246b82)

diff --git a/Xi/exevents.c b/Xi/exevents.c
index 30e48f0..91281ae 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -1036,7 +1036,6 @@ DeliverOneTouchEvent(ClientPtr client, DeviceIntPtr dev, TouchPointInfoPtr ti,
 static void
 ActivateEarlyAccept(DeviceIntPtr dev, TouchPointInfoPtr ti)
 {
-    int rc;
     ClientPtr client;
     XID error;
     GrabPtr grab = ti->listeners[0].grab;

commit 93f063c40dc4b339ae9114551071c57b52d98dba
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Fri Jul 12 14:10:10 2013 +1000

    dix: UpdateTouchesForGrab must only free the listener grab if it is non-NULL
    
    If a client calls XIGrabDevice in response to a ButtonPress event (regular
    event selection), the device will have a grab, but listener->grab is NULL.
    
    Check for that, to avoid logspam.
    
    [ 26293.863] (EE) BUG: triggered 'if (!pGrab)'
    [ 26293.863] (EE) BUG: grabs.c:256 in FreeGrab()
    [ 26293.863] (EE)
    [ 26293.863] (EE) Backtrace:
    [ 26293.864] (EE) 0: /usr/bin/Xorg (FreeGrab+0x54) [0x45d3fc]
    [ 26293.864] (EE) 1: /usr/bin/Xorg (UpdateTouchesForGrab+0x135) [0x447d4e]
    [ 26293.864] (EE) 2: /usr/bin/Xorg (ActivatePointerGrab+0x1ba) [0x447f3d]
    [ 26293.864] (EE) 3: /usr/bin/Xorg (GrabDevice+0x3e6) [0x4503bc]
    [ 26293.864] (EE) 4: /usr/bin/Xorg (ProcXIGrabDevice+0x1f9) [0x5981b1]
    [ 26293.865] (EE) 5: /usr/bin/Xorg (ProcIDispatch+0x78) [0x58aa17]
    [ 26293.865] (EE) 6: /usr/bin/Xorg (Dispatch+0x30d) [0x43347e]
    [ 26293.865] (EE) 7: /usr/bin/Xorg (main+0x61d) [0x498175]
    [ 26293.865] (EE) 8: /lib64/libc.so.6 (__libc_start_main+0xf5) [0x3df5621b75]
    [ 26293.865] (EE) 9: /usr/bin/Xorg (_start+0x29) [0x423a19]
    [ 26293.866] (EE) 10: ? (?+0x29) [0x29]
    [ 26293.866] (EE)
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Keith Packard <keithp@keithp.com>
    (cherry picked from commit 0e3be0b25fcfeff386bad132526352c2e45f1932)

diff --git a/dix/events.c b/dix/events.c
index f9b2ed7..c079f97 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -1438,7 +1438,8 @@ UpdateTouchesForGrab(DeviceIntPtr mouse)
                 listener->type = LISTENER_POINTER_GRAB;
             else
                 listener->type = LISTENER_GRAB;
-            FreeGrab(listener->grab);
+            if (listener->grab)
+                FreeGrab(listener->grab);
             listener->grab = AllocGrab(grab);
         }
     }

commit ecd178e632a99ae2f12d2d9b6e9a48eaa421335d
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Tue Jul 9 13:27:19 2013 +1000

    dix: when ungrabbing an active grab, accept pointer grabs (#66720)
    
    Ungrabbing a device during an active touch grab rejects the grab. Ungrabbing
    a device during an active pointer grab accepts the grab.
    
    Rejection is not really an option for a pointer-emulated grab, if a client
    has a button mask on the window it would get a ButtonPress emulated after
    UngrabDevice. That is against the core grab behaviour.
    
    X.Org Bug 66720 <http://bugs.freedesktop.org/show_bug.cgi?id=66720>
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Jasper St. Pierre <jstpierre@mecheye.net>
    (cherry picked from commit 8eeaa74bc241acb41f1d3ed64971e0b01e794776)

diff --git a/Xi/exevents.c b/Xi/exevents.c
index e1945b9..30e48f0 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -1224,9 +1224,13 @@ ProcessTouchOwnershipEvent(TouchOwnershipEvent *ev,
     else if (ev->reason == XIAcceptTouch) {
         int i;
 
-        /* Go through the motions of ending the touch if the listener has
+
+        /* For pointer-emulated listeners that ungrabbed the active grab,
+         * the state was forced to LISTENER_HAS_END. Still go
+         * through the motions of ending the touch if the listener has
          * already seen the end. This ensures that the touch record is ended in
-         * the server. */
+         * the server.
+         */
         if (ti->listeners[0].state == LISTENER_HAS_END)
             TouchEmitTouchEnd(dev, ti, TOUCH_ACCEPT, ti->listeners[0].listener);
 
@@ -1884,16 +1888,23 @@ DeliverTouchEndEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, InternalEvent *ev,
 
     if (listener->type == LISTENER_POINTER_REGULAR ||
         listener->type == LISTENER_POINTER_GRAB) {
-        rc = DeliverTouchEmulatedEvent(dev, ti, ev, listener, client, win,
-                                       grab, xi2mask);
-
-         /* Once we send a TouchEnd to a legacy listener, we're already well
-          * past the accepting/rejecting stage (can only happen on
-          * GrabModeSync + replay. This listener now gets the end event,
-          * and we can continue.
-          */
-        if (rc == Success)
-            listener->state = LISTENER_HAS_END;
+        /* Note: If the active grab was ungrabbed, we already changed the
+         * state to LISTENER_HAS_END but still get here. So we mustn't
+         * actually send the event.
+         * This is part two of the hack in DeactivatePointerGrab
+         */
+        if (listener->state != LISTENER_HAS_END) {
+            rc = DeliverTouchEmulatedEvent(dev, ti, ev, listener, client, win,
+                                           grab, xi2mask);
+
+             /* Once we send a TouchEnd to a legacy listener, we're already well
+              * past the accepting/rejecting stage (can only happen on
+              * GrabModeSync + replay. This listener now gets the end event,
+              * and we can continue.
+              */
+            if (rc == Success)
+                listener->state = LISTENER_HAS_END;
+        }
         goto out;
     }
 
diff --git a/dix/events.c b/dix/events.c
index 4d50a24..f9b2ed7 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -1519,13 +1519,20 @@ DeactivatePointerGrab(DeviceIntPtr mouse)
     for (i = 0; !wasPassive && mouse->touch && i < mouse->touch->num_touches; i++) {
         TouchPointInfoPtr ti = mouse->touch->touches + i;
         if (ti->active && TouchResourceIsOwner(ti, grab_resource)) {
+            int mode = XIRejectTouch;
             /* Rejecting will generate a TouchEnd, but we must not
                emulate a ButtonRelease here. So pretend the listener
                already has the end event */
             if (grab->grabtype == CORE || grab->grabtype == XI ||
-                    !xi2mask_isset(mouse->deviceGrab.grab->xi2mask, mouse, XI_TouchBegin))
+                    !xi2mask_isset(mouse->deviceGrab.grab->xi2mask, mouse, XI_TouchBegin)) {
+                mode = XIAcceptTouch;
+                /* NOTE: we set the state here, but
+                 * ProcessTouchOwnershipEvent() will still call
+                 * TouchEmitTouchEnd for this listener. The other half of
+                 * this hack is in DeliverTouchEndEvent */
                 ti->listeners[0].state = LISTENER_HAS_END;
-            TouchListenerAcceptReject(mouse, ti, 0, XIRejectTouch);
+            }
+            TouchListenerAcceptReject(mouse, ti, 0, mode);
         }
     }
 

commit 54a7ae04a8475df6ce87e52ff995de22fafc7c92
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Mon May 27 13:46:49 2013 +1000

    dix: remove logspam in RefCursor()
    
    This shouldn't have been in the patch
    
    Reported-by: Colin Harrison <colin.harrison@virgin.net>
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Keith Packard <keithp@keithp.com>
    Signed-off-by: Keith Packard <keithp@keithp.com>
    (cherry picked from commit c21344add2fc589df83b29be5831c36a372201bd)

diff --git a/dix/cursor.c b/dix/cursor.c
index 0820b18..cd8305c 100644
--- a/dix/cursor.c
+++ b/dix/cursor.c
@@ -134,12 +134,8 @@ FreeCursor(pointer value, XID cid)
 CursorPtr
 RefCursor(CursorPtr cursor)
 {
-    ErrorF("%s ::::: cursor is %p", __func__, cursor);
-    if (cursor) {
-        xorg_backtrace();
+    if (cursor)
         cursor->refcnt++;
-    }
-    ErrorF("\n");
     return cursor;
 }
 

commit 1e29b269fd712ae1e3552eeddd3529015baee7ae
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Wed May 15 19:01:11 2013 +1000

    Abstract cursor refcounting
    
    Too many callers relied on the refcnt being handled correctly. Use a simple
    wrapper to handle that case.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    (cherry picked from commit 9a5ad65330693b3273972b63d10f2907d9ab954a)

diff --git a/Xext/saver.c b/Xext/saver.c
index 8de043f..fe81bc4 100644
--- a/Xext/saver.c
+++ b/Xext/saver.c
@@ -531,15 +531,16 @@ CreateSaverWindow(ScreenPtr pScreen)
         mask |= CWBorderPixmap;
     }
     if (pAttr->pCursor) {
+        CursorPtr cursor;
         if (!pWin->optional)
             if (!MakeWindowOptional(pWin)) {
                 FreeResource(pWin->drawable.id, RT_NONE);
                 return FALSE;
             }
-        pAttr->pCursor->refcnt++;
+        cursor = RefCursor(pAttr->pCursor);
         if (pWin->optional->cursor)
             FreeCursor(pWin->optional->cursor, (Cursor) 0);
-        pWin->optional->cursor = pAttr->pCursor;
+        pWin->optional->cursor = cursor;
         pWin->cursorIsNone = FALSE;
         CheckWindowOptionalNeed(pWin);
         mask |= CWCursor;
@@ -1065,8 +1066,7 @@ ScreenSaverSetAttributes(ClientPtr client)
                     client->errorValue = cursorID;
                     goto PatchUp;
                 }
-                pCursor->refcnt++;
-                pAttr->pCursor = pCursor;
+                pAttr->pCursor = RefCursor(pCursor);
                 pAttr->mask &= ~CWCursor;
             }
             break;
diff --git a/dix/cursor.c b/dix/cursor.c
index 1ee127a..0820b18 100644
--- a/dix/cursor.c
+++ b/dix/cursor.c
@@ -114,9 +114,13 @@ FreeCursor(pointer value, XID cid)
     ScreenPtr pscr;
     DeviceIntPtr pDev = NULL;   /* unused anyway */
 
-    if (--pCurs->refcnt != 0)
+
+    UnrefCursor(pCurs);
+    if (CursorRefCount(pCurs) != 0)
         return Success;
 
+    BUG_WARN(CursorRefCount(pCurs) < 0);
+
     for (nscr = 0; nscr < screenInfo.numScreens; nscr++) {
         pscr = screenInfo.screens[nscr];
         (void) (*pscr->UnrealizeCursor) (pDev, pscr, pCurs);
@@ -127,6 +131,33 @@ FreeCursor(pointer value, XID cid)
     return Success;
 }
 
+CursorPtr
+RefCursor(CursorPtr cursor)
+{
+    ErrorF("%s ::::: cursor is %p", __func__, cursor);
+    if (cursor) {
+        xorg_backtrace();
+        cursor->refcnt++;
+    }
+    ErrorF("\n");
+    return cursor;
+}
+
+CursorPtr
+UnrefCursor(CursorPtr cursor)
+{
+    if (cursor)
+        cursor->refcnt--;
+    return cursor;
+}
+
+int
+CursorRefCount(const CursorPtr cursor)
+{
+    return cursor ? cursor->refcnt : 0;
+}
+
+
 /*
  * We check for empty cursors so that we won't have to display them
  */
diff --git a/dix/events.c b/dix/events.c
index 64a8f15..4d50a24 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -931,8 +931,7 @@ ChangeToCursor(DeviceIntPtr pDev, CursorPtr cursor)
 
         (*pScreen->DisplayCursor) (pDev, pScreen, cursor);
         FreeCursor(pSprite->current, (Cursor) 0);
-        pSprite->current = cursor;
-        pSprite->current->refcnt++;
+        pSprite->current = RefCursor(cursor);
     }
 }
 
@@ -3207,11 +3206,10 @@ InitializeSprite(DeviceIntPtr pDev, WindowPtr pWin)
         pSprite->pEnqueueScreen = screenInfo.screens[0];
         pSprite->pDequeueScreen = pSprite->pEnqueueScreen;
     }
-    if (pCursor)
-        pCursor->refcnt++;
+    pCursor = RefCursor(pCursor);
     if (pSprite->current)
         FreeCursor(pSprite->current, None);
-    pSprite->current = pCursor;
+    pSprite->current = RefCursor(pCursor);
 
     if (pScreen) {
         (*pScreen->RealizeCursor) (pDev, pScreen, pSprite->current);
@@ -3290,9 +3288,7 @@ UpdateSpriteForScreen(DeviceIntPtr pDev, ScreenPtr pScreen)
     pSprite->hotLimits.x2 = pScreen->width;
     pSprite->hotLimits.y2 = pScreen->height;
     pSprite->win = win;
-    pCursor = wCursor(win);
-    if (pCursor)
-        pCursor->refcnt++;
+    pCursor = RefCursor(wCursor(win));
     if (pSprite->current)
         FreeCursor(pSprite->current, 0);
     pSprite->current = pCursor;
@@ -4942,9 +4938,7 @@ ProcChangeActivePointerGrab(ClientPtr client)
         (CompareTimeStamps(time, device->deviceGrab.grabTime) == EARLIER))
         return Success;
     oldCursor = grab->cursor;
-    grab->cursor = newCursor;
-    if (newCursor)
-        newCursor->refcnt++;
+    grab->cursor = RefCursor(newCursor);
     PostNewCursor(device);
     if (oldCursor)
         FreeCursor(oldCursor, (Cursor) 0);
@@ -5089,9 +5083,7 @@ GrabDevice(ClientPtr client, DeviceIntPtr dev,
         else
             xi2mask_merge(tempGrab->xi2mask, mask->xi2mask);
         tempGrab->device = dev;
-        tempGrab->cursor = cursor;
-        if (cursor)
-            tempGrab->cursor->refcnt++;
+        tempGrab->cursor = RefCursor(cursor);
         tempGrab->confineTo = confineTo;
         tempGrab->grabtype = grabtype;
         (*grabInfo->ActivateGrab) (dev, tempGrab, time, FALSE);
diff --git a/dix/grabs.c b/dix/grabs.c
index b254ddc..a03897a 100644
--- a/dix/grabs.c
+++ b/dix/grabs.c
@@ -241,13 +241,11 @@ CreateGrab(int client, DeviceIntPtr device, DeviceIntPtr modDevice,
     grab->detail.exact = keybut;
     grab->detail.pMask = NULL;
     grab->confineTo = confineTo;
-    grab->cursor = cursor;
+    grab->cursor = RefCursor(cursor);
     grab->next = NULL;


Reply to: