diff options
| author | Henrik Rydberg <rydberg@euromail.se> | 2011-01-02 12:38:26 +0100 |
|---|---|---|
| committer | Henrik Rydberg <rydberg@euromail.se> | 2011-01-02 12:38:26 +0100 |
| commit | 1e07054fbeab6e90f104c279d3246097dd838a17 (patch) | |
| tree | d5369728c02ee5d826b7e104f0b2297832276f94 /src/grail-api.c | |
| parent | ab67ba5e161c4d65128fc5eada6845a543464759 (diff) | |
Prepare for queued event handling
The current grail operates via callbacks. In order to make grail work
as a pipe, where input and output can be controlled externally, add
the missing event queue for gestures, and align the code to simplify a
switch.
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'src/grail-api.c')
| -rw-r--r-- | src/grail-api.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/grail-api.c b/src/grail-api.c index f013aa3..f38ca18 100644 --- a/src/grail-api.c +++ b/src/grail-api.c | |||
| @@ -184,28 +184,31 @@ static void handle_abs_events(struct grail *ge, const struct input_event *syn) | |||
| 184 | static void tp_sync(struct touch_dev *dev, | 184 | static void tp_sync(struct touch_dev *dev, |
| 185 | const struct input_event *syn) | 185 | const struct input_event *syn) |
| 186 | { | 186 | { |
| 187 | struct input_event ev; | ||
| 188 | struct grail *ge = dev->priv; | 187 | struct grail *ge = dev->priv; |
| 189 | struct grail_impl *impl = ge->impl; | 188 | struct grail_impl *impl = ge->impl; |
| 189 | int head = impl->evbuf.head; | ||
| 190 | struct input_event iev; | ||
| 191 | struct grail_event gev; | ||
| 190 | struct touch_frame *frame = &dev->frame; | 192 | struct touch_frame *frame = &dev->frame; |
| 191 | int nevent = 0; | ||
| 192 | gin_frame_begin(ge, frame); | 193 | gin_frame_begin(ge, frame); |
| 193 | gru_recognize(ge, frame); | 194 | gru_recognize(ge, frame); |
| 194 | gin_frame_end(ge, frame); | 195 | gin_frame_end(ge, frame); |
| 195 | 196 | ||
| 196 | if (!ge->event) { | ||
| 197 | evbuf_clear(&impl->evbuf); | ||
| 198 | return; | ||
| 199 | } | ||
| 200 | if (!impl->filter_abs) | 197 | if (!impl->filter_abs) |
| 201 | handle_abs_events(ge, syn); | 198 | handle_abs_events(ge, syn); |
| 199 | if (impl->evbuf.head != head) | ||
| 200 | evbuf_put(&impl->evbuf, syn); | ||
| 201 | |||
| 202 | while (!grailbuf_empty(&impl->gbuf)) { | ||
| 203 | grailbuf_get(&impl->gbuf, &gev); | ||
| 204 | if (ge->gesture) | ||
| 205 | ge->gesture(ge, &gev); | ||
| 206 | } | ||
| 202 | while (!evbuf_empty(&impl->evbuf)) { | 207 | while (!evbuf_empty(&impl->evbuf)) { |
| 203 | evbuf_get(&impl->evbuf, &ev); | 208 | evbuf_get(&impl->evbuf, &iev); |
| 204 | ge->event(ge, &ev); | 209 | if (ge->event) |
| 205 | nevent++; | 210 | ge->event(ge, &iev); |
| 206 | } | 211 | } |
| 207 | if (nevent) | ||
| 208 | ge->event(ge, syn); | ||
| 209 | } | 212 | } |
| 210 | 213 | ||
| 211 | void grail_filter_abs_events(struct grail *ge, int usage) | 214 | void grail_filter_abs_events(struct grail *ge, int usage) |
