[PATCH v3 19/23] Scroll: Add last_millis to track scroll event timing

Daniel Stone daniel at fooishbar.org
Thu Jun 23 15:12:54 PDT 2011


From: Derek Foreman <derek.foreman at collabora.co.uk>

Stopping a little short of having a full scroll history, adding
last_millis lets us track when the last scroll event we sent was,
for more accurate timing of coasting in particular.

Signed-off-by: Derek Foreman <derek.foreman at collabora.co.uk>
Reviewed-by: Daniel Stone <daniel at fooishbar.org>
Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/synaptics.c    |   10 +++++++---
 src/synapticsstr.h |    1 +
 2 files changed, 8 insertions(+), 3 deletions(-)

v3: Removed get_delta() and get_delta_from_trackstick() hunks, so we now only
    use this for coasting.
    Fixed indentation.
    Changed last_millis to CARD32.

diff --git a/src/synaptics.c b/src/synaptics.c
index eae6114..4bdd2c0 100644
--- a/src/synaptics.c
+++ b/src/synaptics.c
@@ -2334,7 +2334,7 @@ HandleScrolling(SynapticsPrivate *priv, struct SynapticsHwState *hw,
     }
 
     if (priv->autoscroll_yspd) {
-	double dtime = (hw->millis - HIST(0).millis) / 1000.0;
+	double dtime = (hw->millis - priv->scroll.last_millis) / 1000.0;
 	double ddy = para->coasting_friction * dtime;
 	priv->autoscroll_y += priv->autoscroll_yspd * dtime;
 	delay = MIN(delay, POLL_MS);
@@ -2355,7 +2355,7 @@ HandleScrolling(SynapticsPrivate *priv, struct SynapticsHwState *hw,
     }
 
     if (priv->autoscroll_xspd) {
-	double dtime = (hw->millis - HIST(0).millis) / 1000.0;
+	double dtime = (hw->millis - priv->scroll.last_millis) / 1000.0;
 	double ddx = para->coasting_friction * dtime;
 	priv->autoscroll_x += priv->autoscroll_xspd * dtime;
 	delay = MIN(delay, POLL_MS);
@@ -2733,8 +2733,12 @@ HandleState(InputInfoPtr pInfo, struct SynapticsHwState *hw, CARD32 now,
     /* Process scroll events only if coordinates are
      * in the Synaptics Area
      */
-    if (inside_active_area)
+    if (inside_active_area &&
+        (scroll.down != 0 || scroll.up != 0 || scroll.left != 0 ||
+         scroll.right != 0)) {
 	post_scroll_events(pInfo, scroll);
+	priv->scroll.last_millis = hw->millis;
+    }
 
     if (double_click) {
 	post_button_click(pInfo, 1);
diff --git a/src/synapticsstr.h b/src/synapticsstr.h
index ac25889..f68b3fc 100644
--- a/src/synapticsstr.h
+++ b/src/synapticsstr.h
@@ -203,6 +203,7 @@ typedef struct _SynapticsPrivateRec
         int last_x;			/* last x-scroll position */
         int last_y;			/* last y-scroll position */
         double last_a;			/* last angle-scroll position */
+        CARD32 last_millis;		/* time last scroll event posted */
     } scroll;
     int count_packet_finger;		/* packet counter with finger on the touchpad */
     int button_delay_millis;		/* button delay for 3rd button emulation */
-- 
1.7.5.4



More information about the xorg-devel mailing list