From: Peter Hutterer Date: Wed, 14 Jan 2015 23:48:29 +0000 (+1000) Subject: Merge branch 'merged-scroll-events' X-Git-Tag: 0.8.0~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cb2f2ed6134beb0b5d8f45b6e3e07f145bde4ef3;p=platform%2Fupstream%2Flibinput.git Merge branch 'merged-scroll-events' This is merged on top of the wheel normalization patches. Those introduced an axis source and an extra "discrete" value to the various internal and external APIs. This branch changed from a single value to passing dx/dy into all scroll events. The conflicts are to change everything to take x, y, x_discrete, y_discrete as values (and the source axis mask of course). Conflicts: src/evdev-mt-touchpad-edge-scroll.c src/evdev.c src/libinput-private.h src/libinput.c --- cb2f2ed6134beb0b5d8f45b6e3e07f145bde4ef3 diff --cc src/evdev-mt-touchpad-edge-scroll.c index 8605034c,6268986a..26a86141 --- a/src/evdev-mt-touchpad-edge-scroll.c +++ b/src/evdev-mt-touchpad-edge-scroll.c @@@ -325,10 -325,9 +325,10 @@@ tp_edge_scroll_post_events(struct tp_di if (t->scroll.direction != -1) { /* Send stop scroll event */ pointer_notify_axis(device, time, - t->scroll.direction, + AS_MASK(t->scroll.direction), LIBINPUT_POINTER_AXIS_SOURCE_FINGER, - 0.0, - 0); - 0.0, 0.0); ++ 0.0, 0.0, ++ 0, 0); t->scroll.direction = -1; } continue; @@@ -350,10 -349,10 +350,11 @@@ if (fabs(*delta) < t->scroll.threshold) continue; - pointer_notify_axis(device, time, axis, + pointer_notify_axis(device, time, + AS_MASK(axis), LIBINPUT_POINTER_AXIS_SOURCE_FINGER, - *delta, - 0); - dx, dy); ++ dx, dy, ++ 0, 0); t->scroll.direction = axis; tp_edge_scroll_handle_event(tp, t, SCROLL_EVENT_POSTED); @@@ -371,10 -370,9 +372,10 @@@ tp_edge_scroll_stop_events(struct tp_di tp_for_each_touch(tp, t) { if (t->scroll.direction != -1) { pointer_notify_axis(device, time, - t->scroll.direction, + AS_MASK(t->scroll.direction), LIBINPUT_POINTER_AXIS_SOURCE_FINGER, - 0.0, - 0); ++ 0.0, 0.0, + 0.0, 0.0); t->scroll.direction = -1; } } diff --cc src/evdev.c index 0e78381c,076db29f..2d73d690 --- a/src/evdev.c +++ b/src/evdev.c @@@ -539,22 -539,20 +539,24 @@@ evdev_process_absolute_motion(struct ev static void evdev_notify_axis(struct evdev_device *device, uint64_t time, - enum libinput_pointer_axis axis, + uint32_t axes, enum libinput_pointer_axis_source source, - double value, - double discrete) - double x, double y) ++ double x, double y, ++ double x_discrete, double y_discrete) { if (device->scroll.natural_scrolling_enabled) { - value *= -1; - discrete *= -1; + x *= -1; + y *= -1; ++ x_discrete *= -1; ++ y_discrete *= -1; } pointer_notify_axis(&device->base, time, - axis, + axes, source, - value, - discrete); - x, y); ++ x, y, ++ x_discrete, y_discrete); } static inline void @@@ -579,20 -577,20 +581,24 @@@ evdev_process_relative(struct evdev_dev evdev_notify_axis( device, time, - LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, + AS_MASK(LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL), LIBINPUT_POINTER_AXIS_SOURCE_WHEEL, - 0, - -1 * e->value * device->scroll.wheel_click_angle); ++ 0.0, + -1 * e->value * device->scroll.wheel_click_angle, ++ 0.0, + -1 * e->value); break; case REL_HWHEEL: evdev_flush_pending_event(device, time); evdev_notify_axis( device, time, - LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL, + AS_MASK(LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL), LIBINPUT_POINTER_AXIS_SOURCE_WHEEL, e->value * device->scroll.wheel_click_angle, - e->value); - 0); ++ 0.0, ++ e->value, ++ 0.0); break; } } @@@ -1863,27 -1861,20 +1869,20 @@@ evdev_post_scroll(struct evdev_device * /* We use the trigger to enable, but the delta from this event for * the actual scroll movement. Otherwise we get a jump once * scrolling engages */ - if (dy != 0.0 && - evdev_is_scrolling(device, - LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL)) { - evdev_notify_axis(device, - time, - LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, - source, - dy, - 0); - } + if (!evdev_is_scrolling(device, + LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL)) + dy = 0.0; + if (!evdev_is_scrolling(device, + LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL)) + dx = 0.0; - if (dx != 0.0 && - evdev_is_scrolling(device, - LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL)) { + if (dx != 0.0 || dy != 0.0) evdev_notify_axis(device, time, - LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL, + device->scroll.direction, source, -- dx, - 0); - } - dy); ++ dx, dy, ++ 0.0, 0.0); } void @@@ -1892,18 -1883,12 +1891,13 @@@ evdev_stop_scroll(struct evdev_device * enum libinput_pointer_axis_source source) { /* terminate scrolling with a zero scroll event */ - if (device->scroll.direction & (1 << LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL)) - pointer_notify_axis(&device->base, - time, - LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, - source, - 0, 0); - if (device->scroll.direction & (1 << LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL)) + if (device->scroll.direction != 0) pointer_notify_axis(&device->base, time, - LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL, + device->scroll.direction, source, - 0, 0); ++ 0.0, 0.0, + 0.0, 0.0); device->scroll.buildup_horizontal = 0; device->scroll.buildup_vertical = 0; diff --cc src/libinput-private.h index 415e53e3,0cb9b259..012c82d0 --- a/src/libinput-private.h +++ b/src/libinput-private.h @@@ -278,10 -278,9 +278,12 @@@ pointer_notify_button(struct libinput_d void pointer_notify_axis(struct libinput_device *device, uint64_t time, - enum libinput_pointer_axis axis, + uint32_t axes, enum libinput_pointer_axis_source source, - double value, - double discrete); - double x, double y); ++ double x, ++ double y, ++ double x_discrete, ++ double y_discrete); void touch_notify_touch_down(struct libinput_device *device, diff --cc src/libinput.c index 37df9626,2442b065..00ab5f21 --- a/src/libinput.c +++ b/src/libinput.c @@@ -59,6 -59,6 +59,8 @@@ struct libinput_event_pointer uint32_t time; double x; double y; ++ double x_discrete; ++ double y_discrete; double dx_unaccel; double dy_unaccel; uint32_t button; @@@ -387,17 -393,28 +395,50 @@@ libinput_event_pointer_has_axis(struct } LIBINPUT_EXPORT double - libinput_event_pointer_get_axis_value(struct libinput_event_pointer *event) + libinput_event_pointer_get_axis_value(struct libinput_event_pointer *event, + enum libinput_pointer_axis axis) { - return event->value; + struct libinput *libinput = event->base.device->seat->libinput; + double value = 0; + + if (!libinput_event_pointer_has_axis(event, axis)) { + log_bug_client(libinput, "value requested for unset axis\n"); + } else { + switch (axis) { + case LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL: + value = event->x; + break; + case LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL: + value = event->y; + break; + } + } + + return value; } +LIBINPUT_EXPORT double - libinput_event_pointer_get_axis_value_discrete(struct libinput_event_pointer *event) ++libinput_event_pointer_get_axis_value_discrete(struct libinput_event_pointer *event, ++ enum libinput_pointer_axis axis) +{ - return event->discrete; ++ struct libinput *libinput = event->base.device->seat->libinput; ++ double value = 0; ++ ++ if (!libinput_event_pointer_has_axis(event, axis)) { ++ log_bug_client(libinput, "value requested for unset axis\n"); ++ } else { ++ switch (axis) { ++ case LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL: ++ value = event->x_discrete; ++ break; ++ case LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL: ++ value = event->y_discrete; ++ break; ++ } ++ } ++ return value; +} + LIBINPUT_EXPORT enum libinput_pointer_axis_source libinput_event_pointer_get_axis_source(struct libinput_event_pointer *event) { @@@ -999,10 -1016,9 +1040,10 @@@ pointer_notify_button(struct libinput_d void pointer_notify_axis(struct libinput_device *device, uint64_t time, - enum libinput_pointer_axis axis, + uint32_t axes, enum libinput_pointer_axis_source source, - double value, - double discrete) - double x, double y) ++ double x, double y, ++ double x_discrete, double y_discrete) { struct libinput_event_pointer *axis_event; @@@ -1012,10 -1028,10 +1053,12 @@@ *axis_event = (struct libinput_event_pointer) { .time = time, - .axis = axis, - .value = value, + .x = x, + .y = y, .source = source, - .discrete = discrete, + .axes = axes, ++ .x_discrete = x_discrete, ++ .y_discrete = y_discrete, }; post_device_event(device, time, diff --cc src/libinput.h index c6dd57e7,89cc0f09..276660b9 --- a/src/libinput.h +++ b/src/libinput.h @@@ -683,11 -686,10 +686,12 @@@ libinput_event_pointer_has_axis(struct * @ref LIBINPUT_EVENT_POINTER_AXIS. * * @return the axis value of this event + * + * @see libinput_event_pointer_get_axis_value_discrete */ double - libinput_event_pointer_get_axis_value(struct libinput_event_pointer *event); + libinput_event_pointer_get_axis_value(struct libinput_event_pointer *event, + enum libinput_pointer_axis axis); /** * @ingroup event_pointer @@@ -727,25 -729,6 +731,26 @@@ enum libinput_pointer_axis_source libinput_event_pointer_get_axis_source(struct libinput_event_pointer *event); +/** + * @ingroup pointer + * + * Return the axis value in discrete steps for a given axis event. How a + * value translates into a discrete step depends on the source. + * + * If the source is @ref LIBINPUT_POINTER_AXIS_SOURCE_WHEEL, the discrete + * value correspond to the number of physical mouse clicks. + * + * If the source is @ref LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS or @ref + * LIBINPUT_POINTER_AXIS_SOURCE_FINGER, the discrete value is always 0. + * + * @return The discrete value for the given event. + * + * @see libinput_event_pointer_get_axis_value + */ +double - libinput_event_pointer_get_axis_value_discrete(struct libinput_event_pointer *event); ++libinput_event_pointer_get_axis_value_discrete(struct libinput_event_pointer *event, ++ enum libinput_pointer_axis axis); + /** * @ingroup event_pointer * diff --cc test/pointer.c index 2055c413,dd9ea0da..1af4f385 --- a/test/pointer.c +++ b/test/pointer.c @@@ -375,15 -373,15 +376,17 @@@ test_wheel_event(struct litest_device * ptrev = libinput_event_get_pointer_event(event); ck_assert(ptrev != NULL); - ck_assert_int_eq(libinput_event_pointer_get_axis(ptrev), - which == REL_WHEEL ? + + axis = (which == REL_WHEEL) ? LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL : - LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL); - ck_assert_int_eq(libinput_event_pointer_get_axis_value(ptrev), expected); + LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL; + + ck_assert_int_eq(libinput_event_pointer_get_axis_value(ptrev, axis), + expected); ck_assert_int_eq(libinput_event_pointer_get_axis_source(ptrev), LIBINPUT_POINTER_AXIS_SOURCE_WHEEL); - ck_assert_int_eq(libinput_event_pointer_get_axis_value_discrete(ptrev), ++ ck_assert_int_eq(libinput_event_pointer_get_axis_value_discrete(ptrev, axis), + discrete); libinput_event_destroy(event); }