[PATCH v2] dix: fix device scaling to use a [min,max[ range.

Peter Hutterer peter.hutterer at who-t.net
Fri Apr 26 00:16:54 PDT 2013


On Fri, Apr 26, 2013 at 03:28:31PM +1000, Peter Hutterer wrote:
> defmin/defmax are screen coords and thus use a min-inclusive, max-exclusive
> range. device axes ranges are inclusive, so bump the max up by one to get the
> scaling right.
> 
> This fixes off-by-one coordinate errors if the coordinate matrix is used to
> bind the device to a fraction of the screen.
> 
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
> This patch replaces:
>   dix: use the right range in positionSprite
>   dix: the input matrix must work on pixels, not device ranges

.. and it's still not correct as the XI valuators are off now.

Cheers,
   Peter

> 
>  dix/devices.c   | 4 ++--
>  dix/getevents.c | 8 ++++----
>  2 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/dix/devices.c b/dix/devices.c
> index fa94a94..7b423de 100644
> --- a/dix/devices.c
> +++ b/dix/devices.c
> @@ -112,8 +112,8 @@ DeviceSetTransform(DeviceIntPtr dev, float *transform_data)
>       *  Transform is the user supplied (affine) transform
>       *  InvScale scales coordinates back up into their native range
>       */
> -    sx = dev->valuator->axes[0].max_value - dev->valuator->axes[0].min_value;
> -    sy = dev->valuator->axes[1].max_value - dev->valuator->axes[1].min_value;
> +    sx = dev->valuator->axes[0].max_value - dev->valuator->axes[0].min_value + 1;
> +    sy = dev->valuator->axes[1].max_value - dev->valuator->axes[1].min_value + 1;
>  
>      /* invscale */
>      pixman_f_transform_init_scale(&scale, sx, sy);
> diff --git a/dix/getevents.c b/dix/getevents.c
> index a4f192c..f946e0a 100644
> --- a/dix/getevents.c
> +++ b/dix/getevents.c
> @@ -297,11 +297,11 @@ rescaleValuatorAxis(double coord, AxisInfoPtr from, AxisInfoPtr to,
>  
>      if (from && from->min_value < from->max_value) {
>          fmin = from->min_value;
> -        fmax = from->max_value;
> +        fmax = from->max_value + 1;
>      }
>      if (to && to->min_value < to->max_value) {
>          tmin = to->min_value;
> -        tmax = to->max_value;
> +        tmax = to->max_value + 1;
>      }
>  
>      if (fmin == tmin && fmax == tmax)
> @@ -913,9 +913,9 @@ scale_to_desktop(DeviceIntPtr dev, ValuatorMask *mask,
>  
>      /* scale x&y to desktop coordinates */
>      *screenx = rescaleValuatorAxis(x, dev->valuator->axes + 0, NULL,
> -                                   screenInfo.x, screenInfo.width - 1);
> +                                   screenInfo.x, screenInfo.width);
>      *screeny = rescaleValuatorAxis(y, dev->valuator->axes + 1, NULL,
> -                                   screenInfo.y, screenInfo.height - 1);
> +                                   screenInfo.y, screenInfo.height);
>  
>      *devx = x;
>      *devy = y;
> -- 
> 1.8.1.4
> 


More information about the xorg-devel mailing list