[PATCH libinput 1/3] Add a configuration option for natural scrolling
Hans de Goede
hdegoede at redhat.com
Thu Sep 18 23:59:12 PDT 2014
Hi,
On 09/19/2014 01:01 AM, Peter Hutterer wrote:
> Natural scrolling is simply inverted scrolling, but I decided to
> use the Apple terminology simply because it's easier to google for.
>
> Add the usual quartett of config options for has/set/get/get_default/, as a
> boolean option rather than an enum for scroll mode to avoid name collusion
> with the (currently in the works) edge scrolling.
>
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
Set looks good, and is:
Reviewed-by: Hans de Goede <hdegoede at redhat.com>
Regards,
Hans
> ---
> src/libinput-private.h | 9 ++++++
> src/libinput.c | 37 +++++++++++++++++++++++
> src/libinput.h | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 127 insertions(+)
>
> diff --git a/src/libinput-private.h b/src/libinput-private.h
> index cf03c03..1946cf4 100644
> --- a/src/libinput-private.h
> +++ b/src/libinput-private.h
> @@ -109,10 +109,19 @@ struct libinput_device_config_send_events {
> enum libinput_config_send_events_mode (*get_default_mode)(struct libinput_device *device);
> };
>
> +struct libinput_device_config_natural_scroll {
> + int (*has)(struct libinput_device *device);
> + enum libinput_config_status (*set_enabled)(struct libinput_device *device,
> + int enabled);
> + int (*get_enabled)(struct libinput_device *device);
> + int (*get_default_enabled)(struct libinput_device *device);
> +};
> +
> struct libinput_device_config {
> struct libinput_device_config_tap *tap;
> struct libinput_device_config_calibration *calibration;
> struct libinput_device_config_send_events *sendevents;
> + struct libinput_device_config_natural_scroll *natural_scroll;
> };
>
> struct libinput_device {
> diff --git a/src/libinput.c b/src/libinput.c
> index 14f0257..e9dae3f 100644
> --- a/src/libinput.c
> +++ b/src/libinput.c
> @@ -1388,3 +1388,40 @@ libinput_device_config_send_events_get_default_mode(struct libinput_device *devi
> {
> return LIBINPUT_CONFIG_SEND_EVENTS_ENABLED;
> }
> +
> +LIBINPUT_EXPORT int
> +libinput_device_config_scroll_has_natural_scroll(struct libinput_device *device)
> +{
> + if (!device->config.natural_scroll)
> + return 0;
> +
> + return device->config.natural_scroll->has(device);
> +}
> +
> +LIBINPUT_EXPORT enum libinput_config_status
> +libinput_device_config_scroll_set_natural_scroll_enabled(struct libinput_device *device,
> + int enabled)
> +{
> + if (!libinput_device_config_scroll_has_natural_scroll(device))
> + return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
> +
> + return device->config.natural_scroll->set_enabled(device, enabled);
> +}
> +
> +LIBINPUT_EXPORT int
> +libinput_device_config_scroll_get_natural_scroll_enabled(struct libinput_device *device)
> +{
> + if (!device->config.natural_scroll)
> + return 0;
> +
> + return device->config.natural_scroll->get_enabled(device);
> +}
> +
> +LIBINPUT_EXPORT int
> +libinput_device_config_scroll_get_default_natural_scroll_enabled(struct libinput_device *device)
> +{
> + if (!device->config.natural_scroll)
> + return 0;
> +
> + return device->config.natural_scroll->get_default_enabled(device);
> +}
> diff --git a/src/libinput.h b/src/libinput.h
> index 806e1ab..393c927 100644
> --- a/src/libinput.h
> +++ b/src/libinput.h
> @@ -1783,6 +1783,87 @@ libinput_device_config_send_events_get_mode(struct libinput_device *device);
> enum libinput_config_send_events_mode
> libinput_device_config_send_events_get_default_mode(struct libinput_device *device);
>
> +/**
> + * @ingroup config
> + *
> + * Return non-zero if the device supports "natural scrolling".
> + *
> + * In traditional scroll mode, the movement of fingers on a touchpad when
> + * scrolling matches the movement of the scroll bars. When the fingers move
> + * down, the scroll bar moves down, a line of text on the screen moves
> + * towards the upper end of the screen. This also matches scroll wheels on
> + * mice (wheel down, content moves up).
> + *
> + * Natural scrolling is the term coined by Apple for inverted scrolling.
> + * In this mode, the effect of scrolling movement of fingers on a touchpad
> + * resemble physical manipulation of paper. When the fingers move down, a
> + * line of text on the screen moves down (scrollbars move up). This is the
> + * opposite of scroll wheels on mice.
> + *
> + * A device supporting natural scrolling can be switched between traditional
> + * scroll mode and natural scroll mode.
> + *
> + * @param device The device to configure
> + *
> + * @return 0 if natural scrolling is not supported, non-zero if natural
> + * scrolling is supported by this device
> + *
> + * @see libinput_device_config_set_natural_scroll_enabled
> + * @see libinput_device_config_get_natural_scroll_enabled
> + * @see libinput_device_config_get_default_natural_scroll_enabled
> + */
> +int
> +libinput_device_config_scroll_has_natural_scroll(struct libinput_device *device);
> +
> +/**
> + * @ingroup config
> + *
> + * Enable or disable natural scrolling on the device.
> + *
> + * @param device The device to configure
> + * @param enable non-zero to enable, zero to disable natural scrolling
> + *
> + * @return a config status code
> + *
> + * @see libinput_device_config_has_natural_scroll
> + * @see libinput_device_config_get_natural_scroll_enabled
> + * @see libinput_device_config_get_default_natural_scroll_enabled
> + */
> +enum libinput_config_status
> +libinput_device_config_scroll_set_natural_scroll_enabled(struct libinput_device *device,
> + int enable);
> +/**
> + * @ingroup config
> + *
> + * Get the current mode for scrolling on this device
> + *
> + * @param device The device to configure
> + *
> + * @return zero if natural scrolling is disabled, non-zero if enabled
> + *
> + * @see libinput_device_config_has_natural_scroll
> + * @see libinput_device_config_set_natural_scroll_enabled
> + * @see libinput_device_config_get_default_natural_scroll_enabled
> + */
> +int
> +libinput_device_config_scroll_get_natural_scroll_enabled(struct libinput_device *device);
> +
> +/**
> + * @ingroup config
> + *
> + * Get the default mode for scrolling on this device
> + *
> + * @param device The device to configure
> + *
> + * @return zero if natural scrolling is disabled by default, non-zero if enabled
> + *
> + * @see libinput_device_config_has_natural_scroll
> + * @see libinput_device_config_set_natural_scroll_enabled
> + * @see libinput_device_config_get_natural_scroll_enabled
> + */
> +int
> +libinput_device_config_scroll_get_default_natural_scroll_enabled(struct libinput_device *device);
> +
> #ifdef __cplusplus
> }
> #endif
>
More information about the wayland-devel
mailing list