[PATCH libinput 1/2] evdev: Safe x and y resolution for later use

Peter Hutterer peter.hutterer at who-t.net
Wed Jun 18 17:17:50 PDT 2014


On Wed, Jun 18, 2014 at 02:22:23PM +0200, Hans de Goede wrote:
> Signed-off-by: Hans de Goede <hdegoede at redhat.com>
> ---
>  src/evdev.c | 2 ++
>  src/evdev.h | 2 +-
>  2 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/src/evdev.c b/src/evdev.c
> index 51ad5e3..b72e5e1 100644
> --- a/src/evdev.c
> +++ b/src/evdev.c
> @@ -608,11 +608,13 @@ evdev_configure_device(struct evdev_device *device)
>  		if ((absinfo = libevdev_get_abs_info(evdev, ABS_X))) {
>  			device->abs.min_x = absinfo->minimum;
>  			device->abs.max_x = absinfo->maximum;
> +			device->abs.res_x = absinfo->resolution;
>  			has_abs = 1;
>  		}
>  		if ((absinfo = libevdev_get_abs_info(evdev, ABS_Y))) {
>  			device->abs.min_y = absinfo->minimum;
>  			device->abs.max_y = absinfo->maximum;
> +			device->abs.res_y = absinfo->resolution;

This came up in the tablet branch when testing: the resolution of a device
_may_ be 0. I don't know how many devices with ABS_X/Y still have zero, but
especially when testing with uinput devices it always is. uinput currently
doesn't let you set the resolution, the kernel patch to fix this stalled a
while ago and needs someone motivated to pick it up again :)

so I think it'd be safer to force the resolution to 1, prevents a couple of
mathematical surprises lateron.

Cheers,
   Peter

PS: "save", not "safe" in the commit msg, except for when saving 1 is
safe :)


>  			has_abs = 1;
>  		}
>                  /* We only handle the slotted Protocol B in weston.
> diff --git a/src/evdev.h b/src/evdev.h
> index d057010..2db990f 100644
> --- a/src/evdev.h
> +++ b/src/evdev.h
> @@ -66,7 +66,7 @@ struct evdev_device {
>  	const char *devname;
>  	int fd;
>  	struct {
> -		int min_x, max_x, min_y, max_y;
> +		int min_x, max_x, min_y, max_y, res_x, res_y;
>  		int32_t x, y;
>  
>  		int32_t seat_slot;
> -- 
> 2.0.0


More information about the wayland-devel mailing list