xserver: Branch 'master' - 5 commits

Keith Packard keithp at kemper.freedesktop.org
Tue Nov 24 19:21:29 PST 2009


 Xext/geext.c       |    9 ++-----
 Xi/xiproperty.c    |    2 +
 configure.ac       |    8 +++---
 dix/devices.c      |    2 +
 dix/ptrveloc.c     |   64 +++++++++++++++++++++++++++++++++++++++++++----------
 include/ptrveloc.h |    3 ++
 test/input.c       |   54 ++++++++++++++++++++++++++++++++++++++++++++
 7 files changed, 120 insertions(+), 22 deletions(-)

New commits:
commit 0e6cee853d8e5bef3274e632ef034d37f14674a9
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed Nov 18 14:39:25 2009 +1000

    dix: clean up accel old scheme data when switching schemes.
    
    InitValuatorClassDeviceStruct always initializes with the default profile.
    The default profile allocs data and adds a few properties which become
    obsolete if the profile is changed lateron by the driver.
    
    The property handlers are stored in the device's devPrivates and cleaned up.
    Ideally, the property handler ID's could be stored somewhere more obvious,
    but that seems to require breaking the ABI.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Acked-by: Simon Thum <simon.thum at gmx.de>

diff --git a/dix/devices.c b/dix/devices.c
index 395e19a..3634eec 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -1235,6 +1235,8 @@ InitPointerAccelerationScheme(DeviceIntPtr dev,
     if(-1 == i)
         return FALSE;
 
+    if (val->accelScheme.AccelCleanupProc)
+        val->accelScheme.AccelCleanupProc(dev);
 
     /* init scheme-specific data */
     switch(scheme){
diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c
index 37c8e51..6fb9e21 100644
--- a/dix/ptrveloc.c
+++ b/dix/ptrveloc.c
@@ -83,6 +83,9 @@ GetAccelerationProfile(DeviceVelocityPtr vel, int profile_num);
 /* some int which is not a profile number */
 #define PROFILE_UNINITIALIZE (-100)
 
+/* number of properties for predictable acceleration */
+#define NPROPS_PREDICTABLE_ACCEL 4
+
 /**
  * Init struct so it should match the average case
  */
@@ -128,6 +131,7 @@ AccelerationDefaultCleanup(DeviceIntPtr dev)
         FreeVelocityData(dev->valuator->accelScheme.accelData);
         xfree(dev->valuator->accelScheme.accelData);
         dev->valuator->accelScheme.accelData = NULL;
+        DeletePredictableAccelerationProperties(dev);
     }
 }
 
@@ -169,7 +173,7 @@ AccelSetProfileProperty(DeviceIntPtr dev, Atom atom,
     return Success;
 }
 
