[PATCH synaptics v2 09/21] Add last_scroll_millis to track scroll event timing

Daniel Kurtz djkurtz at google.com
Tue Jun 14 23:55:13 PDT 2011


On Wed, Jun 15, 2011 at 1:05 AM, Daniel Stone <daniel at fooishbar.org> wrote:
> From: Derek Foreman <derek.foreman at collabora.co.uk>
>
> Stopping a little short of having a full scroll history, adding
> last_scroll_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    |   14 +++++++++-----
>  src/synapticsstr.h |    1 +
>  2 files changed, 10 insertions(+), 5 deletions(-)
>
> v2: Include HandleScrolling hunks which inexplicably crept into another patch
>    in the series.
>
> diff --git a/src/synaptics.c b/src/synaptics.c
> index 95faa42..c14dbf8 100644
> --- a/src/synaptics.c
> +++ b/src/synaptics.c
> @@ -1754,7 +1754,7 @@ get_delta_for_trackstick(SynapticsPrivate *priv, const struct SynapticsHwState *
>                          double *dx, double *dy)
>  {
>     SynapticsParameters *para = &priv->synpara;
> -    double dtime = (hw->millis - HIST(0).millis) / 1000.0;
> +    double dtime = (hw->millis - priv->last_scroll_millis) / 1000.0;

Will this cause giant random jump at the beginning of the first
scroll, since last_scroll_millis is uninitialized, or at every
subsequent 'new' scroll, since last_scroll_millis still holds the time
of some ancient scroll?

Maybe I'm missing something?

>
>     *dx = (hw->x - priv->trackstick_neutral_x);
>     *dy = (hw->y - priv->trackstick_neutral_y);
> @@ -1809,7 +1809,7 @@ get_delta(SynapticsPrivate *priv, const struct SynapticsHwState *hw,
>           edge_type edge, double *dx, double *dy)
>  {
>     SynapticsParameters *para = &priv->synpara;
> -    double dtime = (hw->millis - HIST(0).millis) / 1000.0;
> +    double dtime = (hw->millis - priv->last_scroll_millis) / 1000.0;
>     double integral;
>     double tmpf;
>     int x_edge_speed = 0;
> @@ -2215,7 +2215,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->last_scroll_millis) / 1000.0;
>        double ddy = para->coasting_friction * dtime;
>        priv->autoscroll_y += priv->autoscroll_yspd * dtime;
>        delay = MIN(delay, POLL_MS);
> @@ -2236,7 +2236,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->last_scroll_millis) / 1000.0;
>        double ddx = para->coasting_friction * dtime;
>        priv->autoscroll_x += priv->autoscroll_xspd * dtime;
>        delay = MIN(delay, POLL_MS);
> @@ -2600,8 +2600,12 @@ HandleState(InputInfoPtr pInfo, struct SynapticsHwState *hw)
>     /* 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->last_scroll_millis = hw->millis;
> +    }
>
>     if (double_click) {
>        post_button_click(pInfo, 1);
> diff --git a/src/synapticsstr.h b/src/synapticsstr.h
> index 6a54455..b65069f 100644
> --- a/src/synapticsstr.h
> +++ b/src/synapticsstr.h
> @@ -220,6 +220,7 @@ typedef struct _SynapticsPrivateRec
>     double autoscroll_x;               /* Accumulated horizontal coasting scroll */
>     double autoscroll_y;               /* Accumulated vertical coasting scroll */
>     int scroll_packet_count;           /* Scroll duration */
> +    unsigned long last_scroll_millis;   /* time last scroll event posted */
>     double frac_x, frac_y;             /* absolute -> relative fraction */
>     enum MidButtonEmulation mid_emu_state;     /* emulated 3rd button */
>     int repeatButtons;                 /* buttons for repeat */
> --
> 1.7.5.3
>
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
>


More information about the xorg-devel mailing list