From da425afd6199995ac7b6f23bf8744a435cc02e23 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Tue, 10 Aug 2010 12:45:52 +0100 Subject: Add property declarations to grail-types Also add accumulated values for delta and velocity properties. Signed-off-by: Henrik Rydberg --- src/gestures-drag.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'src/gestures-drag.c') diff --git a/src/gestures-drag.c b/src/gestures-drag.c index 3f21041..a02943e 100644 --- a/src/gestures-drag.c +++ b/src/gestures-drag.c @@ -33,6 +33,22 @@ static const int getype[DIM_TOUCH + 1] = { GRAIL_TYPE_DRAG5, }; +static void set_props(struct combo_model *s, const struct move_model *m) +{ + if (m->single) { + s->prop[GRAIL_PROP_DRAG_DX] = m->fm[FM_X].raw_delta; + s->prop[GRAIL_PROP_DRAG_DY] = m->fm[FM_Y].raw_delta; + } else { + s->prop[GRAIL_PROP_DRAG_DX] = m->fm[FM_X].action_delta; + s->prop[GRAIL_PROP_DRAG_DY] = m->fm[FM_Y].action_delta; + } + s->prop[GRAIL_PROP_DRAG_VX] = m->fm[FM_X].velocity; + s->prop[GRAIL_PROP_DRAG_VY] = m->fm[FM_Y].velocity; + s->prop[GRAIL_PROP_DRAG_X] = m->fm[FM_X].value; + s->prop[GRAIL_PROP_DRAG_Y] = m->fm[FM_Y].value; + s->nprop = 6; +} + static const int fm_mask = 0x03; int gru_drag(struct grail *ge, @@ -41,11 +57,11 @@ int gru_drag(struct grail *ge, struct gesture_recognizer *gru = ge->gru; struct combo_model *state = &gru->drag; 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 && (!gru->pointer_gesture || !move->single)) { if (state->active) { - gru_end(ge, state->gid, move); + gru_end(ge, state->gid, move, + state->prop, state->nprop); state->active = 0; } return 0; @@ -59,16 +75,10 @@ int gru_drag(struct grail *ge, state->gid = gin_gid_begin(ge, type, PRIO_GESTURE, frame); state->active = 1; } - if (move->single) { - prop[0] = move->fm[FM_X].raw_delta; - prop[1] = move->fm[FM_Y].raw_delta; - } else { - if (!(move->active & fm_mask)) - return 0; - prop[0] = move->fm[FM_X].action_delta; - prop[1] = move->fm[FM_Y].action_delta; - } - gru_event(ge, state->gid, move, prop, 2); + if (!move->single && !(move->active & fm_mask)) + return 0; + set_props(state, move); + gru_event(ge, state->gid, move, state->prop, state->nprop); return 1; } -- cgit v1.2.3