From ee4a0c6821a1b79c3d18c6ef6d7ed6d37df74755 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Sat, 7 Aug 2010 18:28:29 +0200 Subject: gesture: Improved tickle/active logic Reorganize the mode model to use bitmasks for tickle and active, and refine the tickle logic for each gesture. --- src/gestures-combo.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/gestures-combo.c') diff --git a/src/gestures-combo.c b/src/gestures-combo.c index 0f4dd7e..6ce6197 100644 --- a/src/gestures-combo.c +++ b/src/gestures-combo.c @@ -33,6 +33,8 @@ static const int getype[DIM_TOUCH + 1] = { GRAIL_TYPE_COMBO5, }; +static const int fm_mask = 0x0f; + int gru_combo(struct grail *ge, const struct touch_frame *frame) { @@ -40,6 +42,7 @@ int gru_combo(struct grail *ge, struct combo_model *state = &gru->combo; struct move_model *move = &gru->move; grail_prop_t prop[DIM_GRAIL_PROP]; + int mask = state->active ? (move->active & fm_mask) : fm_mask; if (!move->multi) { if (state->active) { gru_end(ge, state->gid, move); @@ -47,8 +50,7 @@ int gru_combo(struct grail *ge, } return 0; } - if (!move->x.tickle && !move->y.tickle && - !move->r.tickle && !move->a.tickle) + if (!(move->tickle & mask)) return 0; if (!state->active) { int type = getype[move->ntouch]; @@ -57,13 +59,12 @@ int gru_combo(struct grail *ge, state->gid = gin_gid_begin(ge, type, PRIO_GESTURE, frame); state->active = 1; } - if (!move->x.active && !move->y.active && - !move->r.active && !move->a.active) + if (!(move->active & fm_mask)) return 0; - prop[0] = move->x.active ? move->x.delta : 0; - prop[1] = move->y.active ? move->y.delta : 0; - prop[2] = move->r.active ? move->r.delta : 0; - prop[3] = move->a.active ? move->a.delta : 0; + prop[0] = move->fm[FM_X].delta; + prop[1] = move->fm[FM_Y].delta; + prop[2] = move->fm[FM_R].delta; + prop[3] = move->fm[FM_A].delta; gru_event(ge, state->gid, move, prop, 4); return 1; } -- cgit v1.2.3