gestures: filter motion inside the gesture state machine

At the moment, every gesture is triggered by motion. In order to implement
gestures not based on motion, like hold, it is required to filter the unwanted
motion inside the gesture state machine so it transits to the correct states.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
This commit is contained in:
José Expósito 2021-05-27 19:19:21 +02:00 committed by Peter Hutterer
parent b5b6f835af
commit 781cee2d8b
3 changed files with 21 additions and 11 deletions

View file

@ -879,9 +879,11 @@ tp_gesture_handle_state_none(struct tp_dispatch *tp, uint64_t time)
}
static void
tp_gesture_handle_state_unknown(struct tp_dispatch *tp, uint64_t time)
tp_gesture_handle_state_unknown(struct tp_dispatch *tp, uint64_t time,
bool ignore_motion)
{
tp_gesture_detect_motion_gestures(tp, time);
if (!ignore_motion)
tp_gesture_detect_motion_gestures(tp, time);
}
static void
@ -983,13 +985,14 @@ tp_gesture_handle_state_pinch(struct tp_dispatch *tp, uint64_t time)
}
static void
tp_gesture_post_gesture(struct tp_dispatch *tp, uint64_t time)
tp_gesture_post_gesture(struct tp_dispatch *tp, uint64_t time,
bool ignore_motion)
{
if (tp->gesture.state == GESTURE_STATE_NONE)
tp_gesture_handle_state_none(tp, time);
if (tp->gesture.state == GESTURE_STATE_UNKNOWN)
tp_gesture_handle_state_unknown(tp, time);
tp_gesture_handle_state_unknown(tp, time, ignore_motion);
if (tp->gesture.state == GESTURE_STATE_POINTER_MOTION)
tp_gesture_handle_state_pointer_motion(tp, time);
@ -1021,7 +1024,8 @@ tp_gesture_thumb_moved(struct tp_dispatch *tp)
}
void
tp_gesture_post_events(struct tp_dispatch *tp, uint64_t time)
tp_gesture_post_events(struct tp_dispatch *tp, uint64_t time,
bool ignore_motion)
{
if (tp->gesture.finger_count == 0)
return;
@ -1055,7 +1059,7 @@ tp_gesture_post_events(struct tp_dispatch *tp, uint64_t time)
tp_thumb_reset(tp);
if (tp->gesture.finger_count <= 4)
tp_gesture_post_gesture(tp, time);
tp_gesture_post_gesture(tp, time, ignore_motion);
}
void

View file

@ -1866,18 +1866,23 @@ tp_post_events(struct tp_dispatch *tp, uint64_t time)
ignore_motion |= tp_tap_handle_state(tp, time);
ignore_motion |= tp_post_button_events(tp, time);
if (ignore_motion ||
tp->palm.trackpoint_active ||
tp->dwt.keyboard_active) {
if (tp->palm.trackpoint_active || tp->dwt.keyboard_active) {
tp_edge_scroll_stop_events(tp, time);
tp_gesture_cancel(tp, time);
return;
}
if (ignore_motion) {
tp_edge_scroll_stop_events(tp, time);
tp_gesture_cancel(tp, time);
tp_gesture_post_events(tp, time, true);
return;
}
if (tp_edge_scroll_post_events(tp, time) != 0)
return;
tp_gesture_post_events(tp, time);
tp_gesture_post_events(tp, time, false);
}
static void

View file

@ -703,7 +703,8 @@ void
tp_gesture_handle_state(struct tp_dispatch *tp, uint64_t time);
void
tp_gesture_post_events(struct tp_dispatch *tp, uint64_t time);
tp_gesture_post_events(struct tp_dispatch *tp, uint64_t time,
bool ignore_motion);
void
tp_gesture_stop_twofinger_scroll(struct tp_dispatch *tp, uint64_t time);