mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-04-20 07:10:44 +02:00
touchpad: Hookup scroll-mode configuration
Default to 2fg scrolling for now, once we have edge-scrolling we can default to edge-scrolling on touchpads which cannot detect more than 1 touch. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
028513a0a7
commit
617bab3731
2 changed files with 59 additions and 3 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue