[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
Mon Feb 6 00:36:56 UTC 2017


On Sun, Feb 05, 2017 at 07:30:18PM -0500, Jiayi Zhao wrote:
> ​​
> Hmmm, after using udev_device_has_tag(udev_device, "ID_INPUT_TOUCHPAD"),
> I'm getting linking errors. Quick google of this leads to: libraries on the
> command line should be after the object files being compiled.
> Is this a bug?

come to think of it, tags are a bit different. you need
udev_device_get_property_value() instead. and you need to make sure that
libudev is linked in - that's where your linking errors come from.

Cheers,
   Peter

> 
> On Sun, Feb 5, 2017 at 7:20 PM, Peter Hutterer <peter.hutterer at who-t.net>
> wrote:
> 
> > On Sun, Feb 05, 2017 at 07:13:04PM -0500, Jiayi Zhao wrote:
> > > How would ID_INPUT_TOUCHPAD work?
> > > I have something like udev_device_has_tag(udev_device,
> > ID_INPUT_TOUCHPAD)
> > > Unfortunately, I'm not sure where this constant is declared and its
> > unable
> > > to find the tag. :/
> >
> > it's a udev property name, so use it as a string, not a #define.
> > value is either 1 or 0, so you do need to check for validity.
> >
> > Cheers,
> >    Peter
> >
> > > On Jan 29, 2017 4:42 PM, "Peter Hutterer" <peter.hutterer at who-t.net>
> > wrote:
> > >
> > > > 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