On Thu, Nov 06, 2014 at 04:37:36PM +0100, Hans de Goede wrote: > Default to 2fg scrolling for now, once we have edge-scrolling we can default > to edge-scrolling on touchpads which cannot detect more then 1 touch.
s/then/than/ > > Signed-off-by: Hans de Goede <hdego...@redhat.com> > --- > src/evdev-mt-touchpad.c | 63 > ++++++++++++++++++++++++++++++++++++++++++++++--- > src/evdev-mt-touchpad.h | 2 ++ > 2 files changed, 62 insertions(+), 3 deletions(-) > > diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c > index 67bbf96..b02f1a3 100644 > --- a/src/evdev-mt-touchpad.c > +++ b/src/evdev-mt-touchpad.c > @@ -508,6 +508,9 @@ tp_post_scroll_events(struct tp_dispatch *tp, uint64_t > time) > struct tp_touch *t; > int nfingers_down = 0; > > + if (tp->scroll.mode != LIBINPUT_CONFIG_SCROLL_2FG) > + return 0; > + > /* No scrolling during tap-n-drag */ > if (tp_tap_dragging(tp)) > return 0; > @@ -945,6 +948,53 @@ tp_scroll_config_natural_get_default(struct > libinput_device *device) > return 0; > } > > +static uint32_t > +tp_scroll_config_scroll_mode_get_modes(struct libinput_device *device) > +{ > + struct evdev_device *evdev = (struct evdev_device*)device; > + struct tp_dispatch *tp = (struct tp_dispatch*)evdev->dispatch; > + uint32_t modes = LIBINPUT_CONFIG_SCROLL_NO_SCROLL; > + > + if (tp->ntouches >= 2) > + modes |= LIBINPUT_CONFIG_SCROLL_2FG; > + > + if (!tp->buttons.is_clickpad) > + modes |= LIBINPUT_CONFIG_SCROLL_EDGE; better to set this when edge scrolling is added. Cheers, Peter > + > + return modes; > +} > + > +static enum libinput_config_status > +tp_scroll_config_scroll_mode_set_mode(struct libinput_device *device, > + enum libinput_config_scroll_mode mode) > +{ > + struct evdev_device *evdev = (struct evdev_device*)device; > + struct tp_dispatch *tp = (struct tp_dispatch*)evdev->dispatch; > + > + if (mode == tp->scroll.mode) > + return LIBINPUT_CONFIG_STATUS_SUCCESS; > + > + evdev_stop_scroll(evdev, libinput_now(device->seat->libinput)); > + tp->scroll.mode = mode; > + > + return LIBINPUT_CONFIG_STATUS_SUCCESS; > +} > + > +static enum libinput_config_scroll_mode > +tp_scroll_config_scroll_mode_get_mode(struct libinput_device *device) > +{ > + struct evdev_device *evdev = (struct evdev_device*)device; > + struct tp_dispatch *tp = (struct tp_dispatch*)evdev->dispatch; > + > + return tp->scroll.mode; > +} > + > +static enum libinput_config_scroll_mode > +tp_scroll_config_scroll_mode_get_default_mode(struct libinput_device *device) > +{ > + return LIBINPUT_CONFIG_SCROLL_2FG; > +} > + > static int > tp_init_scroll(struct tp_dispatch *tp) > { > @@ -956,6 +1006,13 @@ tp_init_scroll(struct tp_dispatch *tp) > tp->scroll.natural_scrolling_enabled = false; > tp->device->base.config.natural_scroll = &tp->scroll.config_natural; > > + tp->scroll.config_mode.get_modes = > tp_scroll_config_scroll_mode_get_modes; > + tp->scroll.config_mode.set_mode = tp_scroll_config_scroll_mode_set_mode; > + tp->scroll.config_mode.get_mode = tp_scroll_config_scroll_mode_get_mode; > + tp->scroll.config_mode.get_default_mode = > tp_scroll_config_scroll_mode_get_default_mode; > + tp->scroll.mode = > tp_scroll_config_scroll_mode_get_default_mode(&tp->device->base); > + tp->device->base.config.scroll_mode = &tp->scroll.config_mode; > + > return 0; > } > > @@ -1024,9 +1081,6 @@ tp_init(struct tp_dispatch *tp, > tp->hysteresis.margin_y = > diagonal / DEFAULT_HYSTERESIS_MARGIN_DENOMINATOR; > > - if (tp_init_scroll(tp) != 0) > - return -1; > - > if (tp_init_accel(tp, diagonal) != 0) > return -1; > > @@ -1042,6 +1096,9 @@ tp_init(struct tp_dispatch *tp, > if (tp_init_sendevents(tp, device) != 0) > return -1; > > + if (tp_init_scroll(tp) != 0) > + return -1; > + > device->seat_caps |= EVDEV_DEVICE_POINTER; > > return 0; > diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h > index baa51a3..4d7b8a9 100644 > --- a/src/evdev-mt-touchpad.h > +++ b/src/evdev-mt-touchpad.h > @@ -203,7 +203,9 @@ struct tp_dispatch { > > struct { > struct libinput_device_config_natural_scroll config_natural; > + struct libinput_device_config_scroll_mode config_mode; > bool natural_scrolling_enabled; > + enum libinput_config_scroll_mode mode; > } scroll; > > enum touchpad_event queued; > -- > 2.1.0 > > _______________________________________________ > wayland-devel mailing list > wayland-devel@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/wayland-devel > _______________________________________________ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel