From d0f7b524153d1b54128b049841f880ee78c2c529 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Tue, 21 Sep 2010 09:49:26 +0200 Subject: Simplify book-keeping of active gestures The current frame computation returns the event types to filter, which is less useful than knowing what gesture types are active in the frame. Add the active gesture types to the frame struct and simplify usage. Signed-off-by: Henrik Rydberg --- src/grail-api.c | 9 +++++---- src/grail-inserter.c | 14 +++----------- src/grail-inserter.h | 4 ++-- 3 files changed, 10 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/grail-api.c b/src/grail-api.c index d0712b3..0673120 100644 --- a/src/grail-api.c +++ b/src/grail-api.c @@ -106,13 +106,14 @@ static void tp_sync(struct touch_dev *dev, struct input_event ev; struct grail *ge = dev->priv; struct grail_impl *impl = ge->impl; + struct gesture_inserter *gin = ge->gin; struct touch_frame *frame = &dev->frame; - grail_mask_t filtered[DIM_EV_TYPE_BYTES]; - int pointer, nevent = 0; + int pointer, used_move, nevent = 0; gin_frame_begin(ge, frame); gru_recognize(ge, frame); - gin_frame_end(ge, filtered, sizeof(filtered), frame); - pointer = pointer_active(ge) && !grail_mask_get(filtered, EV_ABS); + gin_frame_end(ge, frame); + used_move = grail_mask_count(gin->types, sizeof(gin->types)); + pointer = pointer_active(ge) && !used_move; if (!ge->event) { evbuf_clear(&impl->evbuf); diff --git a/src/grail-inserter.c b/src/grail-inserter.c index a54b73a..847995a 100644 --- a/src/grail-inserter.c +++ b/src/grail-inserter.c @@ -103,20 +103,15 @@ void gin_destroy(struct grail *ge) void gin_frame_begin(struct grail *ge, const struct touch_frame *frame) { struct gesture_inserter *gin = ge->gin; + memset(gin->types, 0, sizeof(gin->types)); gin->time = frame->time; } -void gin_frame_end(struct grail *ge, - grail_mask_t *filtered, int max_filtered, - const struct touch_frame *frame) +void gin_frame_end(struct grail *ge, const struct touch_frame *frame) { struct gesture_inserter *gin = ge->gin; - grail_mask_t span[DIM_INSTANCE_BYTES]; int i, hold = 0, discard = 0; - memset(filtered, 0, max_filtered); - memset(span, 0, sizeof(span)); - setup_new_gestures(ge, frame); grail_mask_foreach(i, gin->used, sizeof(gin->used)) { @@ -140,7 +135,7 @@ void gin_frame_end(struct grail *ge, grail_mask_foreach(i, gin->used, sizeof(gin->used)) { struct slot_state *s = &gin->state[i]; struct gesture_event ev; - grail_mask_set_mask(span, s->span, sizeof(span)); + grail_mask_set(gin->types, s->type); if (s->priority < hold) continue; while (!gebuf_empty(&s->buf)) { @@ -154,9 +149,6 @@ void gin_frame_end(struct grail *ge, if (s->status == GRAIL_STATUS_END) gin_gid_discard(ge, s->id); } - - if (grail_mask_count(span, sizeof(span))) - grail_mask_set(filtered, EV_ABS); } int gin_gid_begin_select(struct grail *ge, int type, int priority, diff --git a/src/grail-inserter.h b/src/grail-inserter.h index c5a865a..9baecb7 100644 --- a/src/grail-inserter.h +++ b/src/grail-inserter.h @@ -48,6 +48,7 @@ struct slot_state { struct gesture_inserter { struct slot_state state[DIM_INSTANCE]; + grail_mask_t types[DIM_GRAIL_TYPE_BYTES]; grail_mask_t unused[DIM_INSTANCE_BYTES]; grail_mask_t fresh[DIM_INSTANCE_BYTES]; grail_mask_t used[DIM_INSTANCE_BYTES]; @@ -83,8 +84,7 @@ int gin_init(struct grail *ge); void gin_destroy(struct grail *ge); void gin_frame_begin(struct grail *ge, const struct touch_frame *frame); -void gin_frame_end(struct grail *ge, grail_mask_t *filtered, int max_filtered, - const struct touch_frame *frame); +void gin_frame_end(struct grail *ge, const struct touch_frame *frame); int gin_gid_begin_select(struct grail *ge, int type, int priority, const grail_mask_t *span, int nspan); -- cgit v1.2.3