[PATCH synaptics] Fix coasting for negative scroll directions

Chase Douglas chase.douglas at canonical.com
Wed May 2 10:03:37 PDT 2012


On 05/01/2012 05:21 PM, Peter Hutterer wrote:
> 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) {

Yes, this looks correct now.

Reviewed-by: Chase Douglas <chase.douglas at canonical.com>


More information about the xorg-devel mailing list