xserver: Branch 'master' - 3 commits

Peter Hutterer whot at kemper.freedesktop.org
Wed Jan 14 15:49:45 PST 2009


 Xi/xiproperty.c                |    6 -
 dix/devices.c                  |   10 +
 dix/ptrveloc.c                 |  211 ++++++++++++++++++++++++++++++++++++++++-
 hw/xfree86/common/xf86Xinput.c |   77 +++++++++++---
 include/ptrveloc.h             |    4 
 include/xserver-properties.h   |   10 +
 mi/mieq.c                      |   26 ++++-
 xkb/ddxDevBtn.c                |    2 
 8 files changed, 323 insertions(+), 23 deletions(-)

New commits:
commit 1d54479cb3c8b4f75b7564f8b5e1c5da940b20f4
Author: Simon Thum <simon.thum at gmx.de>
Date:   Tue Nov 25 14:12:02 2008 +1000

    xfree86: init properties when ptraccel configuration is found.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at redhat.com>
    Signed-off-by: Simon Thum <simon.thum at gmx.de>

diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 582c722..413ef03 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -54,6 +54,7 @@
 #include <X11/Xmd.h>
 #include <X11/extensions/XI.h>
 #include <X11/extensions/XIproto.h>
+#include <X11/Xatom.h>
 #include "xf86.h"
 #include "xf86Priv.h"
 #include "xf86Xinput.h"
@@ -85,6 +86,7 @@
 #include "mi.h"
 
 #include <ptrveloc.h>          /* dix pointer acceleration */
+#include <xserver-properties.h>
 
 #ifdef XFreeXDGA
 #include "dgaproc.h"
@@ -102,13 +104,69 @@ EventListPtr xf86Events = NULL;
  * Eval config and modify DeviceVelocityRec accordingly
  */
 static void
-ProcessVelocityConfiguration(char* devname, pointer list, DeviceVelocityPtr s){
+ProcessVelocityConfiguration(DeviceIntPtr pDev, char* devname, pointer list,
+                             DeviceVelocityPtr s)
+{
     int tempi, i;
     float tempf, tempf2;
+    Atom float_prop = XIGetKnownProperty(XATOM_FLOAT);
+    Atom prop;
 
     if(!s)
         return;
 
+    /* common settings (available via device properties) */
+    tempf = xf86SetIntOption(list, "ConstantDeceleration", 1);
+    if(tempf > 1.0){
+        xf86Msg(X_CONFIG, "%s: (accel) constant deceleration by %.1f\n",
+                devname, tempf);
+        prop = XIGetKnownProperty(ACCEL_PROP_CONSTANT_DECELERATION);
+        XIChangeDeviceProperty(pDev, prop, float_prop, 32,
+                               PropModeReplace, 1, &tempf, FALSE);
+    }
+
+    tempf = xf86SetIntOption(list, "AdaptiveDeceleration", 1);
+    if(tempf > 1.0){
+        xf86Msg(X_CONFIG, "%s: (accel) adaptive deceleration by %.1f\n",
+                devname, tempf);
+        prop = XIGetKnownProperty(ACCEL_PROP_ADAPTIVE_DECELERATION);
+        XIChangeDeviceProperty(pDev, prop, float_prop, 32,
+                               PropModeReplace, 1, &tempf, FALSE);
+    }
+
+    /* select profile by number */
+    tempi = xf86SetIntOption(list, "AccelerationProfile",
+            s->statistics.profile_number);
+
+    prop = XIGetKnownProperty(ACCEL_PROP_PROFILE_NUMBER);
+    if (XIChangeDeviceProperty(pDev, prop, XA_INTEGER, 32,
+                               PropModeReplace, 1, &tempi, FALSE) == Success)
+    {
+        xf86Msg(X_CONFIG, "%s: (accel) acceleration profile %i\n", devname,
+                tempi);
+    } else {
+        xf86Msg(X_CONFIG, "%s: (accel) acceleration profile %i is unknown\n",
+                devname, tempi);
+    }
+
+    /* set scaling */
+    tempf = xf86SetRealOption(list, "ExpectedRate", 0);
+    prop = XIGetKnownProperty(ACCEL_PROP_VELOCITY_SCALING);
+    if(tempf > 0){
+        if(tempf > 300){
+            xf86Msg(X_WARNING, "%s: (accel) Using ExpectedRate > 300 may not "
+                    "yield good controllability!\n", devname);
+        }
+        tempf = 1000.0 / tempf;
+        XIChangeDeviceProperty(pDev, prop, float_prop, 32,
+                               PropModeReplace, 1, &tempf, FALSE);
+    }else{
+        tempf = xf86SetRealOption(list, "VelocityScale", s->corr_mul);
+        XIChangeDeviceProperty(pDev, prop, float_prop, 32,
+                               PropModeReplace, 1, &tempf, FALSE);
+    }
+
+    /* advanced stuff, best kept in .fdi's */
     tempf = xf86SetRealOption(list, "FilterHalflife", -1);
     if(tempf > 0)
         tempf = 1.0 / tempf;   /* set reciprocal if possible */
@@ -135,21 +193,6 @@ ProcessVelocityConfiguration(char* devname, pointer list, DeviceVelocityPtr s){
                 devname, i, 1.0f / (s->filters[i].rdecay));
     }
 
-    tempf = xf86SetRealOption(list, "ConstantDeceleration", 1.0);
-    if(tempf > 1.0){
-        xf86Msg(X_CONFIG, "%s: (accel) constant deceleration by %.1f\n",
-                devname, tempf);
-        s->const_acceleration = 1.0 / tempf;   /* set reciprocal deceleration
-                                                  alias acceleration */
-    }
-
-    tempf = xf86SetRealOption(list, "AdaptiveDeceleration", 1.0);
-    if(tempf > 1.0){
-        xf86Msg(X_CONFIG, "%s: (accel) adaptive deceleration by %.1f\n",
-                devname, tempf);
-        s->min_acceleration = 1.0 / tempf;   /* set minimum acceleration */
-    }
-
     tempf = xf86SetRealOption(list, "VelocityCoupling", -1);
     if(tempf >= 0){
 	xf86Msg(X_CONFIG, "%s: (accel) velocity coupling is %.1f%%\n", devname,
@@ -234,7 +277,7 @@ ApplyAccelerationSettings(DeviceIntPtr dev){
         switch(scheme){
             case PtrAccelPredictable:
                 pVel = GetDevicePredictableAccelData(dev);
-                ProcessVelocityConfiguration (local->name, local->options,
+                ProcessVelocityConfiguration (dev, local->name, local->options,
                                               pVel);
                 break;
         }
commit 19275ea8e9dd93d5e61906943706dfe49003dd9c
Author: Simon Thum <simon.thum at gmx.de>
Date:   Wed Nov 19 16:01:21 2008 +1000

    dix: add property support for pointer acceleration.
    
    Note: properties don't need to be cleaned up, the DIX does it for us anyway.
    Data that is stored in properties is cleaned up by the property system.
    Handlers, etc. don't need to be unregistered while cleaning up, as they get
    deleted when the device is removed anyway.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at redhat.com>
    Signed-off-by: Simon Thum <simon.thum at gmx.de>

diff --git a/Xi/xiproperty.c b/Xi/xiproperty.c
index 6da8424..53b2f6a 100644
--- a/Xi/xiproperty.c
+++ b/Xi/xiproperty.c
@@ -50,7 +50,11 @@ static struct dev_properties
     char *name;
 } dev_properties[] = {
     {0, XI_PROP_ENABLED},
-    {0, XATOM_FLOAT}
+    {0, XATOM_FLOAT},
+    {0, ACCEL_PROP_PROFILE_NUMBER},
+    {0, ACCEL_PROP_CONSTANT_DECELERATION},
+    {0, ACCEL_PROP_ADAPTIVE_DECELERATION},
+    {0, ACCEL_PROP_VELOCITY_SCALING}
 };
 
 static long XIPropHandlerID = 1;
diff --git a/dix/devices.c b/dix/devices.c
index e5e3832..f2410fd 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -1319,6 +1319,16 @@ InitPointerAccelerationScheme(DeviceIntPtr dev,
     val->accelScheme = pointerAccelerationScheme[i];
     val->accelScheme.accelData = data;
 
+    /* post-init scheme */
+    switch(scheme){
+        case PtrAccelPredictable:
+            InitializePredictableAccelerationProperties(dev);
+            break;
+
+        default:
+            break;
+    }
+
     return TRUE;
 }
 
diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c
index 95a7c71..dcf91df 100644
--- a/dix/ptrveloc.c
+++ b/dix/ptrveloc.c
@@ -29,9 +29,13 @@
 #include <math.h>
 #include <ptrveloc.h>
 #include <inputstr.h>
+#include <exevents.h>
+#include <X11/Xatom.h>
 #include <assert.h>
 #include <os.h>
 
+#include <xserver-properties.h>
+
 /*****************************************************************************
  * Predictable pointer acceleration
  *
@@ -52,8 +56,8 @@
  *      which returns an acceleration
  *      for a given velocity
  *
- *  The profile can be selected by the user (potentially at runtime).
- *  the classic profile is intended to cleanly perform old-style
+ *  The profile can be selected by the user at runtime.
+ *  The classic profile is intended to cleanly perform old-style
  *  function selection (threshold =/!= 0)
  *
  ****************************************************************************/
@@ -137,6 +141,209 @@ AccelerationDefaultCleanup(DeviceIntPtr pDev)
     }
 }
 
+
+/*************************
+ * Input property support
+ ************************/
+
+/**
+ * choose profile
+ */
+static int
+AccelSetProfileProperty(DeviceIntPtr dev, Atom atom,
+                        XIPropertyValuePtr val, BOOL checkOnly)
+{
+    DeviceVelocityPtr pVel;
+    int profile, *ptr = &profile;
+    int rc;
+    int nelem = 1;
+
+    if (atom != XIGetKnownProperty(ACCEL_PROP_PROFILE_NUMBER))
+        return Success;
+
+    pVel = GetDevicePredictableAccelData(dev);
+    if (!pVel)
+        return BadValue;
+    rc = XIPropToInt(val, &nelem, &ptr);
+
+    if(checkOnly)
+    {
+        if (rc)
+            return rc;
+
+        if (GetAccelerationProfile(pVel, profile) == NULL)
+            return BadValue;
+    } else
+	SetAccelerationProfile(pVel, profile);
+
+    return Success;
+}
+
+static void
+AccelInitProfileProperty(DeviceIntPtr dev, DeviceVelocityPtr pVel)
+{
+    int profile = pVel->statistics.profile_number;
+    Atom prop_profile_number = XIGetKnownProperty(ACCEL_PROP_PROFILE_NUMBER);
+
+    XIChangeDeviceProperty(dev, prop_profile_number, XA_INTEGER, 32,
+                           PropModeReplace, 1, &profile, FALSE);
+    XISetDevicePropertyDeletable(dev, prop_profile_number, FALSE);
+    XIRegisterPropertyHandler(dev, AccelSetProfileProperty, NULL, NULL);
+}
+
+/**
+ * constant deceleration
+ */
+static int
+AccelSetDecelProperty(DeviceIntPtr dev, Atom atom,
+                      XIPropertyValuePtr val, BOOL checkOnly)
+{
+    DeviceVelocityPtr pVel;
+    float v, *ptr = &v;
+    int rc;
+    int nelem = 1;
+
+    if (atom != XIGetKnownProperty(ACCEL_PROP_CONSTANT_DECELERATION))
+        return Success;
+
+    pVel = GetDevicePredictableAccelData(dev);
+    if (!pVel)
+        return BadValue;
+    rc = XIPropToFloat(val, &nelem, &ptr);
+
+    if(checkOnly)
+    {
+        if (rc)
+            return rc;
+	return (v >= 1.0f) ? Success : BadValue;
+    }
+
+    if(v >= 1.0f)
+	pVel->const_acceleration = 1/v;
+
+    return Success;
+}
+
+static void
+AccelInitDecelProperty(DeviceIntPtr dev, DeviceVelocityPtr pVel)
+{
+    float fval = 1.0/pVel->const_acceleration;
+    Atom prop_const_decel = XIGetKnownProperty(ACCEL_PROP_CONSTANT_DECELERATION);
+    XIChangeDeviceProperty(dev, prop_const_decel,
+                           XIGetKnownProperty(XATOM_FLOAT), 32,
+                           PropModeReplace, 1, &fval, FALSE);
+    XISetDevicePropertyDeletable(dev, prop_const_decel, FALSE);
+    XIRegisterPropertyHandler(dev, AccelSetDecelProperty, NULL, NULL);
+}
+
+
+/**
+ * adaptive deceleration
+ */
+static int
+AccelSetAdaptDecelProperty(DeviceIntPtr dev, Atom atom,
+                           XIPropertyValuePtr val, BOOL checkOnly)
+{
+    DeviceVelocityPtr pVel;
+    float v, *ptr = &v;
+    int rc;
+    int nelem = 1;
+
+    if (atom != XIGetKnownProperty(ACCEL_PROP_ADAPTIVE_DECELERATION))
+        return Success;
+
+    pVel = GetDevicePredictableAccelData(dev);
+    if (!pVel)
+        return BadValue;
+    rc = XIPropToFloat(val, &nelem, &ptr);
+
+    if(checkOnly)
+    {
+        if (rc)
+            return rc;
+	return (v >= 1.0f) ? Success : BadValue;
+    }
+
+    if(v >= 1.0f)
+	pVel->min_acceleration = 1/v;
+
+    return Success;
+}
+
+static void
+AccelInitAdaptDecelProperty(DeviceIntPtr dev, DeviceVelocityPtr pVel)
+{
+    float fval = 1.0/pVel->min_acceleration;
+    Atom prop_adapt_decel = XIGetKnownProperty(ACCEL_PROP_ADAPTIVE_DECELERATION);
+
+    XIChangeDeviceProperty(dev, prop_adapt_decel, XIGetKnownProperty(XATOM_FLOAT), 32,
+                           PropModeReplace, 1, &fval, FALSE);
+    XISetDevicePropertyDeletable(dev, prop_adapt_decel, FALSE);
+    XIRegisterPropertyHandler(dev, AccelSetAdaptDecelProperty, NULL, NULL);
+}
+
+
+/**
+ * velocity scaling
+ */
+static int
+AccelSetScaleProperty(DeviceIntPtr dev, Atom atom,
+                      XIPropertyValuePtr val, BOOL checkOnly)
+{
+    DeviceVelocityPtr pVel;
+    float v, *ptr = &v;
+    int rc;
+    int nelem = 1;
+
+    if (atom != XIGetKnownProperty(ACCEL_PROP_VELOCITY_SCALING))
+        return Success;
+
+    pVel = GetDevicePredictableAccelData(dev);
+    if (!pVel)
+        return BadValue;
+    rc = XIPropToFloat(val, &nelem, &ptr);
+
+    if (checkOnly)
+    {
+        if (rc)
+            return rc;
+
+        return (v > 0) ? Success : BadValue;
+    }
+
+    if(v > 0)
+	pVel->corr_mul = v;
+
+    return Success;
+}
+
+static void
+AccelInitScaleProperty(DeviceIntPtr dev, DeviceVelocityPtr pVel)
+{
+    float fval = pVel->corr_mul;
+    Atom prop_velo_scale = XIGetKnownProperty(ACCEL_PROP_VELOCITY_SCALING);
+
+    XIChangeDeviceProperty(dev, prop_velo_scale, XIGetKnownProperty(XATOM_FLOAT), 32,
+                           PropModeReplace, 1, &fval, FALSE);
+    XISetDevicePropertyDeletable(dev, prop_velo_scale, FALSE);
+    XIRegisterPropertyHandler(dev, AccelSetScaleProperty, NULL, NULL);
+}
+
+BOOL
+InitializePredictableAccelerationProperties(DeviceIntPtr device)
+{
+    DeviceVelocityPtr  pVel        = GetDevicePredictableAccelData(device);
+
+    if(!pVel)
+	return FALSE;
+
+    AccelInitProfileProperty(device, pVel);
+    AccelInitDecelProperty(device, pVel);
+    AccelInitAdaptDecelProperty(device, pVel);
+    AccelInitScaleProperty(device, pVel);
+    return TRUE;
+}
+
 /*********************
  * Filtering logic
  ********************/
diff --git a/include/ptrveloc.h b/include/ptrveloc.h
index e491051..096dea8 100644
--- a/include/ptrveloc.h
+++ b/include/ptrveloc.h
@@ -43,6 +43,7 @@
 #define AccelProfilePower 5
 #define AccelProfileLinear 6
 #define AccelProfileReserved 7
+#define AccelProfileLAST AccelProfileReserved
 
 /* fwd */
 struct _DeviceVelocityRec;
@@ -103,6 +104,9 @@ typedef struct _DeviceVelocityRec {
 extern _X_EXPORT void
 InitVelocityData(DeviceVelocityPtr s);
 
+extern _X_EXPORT BOOL
+InitializePredictableAccelerationProperties(DeviceIntPtr pDev);
+
 extern _X_EXPORT void
 InitFilterChain(DeviceVelocityPtr s, float rdecay, float degression,
                 int lutsize, int stages);
diff --git a/include/xserver-properties.h b/include/xserver-properties.h
index f8aeab6..1327e59 100644
--- a/include/xserver-properties.h
+++ b/include/xserver-properties.h
@@ -33,4 +33,14 @@
 /* BOOL. 0 - device disabled, 1 - device enabled */
 #define XI_PROP_ENABLED      "Device Enabled"
 
+/* Pointer acceleration properties */
+/* INTEGER of any format */
+#define ACCEL_PROP_PROFILE_NUMBER "Device Accel Profile"
+/* FLOAT, format 32 */
+#define ACCEL_PROP_CONSTANT_DECELERATION "Device Accel Constant Deceleration"
+/* FLOAT, format 32 */
+#define ACCEL_PROP_ADAPTIVE_DECELERATION "Device Accel Adaptive Deceleration"
+/* FLOAT, format 32 */
+#define ACCEL_PROP_VELOCITY_SCALING "Device Accel Velocity Scaling"
+
 #endif
commit d645721170b1196e5064b397cfbffd1da8c79bb1
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu Jan 8 11:53:30 2009 +1000

    mi: ensure chained button mappings from SD -> MD (#19282)
    
    After copying the master event, flip the detail field to the mapped button of
    the SD, not the physical button. This way if the SD has a mapping 1:3 and the
    MD has a mapping of 3:4, a press on button 1 on the SD results in a core event
    on button 4.
    
    X.Org Bug 19282 <http://bugs.freedesktop.org/show_bug.cgi?id=19282>
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/mi/mieq.c b/mi/mieq.c
index 963f27c..3ce3c49 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -323,15 +323,32 @@ ChangeDeviceID(DeviceIntPtr dev, xEvent* event)
         DebugF("[mi] Unknown event type (%d), cannot change id.\n", type);
 }
 
+static void
+FixUpEventForMaster(DeviceIntPtr mdev, DeviceIntPtr sdev, xEvent* original,
+                    EventListPtr master, int count)
+{
+    /* Ensure chained button mappings, i.e. that the detail field is the
+     * value of the mapped button on the SD, not the physical button */
+    if (original->u.u.type == DeviceButtonPress || original->u.u.type == DeviceButtonRelease)
+    {
+        int btn = original->u.u.detail;
+        if (!sdev->button)
+            return; /* Should never happen */
+
+        master->event->u.u.detail = sdev->button->map[btn];
+    }
+}
+
 /**
  * Copy the given event into master.
  * @param mdev The master device
+ * @param sdev The slave device the original event comes from
  * @param original The event as it came from the EQ
  * @param master The event after being copied
  * @param count Number of events in original.
  */
 void
-CopyGetMasterEvent(DeviceIntPtr mdev, xEvent* original,
+CopyGetMasterEvent(DeviceIntPtr mdev, DeviceIntPtr sdev, xEvent* original,
                    EventListPtr master, int count)
 {
     int len = count * sizeof(xEvent);
@@ -346,9 +363,14 @@ CopyGetMasterEvent(DeviceIntPtr mdev, xEvent* original,
 
     memcpy(master->event, original, len);
     while (count--)
+    {
         ChangeDeviceID(mdev, &master->event[count]);
+        FixUpEventForMaster(mdev, sdev, original, master, count);
+    }
 }
 
+
+
 /* Call this from ProcessInputEvents(). */
 void
 mieqProcessInputEvents(void)
@@ -419,7 +441,7 @@ mieqProcessInputEvents(void)
         }
         else {
             if (master)
-                CopyGetMasterEvent(master, event, masterEvents, nevents);
+                CopyGetMasterEvent(master, dev, event, masterEvents, nevents);
 
             /* If someone's registered a custom event handler, let them
              * steal it. */
diff --git a/xkb/ddxDevBtn.c b/xkb/ddxDevBtn.c
index 709efc1..03fb440 100644
--- a/xkb/ddxDevBtn.c
+++ b/xkb/ddxDevBtn.c
@@ -116,7 +116,7 @@ DeviceIntPtr		master = NULL;
         if (!IsPointerDevice(master))
             master = GetPairedDevice(dev->u.master);
 
-        CopyGetMasterEvent(master, &events, masterEvents, count);
+        CopyGetMasterEvent(master, dev, &events, masterEvents, count);
     }
 
     (*dev->public.processInputProc)((xEventPtr)btn, dev, count);


More information about the xorg-commit mailing list