~chasedouglas/grail/original-touch-state

« back to all changes in this revision

Viewing changes to src/grail-event.c

  • Committer: Henrik Rydberg
  • Date: 2011-01-02 12:08:08 UTC
  • Revision ID: rydberg@bitmath.org-20110102120808-0nzbo3fcpp91sir5
Replace touch logic with utouch frame engine

The original grail uses an internal touch framework and exports some
touch information as extended attributes to gesture events. This was
never quite the intention, but rather to expose gestures and touches
on a similar footing, such that grail can be input agnostic. This
patch starts off by replacing the internal touch framework with the
utouch-frame engine.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#include <math.h>
29
29
 
30
30
static void compute_bbox(struct grail_coord *min, struct grail_coord *max,
31
 
                         const struct touch_frame *frame)
 
31
                         const struct utouch_frame *frame)
32
32
{
33
33
        float x, y;
34
34
        int i;
35
 
        if (frame->nactive < 1)
 
35
        if (frame->num_active < 1)
36
36
                return;
37
37
        x = frame->active[0]->x;
38
38
        y = frame->active[0]->y;
39
39
        min->x = max->x = x;
40
40
        min->y = max->y = y;
41
 
        for (i = 1; i < frame->nactive; i++) {
 
41
        for (i = 1; i < frame->num_active; i++) {
42
42
                x = frame->active[i]->x;
43
43
                y = frame->active[i]->y;
44
44
                if (x < min->x)
53
53
}
54
54
 
55
55
int gin_add_contact_props(const struct gesture_inserter *gin,
56
 
                          grail_prop_t *prop, const struct touch_frame *frame)
 
56
                          grail_prop_t *prop, const struct utouch_frame *frame)
57
57
{
58
58
        struct grail_coord min, max;
59
 
        int i, n = 0, ntouch = frame->nactive;
 
59
        int i, n = 0, ntouch = frame->num_active;
60
60
        if (!ntouch)
61
61
                return n;
62
62
        if (ntouch > 5)
67
67
        prop[n++] = gin_prop_x(gin, max.x);
68
68
        prop[n++] = gin_prop_y(gin, max.y);
69
69
        for (i = 0; i < ntouch; i++) {
70
 
                const struct touch *ct = frame->active[i];
 
70
                const struct utouch_contact *ct = frame->active[i];
71
71
                prop[n++] = ct->id;
72
72
                prop[n++] = gin_prop_x(gin, ct->x);
73
73
                prop[n++] = gin_prop_y(gin, ct->y);
79
79
                    struct grail_client_info *info, int maxinfo,
80
80
                    const grail_mask_t* types, int btypes,
81
81
                    const grail_mask_t* span, int bspan,
82
 
                    const struct touch_frame *frame)
 
82
                    const struct utouch_frame *frame)
83
83
{
84
84
        struct grail_coord pos[DIM_TOUCH];
85
85
        int i, npos = 0;
86
86
        if (!ge->get_clients)
87
87
                return 0;
88
88
        grail_mask_foreach(i, span, bspan) {
89
 
                pos[npos].x = gin_prop_x(ge->gin, frame->touch[i].x);
90
 
                pos[npos].y = gin_prop_y(ge->gin, frame->touch[i].y);
 
89
                pos[npos].x = gin_prop_x(ge->gin, frame->slots[i]->x);
 
90
                pos[npos].y = gin_prop_y(ge->gin, frame->slots[i]->y);
91
91
                npos++;
92
92
        }
93
93
        return ge->get_clients(ge, info, maxinfo, pos, npos, types, btypes);
95
95
 
96
96
void gin_send_event(struct grail *ge, struct slot_state *s,
97
97
                    const struct gesture_event *ev,
98
 
                    const struct touch_frame *frame)
 
98
                    const struct utouch_frame *frame)
99
99
{
100
100
        struct grail_impl *impl = ge->impl;
101
101
        const struct gesture_inserter *gin = ge->gin;
121
121
int grail_get_contacts(const struct grail *ge,
122
122
                       struct grail_contact *touch, int max_touch)
123
123
{
124
 
        const struct touch_dev *dev = &ge->impl->dev;
125
124
        const struct gesture_inserter *gin = ge->gin;
126
 
        const struct touch_frame *frame = &dev->frame;
 
125
        const struct utouch_frame *frame = ge->impl->frame;
127
126
        int i;
128
 
        if (frame->nactive < max_touch)
129
 
                max_touch = frame->nactive;
 
127
        if (frame->num_active < max_touch)
 
128
                max_touch = frame->num_active;
130
129
        for (i = 0; i < max_touch; i++) {
131
130
                struct grail_contact *t = &touch[i];
132
 
                const struct touch *ct = frame->active[i];
 
131
                const struct utouch_contact *ct = frame->active[i];
133
132
                t->id = ct->id;
134
133
                t->tool_type = ct->tool_type;
135
134
                t->pos.x = gin_prop_x(gin, ct->x);
138
137
                t->touch_minor = gin->scale_r * ct->touch_minor;
139
138
                t->width_major = gin->scale_r * ct->width_major;
140
139
                t->width_minor = gin->scale_r * ct->width_minor;
141
 
                t->angle = touch_angle(dev, ct->orientation);
142
 
                t->pressure = touch_pressure(dev, ct->pressure);
 
140
                t->angle = ct->orientation;
 
141
                t->pressure = ct->pressure;
143
142
        }
144
143
        return max_touch;
145
144
}