-static void
+static long
 AccelInitProfileProperty(DeviceIntPtr dev, DeviceVelocityPtr vel)
 {
     int profile = vel->statistics.profile_number;
@@ -178,7 +182,7 @@ AccelInitProfileProperty(DeviceIntPtr dev, DeviceVelocityPtr vel)
     XIChangeDeviceProperty(dev, prop_profile_number, XA_INTEGER, 32,
                            PropModeReplace, 1, &profile, FALSE);
     XISetDevicePropertyDeletable(dev, prop_profile_number, FALSE);
-    XIRegisterPropertyHandler(dev, AccelSetProfileProperty, NULL, NULL);
+    return XIRegisterPropertyHandler(dev, AccelSetProfileProperty, NULL, NULL);
 }
 
 /**
@@ -214,7 +218,7 @@ AccelSetDecelProperty(DeviceIntPtr dev, Atom atom,
     return Success;
 }
 
-static void
+static long
 AccelInitDecelProperty(DeviceIntPtr dev, DeviceVelocityPtr vel)
 {
     float fval = 1.0/vel->const_acceleration;
@@ -223,7 +227,7 @@ AccelInitDecelProperty(DeviceIntPtr dev, DeviceVelocityPtr vel)
                            XIGetKnownProperty(XATOM_FLOAT), 32,
                            PropModeReplace, 1, &fval, FALSE);
     XISetDevicePropertyDeletable(dev, prop_const_decel, FALSE);
-    XIRegisterPropertyHandler(dev, AccelSetDecelProperty, NULL, NULL);
+    return XIRegisterPropertyHandler(dev, AccelSetDecelProperty, NULL, NULL);
 }
 
 
@@ -260,7 +264,7 @@ AccelSetAdaptDecelProperty(DeviceIntPtr dev, Atom atom,
     return Success;
 }
 
-static void
+static long
 AccelInitAdaptDecelProperty(DeviceIntPtr dev, DeviceVelocityPtr vel)
 {
     float fval = 1.0/vel->min_acceleration;
@@ -269,7 +273,7 @@ AccelInitAdaptDecelProperty(DeviceIntPtr dev, DeviceVelocityPtr vel)
     XIChangeDeviceProperty(dev, prop_adapt_decel, XIGetKnownProperty(XATOM_FLOAT), 32,
                            PropModeReplace, 1, &fval, FALSE);
     XISetDevicePropertyDeletable(dev, prop_adapt_decel, FALSE);
-    XIRegisterPropertyHandler(dev, AccelSetAdaptDecelProperty, NULL, NULL);
+    return XIRegisterPropertyHandler(dev, AccelSetAdaptDecelProperty, NULL, NULL);
 }
 
 
@@ -307,7 +311,7 @@ AccelSetScaleProperty(DeviceIntPtr dev, Atom atom,
     return Success;
 }
 
-static void
+static long
 AccelInitScaleProperty(DeviceIntPtr dev, DeviceVelocityPtr vel)
 {
     float fval = vel->corr_mul;
@@ -316,21 +320,57 @@ AccelInitScaleProperty(DeviceIntPtr dev, DeviceVelocityPtr vel)
     XIChangeDeviceProperty(dev, prop_velo_scale, XIGetKnownProperty(XATOM_FLOAT), 32,
                            PropModeReplace, 1, &fval, FALSE);
     XISetDevicePropertyDeletable(dev, prop_velo_scale, FALSE);
-    XIRegisterPropertyHandler(dev, AccelSetScaleProperty, NULL, NULL);
+    return XIRegisterPropertyHandler(dev, AccelSetScaleProperty, NULL, NULL);
 }
 
+static int AccelPropHandlerPrivateKeyIndex;
+DevPrivateKey AccelPropHandlerPrivateKey = &AccelPropHandlerPrivateKeyIndex;
+
 BOOL
 InitializePredictableAccelerationProperties(DeviceIntPtr dev)
 {
     DeviceVelocityPtr  vel = GetDevicePredictableAccelData(dev);
+    long *prop_handlers;
 
     if(!vel)
 	return FALSE;
+    prop_handlers = xalloc(NPROPS_PREDICTABLE_ACCEL * sizeof(long));
+
+    prop_handlers[0] = AccelInitProfileProperty(dev, vel);
+    prop_handlers[1] = AccelInitDecelProperty(dev, vel);
+    prop_handlers[2] = AccelInitAdaptDecelProperty(dev, vel);
+    prop_handlers[3] = AccelInitScaleProperty(dev, vel);
+
+    dixSetPrivate(&dev->devPrivates, AccelPropHandlerPrivateKey,
+                  prop_handlers);
+
+    return TRUE;
+}
+
+BOOL
+DeletePredictableAccelerationProperties(DeviceIntPtr dev)
+{
+    Atom prop;
+    long *prop_handlers;
+    int i;
+
+    prop = XIGetKnownProperty(ACCEL_PROP_VELOCITY_SCALING);
+    XIDeleteDeviceProperty(dev, prop, FALSE);
+    prop = XIGetKnownProperty(ACCEL_PROP_ADAPTIVE_DECELERATION);
+    XIDeleteDeviceProperty(dev, prop, FALSE);
+    prop = XIGetKnownProperty(ACCEL_PROP_CONSTANT_DECELERATION);
+    XIDeleteDeviceProperty(dev, prop, FALSE);
+    prop = XIGetKnownProperty(ACCEL_PROP_PROFILE_NUMBER);
+    XIDeleteDeviceProperty(dev, prop, FALSE);
+
+    prop_handlers = dixLookupPrivate(&dev->devPrivates,
+                                     AccelPropHandlerPrivateKey);
+    dixSetPrivate(&dev->devPrivates, AccelPropHandlerPrivateKey, NULL);
+
+    for (i = 0; prop_handlers && i < NPROPS_PREDICTABLE_ACCEL; i++)
+        XIUnregisterPropertyHandler(dev, prop_handlers[i]);
+    xfree(prop_handlers);
 
-    AccelInitProfileProperty(dev, vel);
-    AccelInitDecelProperty(dev, vel);
-    AccelInitAdaptDecelProperty(dev, vel);
-    AccelInitScaleProperty(dev, vel);
     return TRUE;
 }
 
diff --git a/include/ptrveloc.h b/include/ptrveloc.h
index fa2156b..2a4b40b 100644
--- a/include/ptrveloc.h
+++ b/include/ptrveloc.h
@@ -109,6 +109,9 @@ FreeVelocityData(DeviceVelocityPtr vel);
 extern _X_INTERNAL BOOL
 InitializePredictableAccelerationProperties(DeviceIntPtr dev);
 
+extern _X_INTERNAL BOOL
+DeletePredictableAccelerationProperties(DeviceIntPtr dev);
+
 extern _X_EXPORT int
 SetAccelerationProfile(DeviceVelocityPtr vel, int profile_num);
 
commit 1b127ab8429616adf9ec31ba4d8bdd9af6e104a9
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Tue Nov 24 15:31:48 2009 +1000

    Xi: when deleting all properties, reset property handler to NULL.
    
    Trying to unregister property handlers during the device closure process
    leads to invalid memory accesses.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/Xi/xiproperty.c b/Xi/xiproperty.c
index 4821857..ecb326e 100644
--- a/Xi/xiproperty.c
+++ b/Xi/xiproperty.c
@@ -630,6 +630,8 @@ XIDeleteAllDeviceProperties (DeviceIntPtr device)
         xfree(curr_handler);
         curr_handler = next_handler;
     }
+
+    device->properties.handlers = NULL;
 }
 
 
diff --git a/test/input.c b/test/input.c
index 71e1504..2de55bc 100644
--- a/test/input.c
+++ b/test/input.c
@@ -716,6 +716,59 @@ static void include_byte_padding_macros(void)
 
 }
 
+static void xi_unregister_handlers(void)
+{
+    DeviceIntRec dev;
+    int handler;
+
+    memset(&dev, 0, sizeof(dev));
+
+    handler = XIRegisterPropertyHandler(&dev, NULL, NULL, NULL);
+    g_assert(handler == 1);
+    handler = XIRegisterPropertyHandler(&dev, NULL, NULL, NULL);
+    g_assert(handler == 2);
+    handler = XIRegisterPropertyHandler(&dev, NULL, NULL, NULL);
+    g_assert(handler == 3);
+
+    g_test_message("Unlinking from front.");
+
+    XIUnregisterPropertyHandler(&dev, 4); /* NOOP */
+    g_assert(dev.properties.handlers->id == 3);
+    XIUnregisterPropertyHandler(&dev, 3);
+    g_assert(dev.properties.handlers->id == 2);
+    XIUnregisterPropertyHandler(&dev, 2);
+    g_assert(dev.properties.handlers->id == 1);
+    XIUnregisterPropertyHandler(&dev, 1);
+    g_assert(dev.properties.handlers == NULL);
+
+    handler = XIRegisterPropertyHandler(&dev, NULL, NULL, NULL);
+    g_assert(handler == 4);
+    handler = XIRegisterPropertyHandler(&dev, NULL, NULL, NULL);
+    g_assert(handler == 5);
+    handler = XIRegisterPropertyHandler(&dev, NULL, NULL, NULL);
+    g_assert(handler == 6);
+    XIUnregisterPropertyHandler(&dev, 3); /* NOOP */
+    g_assert(dev.properties.handlers->next->next->next == NULL);
+    XIUnregisterPropertyHandler(&dev, 4);
+    g_assert(dev.properties.handlers->next->next == NULL);
+    XIUnregisterPropertyHandler(&dev, 5);
+    g_assert(dev.properties.handlers->next == NULL);
+    XIUnregisterPropertyHandler(&dev, 6);
+    g_assert(dev.properties.handlers == NULL);
+
+    handler = XIRegisterPropertyHandler(&dev, NULL, NULL, NULL);
+    g_assert(handler == 7);
+    handler = XIRegisterPropertyHandler(&dev, NULL, NULL, NULL);
+    g_assert(handler == 8);
+    handler = XIRegisterPropertyHandler(&dev, NULL, NULL, NULL);
+    g_assert(handler == 9);
+
+    XIDeleteAllDeviceProperties(&dev);
+    g_assert(dev.properties.handlers == NULL);
+    XIUnregisterPropertyHandler(&dev, 7); /* NOOP */
+
+}
+
 int main(int argc, char** argv)
 {
     g_test_init(&argc, &argv,NULL);
@@ -727,6 +780,7 @@ int main(int argc, char** argv)
     g_test_add_func("/dix/input/xi2-struct-sizes", xi2_struct_sizes);
     g_test_add_func("/dix/input/grab_matching", dix_grab_matching);
     g_test_add_func("/include/byte_padding_macros", include_byte_padding_macros);
+    g_test_add_func("/Xi/xiproperty/register-unregister", xi_unregister_handlers);
 
     return g_test_run();
 }
