[PATCH] [weston] weston.ini: Add natural scroll support to weston.ini

Peter Hutterer peter.hutterer at who-t.net
Sun Oct 23 21:50:48 UTC 2016


On Sat, Oct 22, 2016 at 12:23:40PM -0400, Jiayi Zhao wrote:
> Hmm,
> 
> it says here that
> 
> libinput_device_config_scroll_has_natural_scroll()
> 
> returns a zero value if device does not support natural scrolling
> 
> and returns a non-zero value if it does support natural scrolling:
> 
> https://wayland.freedesktop.org/libinput/doc/latest/group__config.html#ga82d1aa961d2bb2f0c72c22e2441a4fc3
> 
> So I don't really know how I else I can program it.

just use

    if (libinput_device_config_scroll_has_natural_scroll())
        do stuff


instead of the current

    if (libinput_device_config_scroll_has_natural_scroll() != 0)
        do stuff

Cheers,
   Peter

> 
> On Oct 20, 2016 9:05 PM, "Peter Hutterer" <peter.hutterer at who-t.net> wrote:
> 
> >
> 
> > >
> 
> > On Thu, Oct 20, 2016 at 08:43:18PM -0400, Jiayi Zhao wrote:
> > > This adds support for enabling/disabling natural scrolling
> > > via a boolean in weston.ini:
> > >
> > > [libinput]
> > > natural_scroll=true
> > >
> > > Signed-off-by: Jiayi Zhao <jeff.no.zhao at gmail.com>
> > > ---
> > >  compositor/main.c | 13 +++++++++++++
> > >  weston.ini.in     |  1 +
> > >  2 files changed, 14 insertions(+)
> > >
> > > diff --git a/compositor/main.c b/compositor/main.c
> > > index 8028ec3..6cd2a25 100644
> > > --- a/compositor/main.c
> > > +++ b/compositor/main.c
> > > @@ -1095,6 +1095,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);
> > > @@ -1109,6 +1111,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) !=
> 0) {
> >
> > libinput's *_has_* API is designed to return a boolean value, IMO you
> > shouldn't use the != 0 here.
> >
> > > +             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);
> > > +     }
> > >  }
> > >
> > >  static void
> > > diff --git a/weston.ini.in b/weston.ini.in
> > > index 14a4c0c..08f931a 100644
> > > --- a/weston.ini.in
> > > +++ b/weston.ini.in
> > > @@ -59,6 +59,7 @@ path=@libexecdir@/weston-keyboard
> > >
> > >  #[libinput]
> > >  #enable_tap=true
> > > +#natural_scroll=false
> >
> > "enable_natural_scroll" is more precise
> >
> > these are just nitpicks, the code itself looks fine, thanks.
> >
> > Cheers,
> >    Peter
> >
> > >
> > >  #[touchpad]
> > >  #constant_accel_factor = 50
> > > --
> > > 2.7.3


More information about the wayland-devel mailing list