diff options
author | Hans de Goede <hdegoede@redhat.com> | 2015-02-18 09:00:25 +0100 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2015-05-26 10:53:23 +1000 |
commit | f10f6920dfb3f97bfbf845f45f2ee7c2e7e8abd1 (patch) | |
tree | d57ece89637e028f526e7bd36b1c3a2e10acce2a | |
parent | 9035e4a767786652858e06b3c77dce333437f565 (diff) | |
download | libinput-f10f6920dfb3f97bfbf845f45f2ee7c2e7e8abd1.tar.gz |
touchpad: Add support for swipe gestures
Add support for swipe gestures.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Jason Gerecke <jason.gerecke@wacom.com>
-rw-r--r-- | src/evdev-mt-touchpad-gestures.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/evdev-mt-touchpad-gestures.c b/src/evdev-mt-touchpad-gestures.c index 57c07feb..c4216f58 100644 --- a/src/evdev-mt-touchpad-gestures.c +++ b/src/evdev-mt-touchpad-gestures.c @@ -75,6 +75,8 @@ tp_get_average_touches_delta(struct tp_dispatch *tp) static void tp_gesture_start(struct tp_dispatch *tp, uint64_t time) { + const struct normalized_coords zero = { 0.0, 0.0 }; + if (tp->gesture.started) return; @@ -82,6 +84,13 @@ tp_gesture_start(struct tp_dispatch *tp, uint64_t time) case 2: /* NOP */ break; + case 3: + case 4: + gesture_notify_swipe(&tp->device->base, time, + LIBINPUT_EVENT_GESTURE_SWIPE_START, + tp->gesture.finger_count, + &zero, &zero); + break; } tp->gesture.started = true; } @@ -136,6 +145,23 @@ tp_gesture_post_twofinger_scroll(struct tp_dispatch *tp, uint64_t time) &delta); } +static void +tp_gesture_post_swipe(struct tp_dispatch *tp, uint64_t time) +{ + struct normalized_coords delta, unaccel; + + unaccel = tp_get_average_touches_delta(tp); + delta = tp_filter_motion(tp, &unaccel, time); + + if (!normalized_is_zero(delta) || !normalized_is_zero(unaccel)) { + tp_gesture_start(tp, time); + gesture_notify_swipe(&tp->device->base, time, + LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE, + tp->gesture.finger_count, + &delta, &unaccel); + } +} + void tp_gesture_post_events(struct tp_dispatch *tp, uint64_t time) { @@ -160,6 +186,10 @@ tp_gesture_post_events(struct tp_dispatch *tp, uint64_t time) case 2: tp_gesture_post_twofinger_scroll(tp, time); break; + case 3: + case 4: + tp_gesture_post_swipe(tp, time); + break; } } @@ -177,6 +207,8 @@ tp_gesture_stop_twofinger_scroll(struct tp_dispatch *tp, uint64_t time) void tp_gesture_stop(struct tp_dispatch *tp, uint64_t time) { + const struct normalized_coords zero = { 0.0, 0.0 }; + if (!tp->gesture.started) return; @@ -184,6 +216,13 @@ tp_gesture_stop(struct tp_dispatch *tp, uint64_t time) case 2: tp_gesture_stop_twofinger_scroll(tp, time); break; + case 3: + case 4: + gesture_notify_swipe(&tp->device->base, time, + LIBINPUT_EVENT_GESTURE_SWIPE_END, + tp->gesture.finger_count, + &zero, &zero); + break; } tp->gesture.started = false; } |