commit 8806375ed72a3cd465fe0a49ead079a334accd6b
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Tue Nov 17 09:25:47 2009 +1000

    Move xdmxconfig modules into DMX conditionals (#25102)
    
    xdmxconfig requires additional modules not checked for if Xdmx build is set
    to auto (the default). This may lead to build errors if the Xdmx modules are
    installed, but not the extra ones required for xdmxconfig.
    
    X.Org Bug 25102 <http://bugs.freedesktop.org/show_bug.cgi?id=25102>
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Remi Cardona <remi at gentoo.org>
    Acked-by: Julien Cristau <jcristau at debian.org>

diff --git a/configure.ac b/configure.ac
index 4c3b3f8..fcd8875 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1881,10 +1881,11 @@ AM_CONDITIONAL(XQUARTZ_SPARKLE, [test "x$XQUARTZ_SPARKLE" != "xno"])
 AM_CONDITIONAL(STANDALONE_XPBPROXY, [test "x$STANDALONE_XPBPROXY" = xyes])
 
 dnl DMX DDX
-
 PKG_CHECK_MODULES([DMXMODULES],
     [xmuu $LIBXEXT x11 xrender xfixes xfont $LIBXI $DMXPROTO xau $XDMCP_MODULES],
-    [have_dmx=yes], [have_dmx=no])
+    PKG_CHECK_MODULES([XDMXCONFIG_DEP], [xaw7 xmu xt xpm x11], [have_dmx=yes],
+                      [have_dmx=no]),
+    [have_dmx=no])
 AC_MSG_CHECKING([whether to build Xdmx DDX])
 if test "x$DMX" = xauto; then
 	DMX="$have_dmx"
@@ -1917,7 +1918,6 @@ dnl USB sources in DMX require <linux/input.h>
 dnl Linux sources in DMX require <linux/keyboard.h>
 	AC_CHECK_HEADER([linux/keyboard.h], DMX_BUILD_LNX="yes",
 			DMX_BUILD_LNX="no")
-	PKG_CHECK_MODULES([XDMXCONFIG_DEP], [xaw7 xmu xt xpm x11])
 	AC_SUBST(XDMXCONFIG_DEP_CFLAGS)
 	AC_SUBST(XDMXCONFIG_DEP_LIBS)
 	PKG_CHECK_MODULES([DMXEXAMPLES_DEP], [$LIBDMX $LIBXEXT x11])
commit a2adda7ab3defd953cf0f48f5372efb037786a9e
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu Nov 19 16:35:55 2009 +1000

    Revert "Move xdmxconfig modules into DMX conditionals (#25102)"
    
    New package dependency unnecessarily links in a few libraries that Xdmx
    doesn't need. This can be fixed more elegantly.
    
    This reverts commit 0ef15ca9d2d9c78c79a2771c550563bc6931b365.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/configure.ac b/configure.ac
index 6f8441c..4c3b3f8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1881,9 +1881,9 @@ AM_CONDITIONAL(XQUARTZ_SPARKLE, [test "x$XQUARTZ_SPARKLE" != "xno"])
 AM_CONDITIONAL(STANDALONE_XPBPROXY, [test "x$STANDALONE_XPBPROXY" = xyes])
 
 dnl DMX DDX
