diff options
Diffstat (limited to 'src/evdev-mt-touchpad.c')
-rw-r--r-- | src/evdev-mt-touchpad.c | 60 |
1 files changed, 57 insertions, 3 deletions
diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index 512131bd..8266c983 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,50 @@ 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; + + 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 +1003,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; + /* In mm for touchpads with valid resolution, see tp_init_accel() */ tp->device->scroll.threshold = 5.0; @@ -1027,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; @@ -1045,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; |