diff options
| -rw-r--r-- | include/grail-types.h | 4 | ||||
| -rw-r--r-- | src/gestures-pinch.c | 31 |
2 files changed, 33 insertions, 2 deletions
diff --git a/include/grail-types.h b/include/grail-types.h index 66afd3f..9f7160d 100644 --- a/include/grail-types.h +++ b/include/grail-types.h | |||
| @@ -59,6 +59,10 @@ | |||
| 59 | #define GRAIL_PROP_PINCH_DR 0 /* radius delta */ | 59 | #define GRAIL_PROP_PINCH_DR 0 /* radius delta */ |
| 60 | #define GRAIL_PROP_PINCH_VR 1 /* radial velocity */ | 60 | #define GRAIL_PROP_PINCH_VR 1 /* radial velocity */ |
| 61 | #define GRAIL_PROP_PINCH_R 2 /* radius */ | 61 | #define GRAIL_PROP_PINCH_R 2 /* radius */ |
| 62 | #define GRAIL_PROP_PINCH_X1 3 /* bounding box x1 */ | ||
| 63 | #define GRAIL_PROP_PINCH_Y1 4 /* bounding box y1 */ | ||
| 64 | #define GRAIL_PROP_PINCH_X2 5 /* bounding box x2 */ | ||
| 65 | #define GRAIL_PROP_PINCH_Y2 6 /* bounding box y2 */ | ||
| 62 | 66 | ||
| 63 | #define GRAIL_PROP_ROTATE_DA 0 /* arc delta */ | 67 | #define GRAIL_PROP_ROTATE_DA 0 /* arc delta */ |
| 64 | #define GRAIL_PROP_ROTATE_VA 1 /* arc velocity */ | 68 | #define GRAIL_PROP_ROTATE_VA 1 /* arc velocity */ |
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] = { | |||
| 35 | 35 | ||
| 36 | static const int fm_mask = 0x04; | 36 | static const int fm_mask = 0x04; |
| 37 | 37 | ||
| 38 | static void set_props(struct combo_model *s, const struct move_model *m) | 38 | static void set_props(struct combo_model *s, |
| 39 | const struct move_model *m, | ||
| 40 | const struct touch_frame *frame) | ||
| 39 | { | 41 | { |
| 42 | float x1, y1, x2, y2, x, y; | ||
| 43 | int i; | ||
| 40 | s->prop[GRAIL_PROP_PINCH_DR] = m->fm[FM_R].action_delta; | 44 | s->prop[GRAIL_PROP_PINCH_DR] = m->fm[FM_R].action_delta; |
| 41 | s->prop[GRAIL_PROP_PINCH_VR] = m->fm[FM_R].velocity; | 45 | s->prop[GRAIL_PROP_PINCH_VR] = m->fm[FM_R].velocity; |
| 42 | s->prop[GRAIL_PROP_PINCH_R] = m->fm[FM_R].value; | 46 | s->prop[GRAIL_PROP_PINCH_R] = m->fm[FM_R].value; |
| 43 | s->nprop = 3; | 47 | s->nprop = 3; |
| 48 | if (!frame->nactive) | ||
| 49 | return; | ||
| 50 | x = frame->active[0]->prop[TP_POS_X]; | ||
| 51 | y = frame->active[0]->prop[TP_POS_Y]; | ||
| 52 | x1 = x2 = x; | ||
| 53 | y1 = y2 = y; | ||
| 54 | for (i = 1; i < frame->nactive; i++) { | ||
| 55 | x = frame->active[i]->prop[TP_POS_X]; | ||
| 56 | y = frame->active[i]->prop[TP_POS_Y]; | ||
| 57 | if (x < x1) | ||
| 58 | x1 = x; | ||
| 59 | if (y < y1) | ||
| 60 | y1 = y; | ||
| 61 | if (x > x2) | ||
| 62 | x2 = x; | ||
| 63 | if (y > y2) | ||
| 64 | y2 = y; | ||
| 65 | } | ||
| 66 | s->prop[GRAIL_PROP_PINCH_X1] = x1; | ||
| 67 | s->prop[GRAIL_PROP_PINCH_Y1] = y1; | ||
| 68 | s->prop[GRAIL_PROP_PINCH_X2] = x2; | ||
| 69 | s->prop[GRAIL_PROP_PINCH_Y2] = y2; | ||
| 70 | s->nprop = 7; | ||
| 44 | } | 71 | } |
| 45 | 72 | ||
| 46 | int gru_pinch(struct grail *ge, | 73 | int gru_pinch(struct grail *ge, |
| @@ -69,7 +96,7 @@ int gru_pinch(struct grail *ge, | |||
| 69 | } | 96 | } |
| 70 | if (!(move->active & fm_mask)) | 97 | if (!(move->active & fm_mask)) |
| 71 | return 0; | 98 | return 0; |
| 72 | set_props(state, move); | 99 | set_props(state, move, frame); |
| 73 | gru_event(ge, state->gid, move, state->prop, state->nprop); | 100 | gru_event(ge, state->gid, move, state->prop, state->nprop); |
| 74 | return 1; | 101 | return 1; |
| 75 | } | 102 | } |
