From 9a99564617a6c308bc2fc352726581dae0515195 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Fri, 25 Mar 2011 19:20:08 +0100 Subject: Do not timeout gestures overlapping touch gestures The notion of listening to touch gestures implies that the touches of those gestures never timeout. Hence, any pending gesture that overlaps those touches should not timeout. Signed-off-by: Henrik Rydberg --- src/grail-inserter.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/grail-inserter.c b/src/grail-inserter.c index 5225cb8..fc9076a 100644 --- a/src/grail-inserter.c +++ b/src/grail-inserter.c @@ -38,6 +38,18 @@ static int find_gslot(const struct gesture_inserter *gin, int gid) return -1; } +static int mask_overlap(const grail_mask_t *a, const grail_mask_t *b, + int bytes) +{ + int i; + + for (i = 0; i < bytes; i++) + if (a[i] & b[i]) + return 1; + + return 0; +} + // todo: spanning tree for multi-user case static void setup_new_gestures(struct grail *ge, const struct utouch_frame *frame) @@ -119,8 +131,10 @@ void gin_frame_begin(struct grail *ge, const struct utouch_frame *frame) void gin_frame_end(struct grail *ge, const struct utouch_frame *frame) { struct gesture_inserter *gin = ge->gin; + grail_mask_t keep[DIM_TOUCH_BYTES]; int i, hold[2] = { 0, 0 }, discard[2] = { 0, 0 }; + memset(keep, 0, sizeof(keep)); setup_new_gestures(ge, frame); grail_mask_foreach(i, gin->used, sizeof(gin->used)) { @@ -141,10 +155,18 @@ void gin_frame_end(struct grail *ge, const struct utouch_frame *frame) gin_gid_discard(ge, s->id); } + grail_mask_foreach(i, gin->used, sizeof(gin->used)) { + struct slot_state *s = &gin->state[i]; + if (s->slice == 1) + grail_mask_set_mask(keep, s->span, sizeof(keep)); + } + grail_mask_foreach(i, gin->used, sizeof(gin->used)) { struct slot_state *s = &gin->state[i]; if (!s->timeout) continue; + if (mask_overlap(keep, s->span, sizeof(keep))) + continue; gin_gid_discard(ge, s->id); } -- cgit v1.2.3