From 212a4c23ffde2c5e220665f0a32cca534dc64ede Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Tue, 10 Aug 2010 17:03:03 +0100 Subject: pinch: add bounding box to property list Signed-off-by: Henrik Rydberg --- src/gestures-pinch.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gestures-pinch.c b/src/gestures-pinch.c index 18007de..0ddffa4 100644 --- a/src/gestures-pinch.c +++ b/src/gestures-pinch.c @@ -35,12 +35,39 @@ static const int getype[DIM_TOUCH + 1] = { static const int fm_mask = 0x04; -static void set_props(struct combo_model *s, const struct move_model *m) +static void set_props(struct combo_model *s, + const struct move_model *m, + const struct touch_frame *frame) { + float x1, y1, x2, y2, x, y; + int i; s->prop[GRAIL_PROP_PINCH_DR] = m->fm[FM_R].action_delta; s->prop[GRAIL_PROP_PINCH_VR] = m->fm[FM_R].velocity; s->prop[GRAIL_PROP_PINCH_R] = m->fm[FM_R].value; s->nprop = 3; + if (!frame->nactive) + return; + x = frame->active[0]->prop[TP_POS_X]; + y = frame->active[0]->prop[TP_POS_Y]; + x1 = x2 = x; + y1 = y2 = y; + for (i = 1; i < frame->nactive; i++) { + x = frame->active[i]->prop[TP_POS_X]; + y = frame->active[i]->prop[TP_POS_Y]; + if (x < x1) + x1 = x; + if (y < y1) + y1 = y; + if (x > x2) + x2 = x; + if (y > y2) + y2 = y; + } + s->prop[GRAIL_PROP_PINCH_X1] = x1; + s->prop[GRAIL_PROP_PINCH_Y1] = y1; + s->prop[GRAIL_PROP_PINCH_X2] = x2; + s->prop[GRAIL_PROP_PINCH_Y2] = y2; + s->nprop = 7; } int gru_pinch(struct grail *ge, @@ -69,7 +96,7 @@ int gru_pinch(struct grail *ge, } if (!(move->active & fm_mask)) return 0; - set_props(state, move); + set_props(state, move, frame); gru_event(ge, state->gid, move, state->prop, state->nprop); return 1; } -- cgit v1.2.3