summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2014-11-04 10:43:39 +0100
committerPeter Hutterer <peter.hutterer@who-t.net>2014-11-20 08:10:39 +1000
commit617bab373132ac7532a1476b5a9f30dc053f28cb (patch)
tree10ef2b65df1c65a1be065da134d80d95a9c126b5
parent028513a0a723e97941c39c4aeb17433198723913 (diff)
downloadlibinput-617bab373132ac7532a1476b5a9f30dc053f28cb.tar.gz
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>
-rw-r--r--src/evdev-mt-touchpad.c60
-rw-r--r--src/evdev-mt-touchpad.h2
2 files changed, 59 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;
diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h
index baa51a36..4d7b8a90 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;