[PATCH] [weston, v4] weston.ini: Add natural scroll support to weston.ini This adds support for enabling/disabling natural scrolling via a boolean in weston.ini:

Peter Hutterer peter.hutterer at who-t.net
Sun Jan 29 21:42:34 UTC 2017


On Fri, Jan 27, 2017 at 09:46:49PM -0500, Jiayi Zhao wrote:
> [libinput]
> natural_scroll=true
> 
> CHANGES:
>  - libinput_device_config_scroll_has_natural_scroll() is no longer compared to != 0
>  - added configuration option to weston.ini man page
> 
> Signed-off-by: Jiayi Zhao <jeff.no.zhao at gmail.com>
> ---
>  compositor/main.c  | 13 +++++++++++++
>  man/weston.ini.man |  3 +++
>  weston.ini.in      |  1 +
>  3 files changed, 17 insertions(+)
> 
> diff --git a/compositor/main.c b/compositor/main.c
> index 4bd6e68..84bb8dd 100644
> --- a/compositor/main.c
> +++ b/compositor/main.c
> @@ -1133,6 +1133,8 @@ configure_input_device(struct weston_compositor *compositor,
>  	struct weston_config *config = wet_get_config(compositor);
>  	int enable_tap;
>  	int enable_tap_default;
> +	int natural_scroll;
> +	int natural_scroll_default;
>  
>  	s = weston_config_get_section(config,
>  				      "libinput", NULL, NULL);
> @@ -1147,6 +1149,17 @@ configure_input_device(struct weston_compositor *compositor,
>  		libinput_device_config_tap_set_enabled(device,
>  						       enable_tap);
>  	}
> +
> +	if (libinput_device_config_scroll_has_natural_scroll(device)) {
> +		natural_scroll_default =
> +			libinput_device_config_scroll_get_default_natural_scroll_enabled(
> +				device);
> +		weston_config_section_get_bool(s, "natural_scroll",
> +						&natural_scroll,
> +						natural_scroll_default);
> +		libinput_device_config_scroll_set_natural_scroll_enabled(device,
> +							natural_scroll);
> +	}

libinput exposes natural scrolling on mice as well and with this code
you're enabling it on any device that has the option. so your mouse
wheels will be upside down too when you enable this. That's probably not
what you intended, but if so, prepare for angry emails :)

there are two options to work around this:
* check the udev device for ID_INPUT_TOUCHPAD 
* assume anything that has tapping is a touchpad

Cheers,
   Peter

>  }
>  
>  static void
> diff --git a/man/weston.ini.man b/man/weston.ini.man
> index 2edb085..62e0f92 100644
> --- a/man/weston.ini.man
> +++ b/man/weston.ini.man
> @@ -187,6 +187,9 @@ Available configuration are:
>  .TP 7
>  .BI "enable_tap=" true
>  enables tap to click on touchpad devices
> +.TP 7
> +.BI "natural_scroll=" true
> +enables natural scrolling on touchpad devices
>  .RS
>  .PP
>  
> diff --git a/weston.ini.in b/weston.ini.in
> index 257c4ec..f957ec6 100644
> --- a/weston.ini.in
> +++ b/weston.ini.in
> @@ -61,6 +61,7 @@ path=@libexecdir@/weston-keyboard
>  
>  #[libinput]
>  #enable_tap=true
> +#natural_scroll=false
>  
>  #[touchpad]
>  #constant_accel_factor = 50
> -- 
> 2.10.2
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/wayland-devel
> 


More information about the wayland-devel mailing list