[PATCH libinput 05/10] touchpad: hook up scroll config

Hans de Goede hdegoede at redhat.com
Wed Jun 4 02:33:27 PDT 2014


Hi,

On 06/03/2014 07:34 AM, Peter Hutterer wrote:
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
>  src/evdev-mt-touchpad.c | 43 +++++++++++++++++++++++++++++++++++++++++++
>  src/evdev-mt-touchpad.h |  1 +
>  2 files changed, 44 insertions(+)
> 
> diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
> index 26d5f7d..c1c994a 100644
> --- a/src/evdev-mt-touchpad.c
> +++ b/src/evdev-mt-touchpad.c
> @@ -737,8 +737,51 @@ tp_init_accel(struct tp_dispatch *touchpad, double diagonal)
>  }
>  
>  static int
> +tp_config_scroll_methods(struct libinput_device *device)
> +{
> +	struct evdev_dispatch *dispatch = ((struct evdev_device *)device)->dispatch;

As with previous patches, please user container_of here for proper type checking.
Same for all the other occurrences of the same pattern below.

Otherwise this looks good.

Regards,

Hans

> +	struct tp_dispatch *tp = container_of(dispatch, tp, base);
> +
> +	return LIBINPUT_SCROLL_METHOD_TWOFINGER;
> +}
> +
> +static enum libinput_config_status
> +tp_config_scroll_set(struct libinput_device *device,
> +		     enum libinput_scroll_method method)
> +{
> +	struct evdev_dispatch *dispatch = ((struct evdev_device *)device)->dispatch;
> +	struct tp_dispatch *tp = container_of(dispatch, tp, base);
> +
> +	if (method != LIBINPUT_SCROLL_METHOD_TWOFINGER)
> +		return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
> +
> +	return LIBINPUT_CONFIG_STATUS_SUCCESS;
> +}
> +
> +static enum libinput_scroll_method
> +tp_config_scroll_get(struct libinput_device *device)
> +{
> +	struct evdev_dispatch *dispatch = ((struct evdev_device *)device)->dispatch;
> +	struct tp_dispatch *tp = container_of(dispatch, tp, base);
> +
> +	return LIBINPUT_SCROLL_METHOD_TWOFINGER;
> +}
> +
> +static void
> +tp_config_scroll_reset(struct libinput_device *device)
> +{
> +	/* two-finger scrolling is hardcoded, nothing to do */
> +}
> +
> +static int
>  tp_init_scroll(struct tp_dispatch *tp)
>  {
> +	tp->scroll.config.methods = tp_config_scroll_methods;
> +	tp->scroll.config.set = tp_config_scroll_set;
> +	tp->scroll.config.get = tp_config_scroll_get;
> +	tp->scroll.config.reset = tp_config_scroll_reset;
> +	tp->device->base.config.scroll = &tp->scroll.config;
> +
>  	tp->scroll.direction = 0;
>  	tp->scroll.state = SCROLL_STATE_NONE;
>  
> diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h
> index 0b31e9a..d89d74c 100644
> --- a/src/evdev-mt-touchpad.h
> +++ b/src/evdev-mt-touchpad.h
> @@ -195,6 +195,7 @@ struct tp_dispatch {
>  	} buttons;				/* physical buttons */
>  
>  	struct {
> +		struct libinput_device_config_scroll config;
>  		enum scroll_state state;
>  		enum libinput_pointer_axis direction;
>  	} scroll;
> 


More information about the wayland-devel mailing list