[PATCH synaptics 2/2] Use the scroll distances as increment for scrolling valuator axes

Peter Hutterer peter.hutterer at who-t.net
Tue Oct 18 20:21:14 PDT 2011


XI2.1 allows an 'increment' for each scrolling variable. Use that instead of
hiding it away inside the driver.

For circular scrolling, the increment is the one of the respective scrolling
axis.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/properties.c |   18 ++++++++++++++++--
 src/synaptics.c  |   20 ++++++++++----------
 2 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/src/properties.c b/src/properties.c
index 5f11cf2..3a13324 100644
--- a/src/properties.c
+++ b/src/properties.c
@@ -425,8 +425,22 @@ SetProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop,
             return BadMatch;
 
         dist = (INT32*)prop->data;
-        para->scroll_dist_vert = dist[0];
-        para->scroll_dist_horiz = dist[1];
+        if (!checkonly && para->scroll_dist_vert != dist[0])
+        {
+            para->scroll_dist_vert = dist[0];
+#ifdef HAVE_SMOOTH_SCROLL
+            SetScrollValuator(dev, priv->scroll_axis_vert, SCROLL_TYPE_VERTICAL,
+                              para->scroll_dist_vert, 0);
+#endif
+        }
+        if (!checkonly && para->scroll_dist_horiz != dist[1])
+        {
+            para->scroll_dist_horiz = dist[1];
+#ifdef HAVE_SMOOTH_SCROLL
+            SetScrollValuator(dev, priv->scroll_axis_horiz, SCROLL_TYPE_HORIZONTAL,
+                              para->scroll_dist_horiz, 0);
+#endif
+        }
     } else if (property == prop_scrolledge)
     {
         CARD8 *edge;
diff --git a/src/synaptics.c b/src/synaptics.c
index 9daa45a..1c9b6db 100644
--- a/src/synaptics.c
+++ b/src/synaptics.c
@@ -1101,8 +1101,10 @@ DeviceInit(DeviceIntPtr dev)
     if (!priv->scroll_events_mask)
         return !Success;
 
-    SetScrollValuator(dev, priv->scroll_axis_horiz, SCROLL_TYPE_HORIZONTAL, 1, 0);
-    SetScrollValuator(dev, priv->scroll_axis_vert, SCROLL_TYPE_VERTICAL, 1, 0);
+    SetScrollValuator(dev, priv->scroll_axis_horiz, SCROLL_TYPE_HORIZONTAL,
+                      priv->synpara.scroll_dist_horiz, 0);
+    SetScrollValuator(dev, priv->scroll_axis_vert, SCROLL_TYPE_VERTICAL,
+                      priv->synpara.scroll_dist_vert, 0);
 #endif
 
     if (!alloc_shm_data(pInfo))
@@ -2232,17 +2234,15 @@ HandleScrolling(SynapticsPrivate *priv, struct SynapticsHwState *hw,
 
     if (priv->vert_scroll_edge_on || priv->vert_scroll_twofinger_on) {
 	/* + = down, - = up */
-	double delta = para->scroll_dist_vert;
-	if (delta > 0 && hw->y != priv->scroll.last_y) {
-	    priv->scroll.delta_y += (hw->y - priv->scroll.last_y) / delta;
+	if (para->scroll_dist_vert > 0 && hw->y != priv->scroll.last_y) {
+	    priv->scroll.delta_y += (hw->y - priv->scroll.last_y);
 	    priv->scroll.last_y = hw->y;
 	}
     }
     if (priv->horiz_scroll_edge_on || priv->horiz_scroll_twofinger_on) {
 	/* + = right, - = left */
-	double delta = para->scroll_dist_horiz;
-	if (delta > 0 && hw->x != priv->scroll.last_x) {
-	    priv->scroll.delta_x += (hw->x - priv->scroll.last_x) / delta;
+	if (para->scroll_dist_horiz > 0 && hw->x != priv->scroll.last_x) {
+	    priv->scroll.delta_x += (hw->x - priv->scroll.last_x);
 	    priv->scroll.last_x = hw->x;
 	}
     }
@@ -2252,9 +2252,9 @@ HandleScrolling(SynapticsPrivate *priv, struct SynapticsHwState *hw,
 	double diff = diffa(priv->scroll.last_a, angle(priv, hw->x, hw->y));
 	if (delta >= 0.005 && diff != 0.0) {
 	    if (priv->circ_scroll_vert)
-		priv->scroll.delta_y += diff / delta;
+		priv->scroll.delta_y += diff / delta * para->scroll_dist_vert;
 	    else
-		priv->scroll.delta_x += diff / delta;
+		priv->scroll.delta_x += diff / delta * para->scroll_dist_horiz;;
 	    priv->scroll.last_a = angle(priv, hw->x, hw->y);
         }
     }
-- 
1.7.6.4



More information about the xorg-devel mailing list