[PATCH libinput 04/10] Add a config interface for scroll methods

Hans de Goede hdegoede at redhat.com
Wed Jun 4 02:31:52 PDT 2014


Hi,

On 06/03/2014 07:34 AM, Peter Hutterer wrote:
> ---
>  src/libinput-private.h |  9 ++++++
>  src/libinput.c         | 35 ++++++++++++++++++++++++
>  src/libinput.h         | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 118 insertions(+)
> 

Looks good to me.

Regards,

Hans

> diff --git a/src/libinput-private.h b/src/libinput-private.h
> index 020167e..d3570a4 100644
> --- a/src/libinput-private.h
> +++ b/src/libinput-private.h
> @@ -77,8 +77,17 @@ struct libinput_device_config_tap {
>  	void (*reset)(struct libinput_device *device);
>  };
>  
> +struct libinput_device_config_scroll {
> +	int (*methods)(struct libinput_device *device);
> +	enum libinput_config_status (*set)(struct libinput_device *device,
> +					   enum libinput_scroll_method method);
> +	enum libinput_scroll_method (*get)(struct libinput_device *device);
> +	void (*reset)(struct libinput_device *device);
> +};
> +
>  struct libinput_device_config {
>  	struct libinput_device_config_tap *tap;
> +	struct libinput_device_config_scroll *scroll;
>  };
>  
>  struct libinput_device {
> diff --git a/src/libinput.c b/src/libinput.c
> index 6a713bb..b2388e6 100644
> --- a/src/libinput.c
> +++ b/src/libinput.c
> @@ -1215,3 +1215,38 @@ libinput_device_config_tap_reset(struct libinput_device *device)
>  	if (device->config.tap)
>  		device->config.tap->reset(device);
>  }
> +
> +LIBINPUT_EXPORT unsigned int
> +libinput_device_config_scroll_get_methods(struct libinput_device *device)
> +{
> +	return device->config.scroll ?
> +			device->config.scroll->methods(device) :
> +			LIBINPUT_SCROLL_METHOD_NONE;
> +}
> +
> +LIBINPUT_EXPORT enum libinput_config_status
> +libinput_device_config_scroll_set_method(struct libinput_device *device,
> +					 enum libinput_scroll_method method)
> +{
> +	if ((method & libinput_device_config_scroll_get_methods(device)) == 0)
> +		return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
> +
> +	return device->config.scroll->set(device, method);
> +}
> +
> +LIBINPUT_EXPORT enum libinput_scroll_method
> +libinput_device_config_scroll_get_method(struct libinput_device *device)
> +{
> +	if (libinput_device_config_scroll_get_methods(device) ==
> +	    LIBINPUT_SCROLL_METHOD_NONE)
> +		return LIBINPUT_SCROLL_METHOD_NONE;
> +
> +	return device->config.scroll->get(device);
> +}
> +
> +LIBINPUT_EXPORT void
> +libinput_device_config_scroll_reset(struct libinput_device *device)
> +{
> +	if (device->config.scroll)
> +		device->config.scroll->reset(device);
> +}
> diff --git a/src/libinput.h b/src/libinput.h
> index 0c84547..571f7ba 100644
> --- a/src/libinput.h
> +++ b/src/libinput.h
> @@ -1434,6 +1434,80 @@ libinput_device_config_tap_is_enabled(struct libinput_device *device);
>  void
>  libinput_device_config_tap_reset(struct libinput_device *device);
>  
> +/**
> + * @ingroup config
> + *
> + * Devices without a physical scroll wheel (such as touchpads) may emulate
> + * scroll events in software through one or more methods.
> + */
> +enum libinput_scroll_method {
> +	/**
> +	 * No scroll method available or selected.
> +	 */
> +	LIBINPUT_SCROLL_METHOD_NONE = 0,
> +	/**
> +	 * Scrolling is triggered by moving a finger at the edge of the
> +	 * touchpad.
> +	 */
> +	LIBINPUT_SCROLL_METHOD_EDGE = (1 << 0),
> +	/**
> +	 * Scrolling is triggered by moving two fingers simultaneously.
> +	 */
> +	LIBINPUT_SCROLL_METHOD_TWOFINGER = (1 << 1),
> +};
> +
> +/**
> + * @ingroup config
> + *
> + * Check the available scroll methods on this device.
> + *
> + * @param device The device to configure
> + *
> + * @return A bitmask of the available scroll methods
> + */
> +unsigned int
> +libinput_device_config_scroll_get_methods(struct libinput_device *device);
> +
> +/**
> + * @ingroup config
> + *
> + * Set the scroll method on this device. Only one method at a time may be
> + * chosen for each device.
> + *
> + * @param device The device to configure
> + * @param method The scroll method to chose
> + *
> + * @return A config status code
> + */
> +enum libinput_config_status
> +libinput_device_config_scroll_set_method(struct libinput_device *device,
> +					 enum libinput_scroll_method method);
> +
> +/**
> + * @ingroup config
> + *
> + * Get the currently selected scroll method on this device. If a device does
> + * not support configurable scroll methods, the return value is always
> + * LIBINPUT_SCROLL_METHOD_NONE.
> + *
> + * @param device The device to configure
> + *
> + * @return The currently selected scroll method
> + */
> +enum libinput_scroll_method
> +libinput_device_config_scroll_get_method(struct libinput_device *device);
> +
> +/**
> + * @ingroup config
> + *
> + * Reset to the default scroll method for this device, if any. If the device
> + * does not support configurable scroll methods this function does nothing.
> + *
> + * @param device The device to configure
> + */
> +void
> +libinput_device_config_scroll_reset(struct libinput_device *device);
> +
>  #ifdef __cplusplus
>  }
>  #endif
> 


More information about the wayland-devel mailing list