-XDMXCONFIG_MODULES="xaw7 xmu xt xpm x11"
+
 PKG_CHECK_MODULES([DMXMODULES],
-    [xmuu $LIBXEXT x11 xrender xfixes xfont $LIBXI $DMXPROTO xau $XDMCP_MODULES $XDMXCONFIG_MODULES],
+    [xmuu $LIBXEXT x11 xrender xfixes xfont $LIBXI $DMXPROTO xau $XDMCP_MODULES],
     [have_dmx=yes], [have_dmx=no])
 AC_MSG_CHECKING([whether to build Xdmx DDX])
 if test "x$DMX" = xauto; then
@@ -1917,7 +1917,7 @@ dnl USB sources in DMX require <linux/input.h>
 dnl Linux sources in DMX require <linux/keyboard.h>
 	AC_CHECK_HEADER([linux/keyboard.h], DMX_BUILD_LNX="yes",
 			DMX_BUILD_LNX="no")
-	PKG_CHECK_MODULES([XDMXCONFIG_DEP], [$XDMXCONFIG_MODULES])
+	PKG_CHECK_MODULES([XDMXCONFIG_DEP], [xaw7 xmu xt xpm x11])
 	AC_SUBST(XDMXCONFIG_DEP_CFLAGS)
 	AC_SUBST(XDMXCONFIG_DEP_LIBS)
 	PKG_CHECK_MODULES([DMXEXAMPLES_DEP], [$LIBDMX $LIBXEXT x11])
commit eb967ca36cfe0409972ac987a74d498cd6f6bafb
Author: Rami Ylimaki <ext-rami.ylimaki at nokia.com>
Date:   Tue Nov 17 17:13:43 2009 +0200

    Xext: Fix a memory leak on GE client disconnect.
    
    Add a call to dixRequestPrivate to inform dixFreePrivates that memory
    allocated in GEClientCallback should be released when client
    disconnects. Otherwise there is a leak of sizeof(GEClientInfoRec) for
    every client connect/disconnect.
    
    Also remove the explicit allocation and let GEGetClient /
    dixLookupPrivate do it. This makes GEClientCallback similar to the
    other extension callbacks.
    
    Signed-off-by: Rami Ylimaki <ext-rami.ylimaki at nokia.com>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/Xext/geext.c b/Xext/geext.c
index 6fad4ae..2ba0ca8 100644
--- a/Xext/geext.c
+++ b/Xext/geext.c
@@ -168,12 +168,6 @@ GEClientCallback(CallbackListPtr *list,
     ClientPtr		pClient = clientinfo->client;
     GEClientInfoPtr     pGEClient = GEGetClient(pClient);
 
-    if (pGEClient == NULL)
-    {
-        pGEClient = xcalloc(1, sizeof(GEClientInfoRec));
-        dixSetPrivate(&pClient->devPrivates, GEClientPrivateKey, pGEClient);
-    }
-
     pGEClient->major_version = 0;
     pGEClient->minor_version = 0;
 }
@@ -222,6 +216,9 @@ GEExtensionInit(void)
 {
     ExtensionEntry *extEntry;
 
+    if (!dixRequestPrivate(GEClientPrivateKey, sizeof(GEClientInfoRec)))
+        FatalError("GEExtensionInit: GE private request failed.\n");
+
     if(!AddCallback(&ClientStateCallback, GEClientCallback, 0))
     {
         FatalError("GEExtensionInit: register client callback failed.\n");


More information about the xorg-commit mailing list