summaryrefslogtreecommitdiff
path: root/src/gestures-drag.c
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2010-08-10 11:47:00 +0100
committerHenrik Rydberg <rydberg@euromail.se>2010-08-10 15:04:18 +0100
commit7be96df1c903c11711336c5ad1859b347ae4b661 (patch)
treea5420af7613448c12e34ade0945b687ea9879836 /src/gestures-drag.c
parentfff2c89c1651f0c5aef75510f915a999700c31b9 (diff)
api: Rename gestures to conform to design docs
Use the names drag, pinch and rotate, and remove the combo gesture. Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'src/gestures-drag.c')
-rw-r--r--src/gestures-drag.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/gestures-drag.c b/src/gestures-drag.c
new file mode 100644
index 0000000..3f21041
--- /dev/null
+++ b/src/gestures-drag.c
@@ -0,0 +1,74 @@
1/*****************************************************************************
2 *
3 * grail - Gesture Recognition And Instantiation Library
4 *
5 * Copyright (C) 2010 Canonical Ltd.
6 * Copyright (C) 2010 Henrik Rydberg <rydberg@bitmath.org>
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program. If not, see <http://www.gnu.org/licenses/>.
20 *
21 ****************************************************************************/
22
23#include "grail-recognizer.h"
24#include <math.h>
25#include <stdio.h>
26
27static const int getype[DIM_TOUCH + 1] = {
28 -1,
29 GRAIL_TYPE_DRAG1,
30 GRAIL_TYPE_DRAG2,
31 GRAIL_TYPE_DRAG3,
32 GRAIL_TYPE_DRAG4,
33 GRAIL_TYPE_DRAG5,
34};
35
36static const int fm_mask = 0x03;
37
38int gru_drag(struct grail *ge,
39 const struct touch_frame *frame)
40{
41 struct gesture_recognizer *gru = ge->gru;
42 struct combo_model *state = &gru->drag;
43 struct move_model *move = &gru->move;
44 grail_prop_t prop[DIM_GRAIL_PROP];
45 int mask = state->active ? (move->active & fm_mask) : fm_mask;
46 if (!move->multi && (!gru->pointer_gesture || !move->single)) {
47 if (state->active) {
48 gru_end(ge, state->gid, move);
49 state->active = 0;
50 }
51 return 0;
52 }
53 if (!(move->tickle & mask))
54 return 0;
55 if (!state->active) {
56 int type = getype[move->ntouch];
57 if (type < 0)
58 return 0;
59 state->gid = gin_gid_begin(ge, type, PRIO_GESTURE, frame);
60 state->active = 1;
61 }
62 if (move->single) {
63 prop[0] = move->fm[FM_X].raw_delta;
64 prop[1] = move->fm[FM_Y].raw_delta;
65 } else {
66 if (!(move->active & fm_mask))
67 return 0;
68 prop[0] = move->fm[FM_X].action_delta;
69 prop[1] = move->fm[FM_Y].action_delta;
70 }
71 gru_event(ge, state->gid, move, prop, 2);
72 return 1;
73}
74