touchpad: enable natural scrolling for edge scrolling

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@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
Peter Hutterer 2015-08-11 12:40:45 +10:00
parent 3dd0ece9c0
commit 0cd54c5987
4 changed files with 48 additions and 11 deletions

View file

@ -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,

View file

@ -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,

View file

@ -380,6 +380,13 @@ evdev_pointer_notify_physical_button(struct evdev_device *device,
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,

View file

@ -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);