~fginther/grail/grail-2.0.1.1-oneiric

« back to all changes in this revision

Viewing changes to tools/grail-transform.c

  • Committer: Francis Ginther
  • Date: 2012-08-22 18:35:11 UTC
  • mfrom: (20.2.19 upstream)
  • Revision ID: francis.ginther@canonical.com-20120822183511-yxwny2hixhyu2z42
* New upstream microrelease, bug fixes only
  - Rename project to simply 'grail' (LP: #1040218)
* Updated debian/watch file for project rename

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
#include "config.h"
23
23
#include <evemu.h>
24
 
#include <utouch/frame-mtdev.h>
25
 
#include <utouch/frame-xi2.h>
 
24
#include <oif/frame-mtdev.h>
 
25
#include <oif/frame-xi2.h>
26
26
#include <grail.h>
27
27
#include <stdio.h>
28
28
#include <stdlib.h>
37
37
        int fd;
38
38
        struct evemu_device *evemu;
39
39
        struct mtdev *mtdev;
40
 
        utouch_frame_handle fh;
 
40
        oif_frame_handle fh;
41
41
        struct grail *ge;
42
42
 
43
43
        struct grail_coord pos[4];
59
59
 
60
60
static void clear_screen(struct appdata *w)
61
61
{
62
 
        const struct utouch_surface *s = utouch_frame_get_surface(w->fh);
 
62
        const struct oif_surface *s = oif_frame_get_surface(w->fh);
63
63
        int width = s->mapped_max_x - s->mapped_min_x;
64
64
        int height = s->mapped_max_y - s->mapped_min_y;
65
65
        int i;
80
80
static void draw_object(struct appdata *w)
81
81
{
82
82
        static const double frac = 0.04;
83
 
        const struct utouch_surface *s = utouch_frame_get_surface(w->fh);
 
83
        const struct oif_surface *s = oif_frame_get_surface(w->fh);
84
84
        double d = frac * (s->mapped_max_x - s->mapped_min_x);
85
85
        int i;
86
86
 
105
105
}
106
106
 
107
107
static void report_frame(struct appdata *w,
108
 
                         const struct utouch_frame *touch)
 
108
                         const struct oif_frame *touch)
109
109
{
110
110
        const struct grail_frame *frame;
111
111
        const struct grail_element *slot;
201
201
 
202
202
static void set_screen_size_mtdev(struct appdata *w, XEvent *xev)
203
203
{
204
 
        struct utouch_surface *s = utouch_frame_get_surface(w->fh);
 
204
        struct oif_surface *s = oif_frame_get_surface(w->fh);
205
205
        XConfigureEvent *cev = (XConfigureEvent *)xev;
206
206
 
207
207
        s->mapped_min_x = 0;
218
218
 
219
219
static void loop_device_mtdev(struct appdata *w)
220
220
{
221
 
        const struct utouch_frame *tf;
 
221
        const struct oif_frame *tf;
222
222
        struct input_event iev;
223
223
        XEvent xev;
224
224
 
230
230
        while (1) {
231
231
                while (!mtdev_idle(w->mtdev, w->fd, 100)) {
232
232
                        while (mtdev_get(w->mtdev, w->fd, &iev, 1) > 0) {
233
 
                                tf = utouch_frame_pump_mtdev(w->fh, &iev);
 
233
                                tf = oif_frame_pump_mtdev(w->fh, &iev);
234
234
                                report_frame(w, tf);
235
235
                        }
236
236
                }
261
261
        w->mtdev = mtdev_new_open(w->fd);
262
262
        if (!w->mtdev)
263
263
                return -1;
264
 
        w->fh = utouch_frame_new_engine(500, 32, 100);
 
264
        w->fh = oif_frame_new_engine(500, 32, 100);
265
265
        if (!w->fh)
266
266
                return -1;
267
 
        if (utouch_frame_init_mtdev(w->fh, w->evemu))
 
267
        if (oif_frame_init_mtdev(w->fh, w->evemu))
268
268
                return -1;
269
269
        w->ge = grail_new(w->fh, 100, 0);
270
270
        if (!w->ge)
278
278
        loop_device_mtdev(w);
279
279
 
280
280
        grail_delete(w->ge);
281
 
        utouch_frame_delete_engine(w->fh);
 
281
        oif_frame_delete_engine(w->fh);
282
282
        mtdev_close_delete(w->mtdev);
283
283
        evemu_delete(w->evemu);
284
284
 
322
322
 
323
323
static void loop_device_xi2(struct appdata *w, int id)
324
324
{
325
 
        const struct utouch_frame *tf;
 
325
        const struct oif_frame *tf;
326
326
        XIEventMask mask;
327
327
 
328
328
        mask.deviceid = id;
346
346
                if (XGetEventData(w->dsp, cookie) &&
347
347
                    cookie->type == GenericEvent &&
348
348
                    cookie->extension == w->opcode) {
349
 
                        tf = utouch_frame_pump_xi2(w->fh, cookie->data);
 
349
                        tf = oif_frame_pump_xi2(w->fh, cookie->data);
350
350
                        report_frame(w, tf);
351
351
                }
352
352
                XFreeEventData(w->dsp, cookie);
373
373
        if (!dev)
374
374
                return -1;
375
375
 
376
 
        w->fh = utouch_frame_new_engine(500, 32, 100);
 
376
        w->fh = oif_frame_new_engine(500, 32, 100);
377
377
        if (!w->fh)
378
378
                return -1;
379
 
        if (utouch_frame_init_xi2(w->fh, w->dsp, dev))
 
379
        if (oif_frame_init_xi2(w->fh, w->dsp, dev))
380
380
                return -1;
381
381
        w->ge = grail_new(w->fh, 100, 0);
382
382
        if (!w->ge)
385
385
        loop_device_xi2(w, id);
386
386
 
387
387
        grail_delete(w->ge);
388
 
        utouch_frame_delete_engine(w->fh);
 
388
        oif_frame_delete_engine(w->fh);
389
389
 
390
390
        XIFreeDeviceInfo(info);
391
391