[PATCH synaptics] Fix coasting for negative scroll directions

Peter Hutterer peter.hutterer at who-t.net
Tue May 1 17:21:27 PDT 2012


1874094f0e99d8db319f6cf769ce5a25c9bc490c introduced negative scroll
directions. Coasting assumed always-positive increments and triggered an
endless scrolling loop.

Reported-by: Matthias Clasen <mclasen at redhat.com>
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/synaptics.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/synaptics.c b/src/synaptics.c
index 6dc8004..77eb5be 100644
--- a/src/synaptics.c
+++ b/src/synaptics.c
@@ -2625,7 +2625,8 @@ HandleScrolling(SynapticsPrivate *priv, struct SynapticsHwState *hw,
 
     if (priv->scroll.coast_speed_y) {
 	double dtime = (hw->millis - priv->scroll.last_millis) / 1000.0;
-	double ddy = para->coasting_friction * dtime * para->scroll_dist_vert;
+	double ddy = para->coasting_friction * dtime * abs(para->scroll_dist_vert);
+
 	priv->scroll.delta_y += priv->scroll.coast_speed_y * dtime;
 	delay = MIN(delay, POLL_MS);
 	if (abs(priv->scroll.coast_speed_y) < ddy) {
@@ -2638,7 +2639,7 @@ HandleScrolling(SynapticsPrivate *priv, struct SynapticsHwState *hw,
 
     if (priv->scroll.coast_speed_x) {
 	double dtime = (hw->millis - priv->scroll.last_millis) / 1000.0;
-	double ddx = para->coasting_friction * dtime * para->scroll_dist_horiz;
+	double ddx = para->coasting_friction * dtime * abs(para->scroll_dist_horiz);
 	priv->scroll.delta_x += priv->scroll.coast_speed_x * dtime;
 	delay = MIN(delay, POLL_MS);
 	if (abs(priv->scroll.coast_speed_x) < ddx) {
-- 
1.7.10



More information about the xorg-devel mailing list