[PATCH libinput] touchpad: enable natural scrolling for edge scrolling
Peter Hutterer
peter.hutterer at who-t.net
Mon Aug 10 19:53:20 PDT 2015
Instead of going straight to pointer_notify_axis, go through
evdev_notify_axis() which flips the scroll direction around for us.
https://bugs.freedesktop.org/show_bug.cgi?id=91597
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
src/evdev-mt-touchpad-edge-scroll.c | 20 ++++++++++----------
src/evdev.c | 2 +-
src/evdev.h | 7 +++++++
test/touchpad.c | 30 ++++++++++++++++++++++++++++++
4 files changed, 48 insertions(+), 11 deletions(-)
diff --git a/src/evdev-mt-touchpad-edge-scroll.c b/src/evdev-mt-touchpad-edge-scroll.c
index 4902808..eda62e4 100644
--- a/src/evdev-mt-touchpad-edge-scroll.c
+++ b/src/evdev-mt-touchpad-edge-scroll.c
@@ -342,7 +342,7 @@ tp_edge_scroll_handle_state(struct tp_dispatch *tp, uint64_t time)
int
tp_edge_scroll_post_events(struct tp_dispatch *tp, uint64_t time)
{
- struct libinput_device *device = &tp->device->base;
+ struct evdev_device *device = tp->device;
struct tp_touch *t;
enum libinput_pointer_axis axis;
double *delta;
@@ -369,7 +369,7 @@ tp_edge_scroll_post_events(struct tp_dispatch *tp, uint64_t time)
case EDGE_NONE:
if (t->scroll.direction != -1) {
/* Send stop scroll event */
- pointer_notify_axis(device, time,
+ evdev_notify_axis(device, time,
AS_MASK(t->scroll.direction),
LIBINPUT_POINTER_AXIS_SOURCE_FINGER,
&zero,
@@ -395,7 +395,7 @@ tp_edge_scroll_post_events(struct tp_dispatch *tp, uint64_t time)
switch (t->scroll.edge_state) {
case EDGE_SCROLL_TOUCH_STATE_NONE:
case EDGE_SCROLL_TOUCH_STATE_AREA:
- log_bug_libinput(device->seat->libinput,
+ log_bug_libinput(tp_libinput_context(tp),
"unexpected scroll state %d\n",
t->scroll.edge_state);
break;
@@ -416,11 +416,11 @@ tp_edge_scroll_post_events(struct tp_dispatch *tp, uint64_t time)
if (*delta == 0.0)
continue;
- pointer_notify_axis(device, time,
- AS_MASK(axis),
- LIBINPUT_POINTER_AXIS_SOURCE_FINGER,
- &normalized,
- &zero_discrete);
+ evdev_notify_axis(device, time,
+ AS_MASK(axis),
+ LIBINPUT_POINTER_AXIS_SOURCE_FINGER,
+ &normalized,
+ &zero_discrete);
t->scroll.direction = axis;
tp_edge_scroll_handle_event(tp, t, SCROLL_EVENT_POSTED);
@@ -432,14 +432,14 @@ tp_edge_scroll_post_events(struct tp_dispatch *tp, uint64_t time)
void
tp_edge_scroll_stop_events(struct tp_dispatch *tp, uint64_t time)
{
- struct libinput_device *device = &tp->device->base;
+ struct evdev_device *device = tp->device;
struct tp_touch *t;
const struct normalized_coords zero = { 0.0, 0.0 };
const struct discrete_coords zero_discrete = { 0.0, 0.0 };
tp_for_each_touch(tp, t) {
if (t->scroll.direction != -1) {
- pointer_notify_axis(device, time,
+ evdev_notify_axis(device, time,
AS_MASK(t->scroll.direction),
LIBINPUT_POINTER_AXIS_SOURCE_FINGER,
&zero,
diff --git a/src/evdev.c b/src/evdev.c
index 53ebf9d..225c3ac 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -612,7 +612,7 @@ evdev_process_absolute_motion(struct evdev_device *device,
}
}
-static void
+void
evdev_notify_axis(struct evdev_device *device,
uint64_t time,
uint32_t axes,
diff --git a/src/evdev.h b/src/evdev.h
index 65c5a41..c951671 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -381,6 +381,13 @@ void
evdev_init_natural_scroll(struct evdev_device *device);
void
+evdev_notify_axis(struct evdev_device *device,
+ uint64_t time,
+ uint32_t axes,
+ enum libinput_pointer_axis_source source,
+ const struct normalized_coords *delta_in,
+ const struct discrete_coords *discrete_in);
+void
evdev_post_scroll(struct evdev_device *device,
uint64_t time,
enum libinput_pointer_axis_source source,
diff --git a/test/touchpad.c b/test/touchpad.c
index 6e7ea5f..bbdbc21 100644
--- a/test/touchpad.c
+++ b/test/touchpad.c
@@ -350,6 +350,35 @@ START_TEST(touchpad_scroll_natural_2fg)
}
END_TEST
+START_TEST(touchpad_scroll_natural_edge)
+{
+ struct litest_device *dev = litest_current_device();
+ struct libinput *li = dev->libinput;
+
+ litest_enable_edge_scroll(dev);
+ litest_drain_events(li);
+
+ libinput_device_config_scroll_set_natural_scroll_enabled(dev->libinput_device, 1);
+
+ litest_touch_down(dev, 0, 99, 20);
+ litest_touch_move_to(dev, 0, 99, 20, 99, 80, 10, 0);
+ litest_touch_up(dev, 0);
+
+ libinput_dispatch(li);
+ litest_assert_scroll(li, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, -4);
+ litest_assert_empty_queue(li);
+
+ litest_touch_down(dev, 0, 99, 80);
+ litest_touch_move_to(dev, 0, 99, 80, 99, 20, 10, 0);
+ litest_touch_up(dev, 0);
+
+ libinput_dispatch(li);
+ litest_assert_scroll(li, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, 4);
+ litest_assert_empty_queue(li);
+
+}
+END_TEST
+
START_TEST(touchpad_edge_scroll)
{
struct litest_device *dev = litest_current_device();
@@ -3450,6 +3479,7 @@ litest_setup_tests(void)
litest_add("touchpad:scroll", touchpad_scroll_natural_defaults, LITEST_TOUCHPAD, LITEST_ANY);
litest_add("touchpad:scroll", touchpad_scroll_natural_enable_config, LITEST_TOUCHPAD, LITEST_ANY);
litest_add("touchpad:scroll", touchpad_scroll_natural_2fg, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
+ litest_add("touchpad:scroll", touchpad_scroll_natural_edge, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
litest_add("touchpad:scroll", touchpad_scroll_defaults, LITEST_TOUCHPAD, LITEST_ANY);
litest_add("touchpad:scroll", touchpad_edge_scroll, LITEST_TOUCHPAD, LITEST_ANY);
litest_add("touchpad:scroll", touchpad_edge_scroll_no_motion, LITEST_TOUCHPAD, LITEST_ANY);
--
2.4.3
More information about the wayland-devel
mailing list