xserver: Branch 'master' - 3 commits

Peter Hutterer whot at kemper.freedesktop.org
Thu May 7 21:08:23 PDT 2009


 dix/ptrveloc.c     |   47 +++++++++++++++++++++++++++++++++++------------
 include/ptrveloc.h |    7 +++----
 2 files changed, 38 insertions(+), 16 deletions(-)

New commits:
commit 3fc6fcfb267888d65a22ed7c3eda175a2530a3d5
Author: Simon Thum <simon.thum at gmx.de>
Date:   Wed May 6 10:39:16 2009 +0200

    dix: add 'none' pointer acceleration profile with number -1
    
    This is a shorthand for disabling acceleration, while retaining the
    possiblity to use constant deceleration. If constant deceleration is
    also unused, it will optimize motion processing.
    
    Other possiblities to deactivate acceleration were quite hidden,
    and didn't always work as expected. E.g. xset m 1 1 would retain
    adaptive deceleration, while xset m 1 0 would not (in the default
    profile).
    
    Also removes the 'reserved' profile; it was unused and it's trivial
    to add new ones anyway.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c
index 7732e95..2907d40 100644
--- a/dix/ptrveloc.c
+++ b/dix/ptrveloc.c
@@ -77,9 +77,12 @@ GetAccelerationProfile(DeviceVelocityPtr s, int profile_num);
 #endif
 
 /********************************
- *  Init/Uninit etc
+ *  Init/Uninit
  *******************************/
 
+/* some int which is not a profile number */
+#define PROFILE_UNINITIALIZE (-100)
+
 /**
  * Init struct so it should match the average case
  */
@@ -108,7 +111,7 @@ InitVelocityData(DeviceVelocityPtr s)
 static void
 FreeVelocityData(DeviceVelocityPtr s){
     xfree(s->tracker);
-    SetAccelerationProfile(s, -1);
+    SetAccelerationProfile(s, PROFILE_UNINITIALIZE);
 }
 
 
@@ -824,6 +827,16 @@ LinearProfile(
 }
 
 
+static float
+NoProfile(
+    DeviceVelocityPtr pVel,
+    float velocity,
+    float threshold,
+    float acc)
+{
+    return 1.0f;
+}
+
 static PointerAccelerationProfileFunc
 GetAccelerationProfile(
     DeviceVelocityPtr s,
@@ -844,8 +857,8 @@ GetAccelerationProfile(
             return PowerProfile;
         case AccelProfileLinear:
             return LinearProfile;
-        case AccelProfileReserved:
-            /* reserved for future use, e.g. a user-defined profile */
+        case AccelProfileNone:
+            return NoProfile;
         default:
             return NULL;
     }
@@ -856,8 +869,10 @@ GetAccelerationProfile(
  * Intended to make profiles exchangeable at runtime.
  * If you created a profile, give it a number here and in the header to
  * make it selectable. In case some profile-specific init is needed, here
- * would be a good place, since FreeVelocityData() also calls this with -1.
- * returns FALSE (0) if profile number is unavailable.
+ * would be a good place, since FreeVelocityData() also calls this with
+ * PROFILE_UNINITIALIZE.
+ *
+ * returns FALSE if profile number is unavailable, TRUE otherwise.
  */
 int
 SetAccelerationProfile(
@@ -867,7 +882,7 @@ SetAccelerationProfile(
     PointerAccelerationProfileFunc profile;
     profile = GetAccelerationProfile(s, profile_num);
 
-    if(profile == NULL && profile_num != -1)
+    if(profile == NULL && profile_num != PROFILE_UNINITIALIZE)
 	return FALSE;
 
     if(s->profile_private != NULL){
@@ -955,6 +970,11 @@ acceleratePointerPredictable(
     if (!num_valuators || !valuators || !velocitydata)
         return;
 
+    if (velocitydata->statistics.profile_number == AccelProfileNone &&
+	velocitydata->const_acceleration == 1.0f) {
+	return; /*we're inactive anyway, so skip the whole thing.*/
+    }
+
     if (first_valuator == 0) {
         dx = valuators[0];
         px = &valuators[0];
@@ -994,7 +1014,7 @@ acceleratePointerPredictable(
                     /* Since it may not be apparent: lrintf() does not offer
                      * strong statements about rounding; however because we
                      * process each axis conditionally, there's no danger
-                     * of a toggling remainder. Its lack of guarantees hopefully
+                     * of a toggling remainder. Its lack of guarantees likely
                      * makes it faster on the average target. */
                     *px = lrintf(tmp);
                     pDev->last.remainder[0] = tmp - (float)*px;
diff --git a/include/ptrveloc.h b/include/ptrveloc.h
index 6ef8c75..83d188c 100644
--- a/include/ptrveloc.h
+++ b/include/ptrveloc.h
@@ -27,9 +27,9 @@
 
 #include <input.h> /* DeviceIntPtr */
 
-/* constants for acceleration profiles;
- * see  */
+/* constants for acceleration profiles */
 
+#define AccelProfileNone -1
 #define AccelProfileClassic  0
 #define AccelProfileDeviceSpecific 1
 #define AccelProfilePolynomial 2
@@ -37,8 +37,7 @@
 #define AccelProfileSimple 4
 #define AccelProfilePower 5
 #define AccelProfileLinear 6
-#define AccelProfileReserved 7
-#define AccelProfileLAST AccelProfileReserved
+#define AccelProfileLAST AccelProfileLinear
 
 /* fwd */
 struct _DeviceVelocityRec;
commit 9d1597cbefea6a5e7959f2099c46f1a284def7ad
Author: Simon Thum <simon.thum at gmx.de>
Date:   Thu Apr 30 13:01:17 2009 +0200

    dix: remove superfluous includes from ptrveloc.c
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c
index 0a9a22e..7732e95 100644
--- a/dix/ptrveloc.c
+++ b/dix/ptrveloc.c
@@ -28,11 +28,8 @@
 
 #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>
 
commit 35fce4e5c7fa34f98b3e4010c6cb09ce38a9205c
Author: Simon Thum <simon.thum at gmx.de>
Date:   Thu Apr 30 12:58:48 2009 +0200

    dix: fix warning in pointer acceleration
    
    newer gcc's warn against how this cast is done (though it eludes me why),
    and lrintf() is also faster especially on insane processors like the P4
    (http://www.mega-nerd.com/FPcast).
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c
index 99efc79..0a9a22e 100644
--- a/dix/ptrveloc.c
+++ b/dix/ptrveloc.c
@@ -994,14 +994,20 @@ acceleratePointerPredictable(
 
                 if (dx) {
                     tmp = mult * fdx + pDev->last.remainder[0];
-                    *px = (int)roundf(tmp);
+                    /* Since it may not be apparent: lrintf() does not offer
+                     * strong statements about rounding; however because we
+                     * process each axis conditionally, there's no danger
+                     * of a toggling remainder. Its lack of guarantees hopefully
+                     * makes it faster on the average target. */
+                    *px = lrintf(tmp);
                     pDev->last.remainder[0] = tmp - (float)*px;
                 }
                 if (dy) {
                     tmp = mult * fdy + pDev->last.remainder[1];
-                    *py = (int)roundf(tmp);
+                    *py = lrintf(tmp);
                     pDev->last.remainder[1] = tmp - (float)*py;
                 }
+                DebugAccelF("pos (%i | %i) remainders x: %.3f y: %.3f delta x:%.3f y:%.3f\n", *px, *py, pDev->last.remainder[0], pDev->last.remainder[1], fdx, fdy);
             }
         }
     }


More information about the xorg-commit mailing list