blob: 7c9ada6468660b441a098d92cc6d2ca4aae280bd [file] [log] [blame]
Kristian Høgsberg558949b2011-12-21 22:54:49 -05001/*
2 * Copyright © 2011 Benjamin Franzke
3 * Copyright © 2011 Intel Corporation
Marius Vlad539c5a62021-08-13 18:18:34 +03004 * Copyright © 2021 Collabora, Ltd.
Kristian Høgsberg558949b2011-12-21 22:54:49 -05005 *
Bryce Harrington1f6b0d12015-06-10 22:48:59 -07006 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
Kristian Høgsberg558949b2011-12-21 22:54:49 -050012 *
Bryce Harrington1f6b0d12015-06-10 22:48:59 -070013 * The above copyright notice and this permission notice (including the next
14 * paragraph) shall be included in all copies or substantial portions of the
15 * Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 * DEALINGS IN THE SOFTWARE.
Kristian Høgsberg558949b2011-12-21 22:54:49 -050024 */
25
Bryce Harringtonb4dae9b2016-06-15 18:13:07 -070026#include "config.h"
Kristian Høgsbergc7d2c4c2013-08-26 14:43:17 -070027
Jussi Kukkonen649bbce2016-07-19 14:16:27 +030028#include <stdint.h>
Kristian Høgsberg558949b2011-12-21 22:54:49 -050029#include <stdio.h>
30#include <stdlib.h>
31#include <string.h>
32#include <stdbool.h>
33#include <assert.h>
34#include <unistd.h>
Antonio Borneo39578632019-04-26 23:57:31 +020035#include <errno.h>
Kristian Høgsberg558949b2011-12-21 22:54:49 -050036#include <sys/mman.h>
37
38#include <wayland-client.h>
Jon Cruz35b2eaa2015-06-15 15:37:08 -070039#include "shared/helpers.h"
Marius Vlad539c5a62021-08-13 18:18:34 +030040#include "shared/xalloc.h"
Jon Cruz4678bab2015-06-15 15:37:07 -070041#include "shared/os-compatibility.h"
Kristian Høgsberg558949b2011-12-21 22:54:49 -050042
Marius Vlad539c5a62021-08-13 18:18:34 +030043#include "xdg-shell-client-protocol.h"
44
Ander Conselvan de Oliveirac3f03f52014-05-07 11:57:27 +030045struct seat {
46 struct touch *touch;
47 struct wl_seat *seat;
48 struct wl_touch *wl_touch;
49};
50
Marius Vlad539c5a62021-08-13 18:18:34 +030051struct buffer {
52 struct wl_buffer *buffer;
53 void *data;
54};
55
Kristian Høgsberg558949b2011-12-21 22:54:49 -050056struct touch {
57 struct wl_display *display;
Kristian Høgsbergfa80e112012-10-10 21:34:26 -040058 struct wl_registry *registry;
Kristian Høgsberg558949b2011-12-21 22:54:49 -050059 struct wl_compositor *compositor;
Marius Vlad539c5a62021-08-13 18:18:34 +030060 struct xdg_wm_base *wm_base;
Kristian Høgsberg558949b2011-12-21 22:54:49 -050061 struct wl_shm *shm;
Kristian Høgsberg558949b2011-12-21 22:54:49 -050062 struct wl_surface *surface;
Marius Vlad539c5a62021-08-13 18:18:34 +030063 struct xdg_surface *xdg_surface;
64 struct xdg_toplevel *xdg_toplevel;
65 struct buffer *buffer;
Kristian Høgsberg558949b2011-12-21 22:54:49 -050066 int width, height;
Emmanuel Gil Peyrot152405b2021-10-14 11:43:46 +020067 bool running;
Marius Vlad539c5a62021-08-13 18:18:34 +030068 bool wait_for_configure;
Emmanuel Gil Peyrot152405b2021-10-14 11:43:46 +020069 bool has_argb;
Kristian Høgsberg558949b2011-12-21 22:54:49 -050070};
71
Marius Vlad539c5a62021-08-13 18:18:34 +030072static struct buffer *
Kristian Høgsberg558949b2011-12-21 22:54:49 -050073create_shm_buffer(struct touch *touch)
74{
Kristian Høgsberg16626282012-04-03 11:21:27 -040075 struct wl_shm_pool *pool;
Kristian Høgsberg558949b2011-12-21 22:54:49 -050076 int fd, size, stride;
Marius Vlad539c5a62021-08-13 18:18:34 +030077 void *data;
78 struct buffer *buffer = NULL;
79
80 buffer = zalloc(sizeof(*buffer));
81 if (!buffer)
82 return NULL;
Kristian Høgsberg558949b2011-12-21 22:54:49 -050083
Kristian Høgsberg558949b2011-12-21 22:54:49 -050084 stride = touch->width * 4;
85 size = stride * touch->height;
Pekka Paalanen1da1b8f2012-06-06 16:59:43 +030086
87 fd = os_create_anonymous_file(size);
88 if (fd < 0) {
Antonio Borneo39578632019-04-26 23:57:31 +020089 fprintf(stderr, "creating a buffer file for %d B failed: %s\n",
90 size, strerror(errno));
Kristian Høgsberg558949b2011-12-21 22:54:49 -050091 exit(1);
92 }
93
Marius Vlad539c5a62021-08-13 18:18:34 +030094 data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
95 if (data == MAP_FAILED) {
Antonio Borneo39578632019-04-26 23:57:31 +020096 fprintf(stderr, "mmap failed: %s\n", strerror(errno));
Kristian Høgsberg558949b2011-12-21 22:54:49 -050097 close(fd);
Marius Vlad539c5a62021-08-13 18:18:34 +030098 return NULL;
Kristian Høgsberg558949b2011-12-21 22:54:49 -050099 }
100
Kristian Høgsberg16626282012-04-03 11:21:27 -0400101 pool = wl_shm_create_pool(touch->shm, fd, size);
Marius Vlad539c5a62021-08-13 18:18:34 +0300102 buffer->buffer =
Kristian Høgsberg16626282012-04-03 11:21:27 -0400103 wl_shm_pool_create_buffer(pool, 0,
104 touch->width, touch->height, stride,
105 WL_SHM_FORMAT_ARGB8888);
Marius Vlad539c5a62021-08-13 18:18:34 +0300106
Kristian Høgsberg16626282012-04-03 11:21:27 -0400107 wl_shm_pool_destroy(pool);
Kristian Høgsberg558949b2011-12-21 22:54:49 -0500108
Marius Vlad539c5a62021-08-13 18:18:34 +0300109 buffer->data = data;
Kristian Høgsberg558949b2011-12-21 22:54:49 -0500110 close(fd);
Marius Vlad539c5a62021-08-13 18:18:34 +0300111
112 return buffer;
113}
114
115static void
116initial_redraw(void *data)
117{
118 struct touch *touch = data;
119 struct buffer *buffer = NULL;
120
121 buffer = create_shm_buffer(touch);
122 assert(buffer);
123
124 touch->buffer = buffer;
125
126 /* paint the "work-area" */
127 memset(buffer->data, 64, touch->width * touch->height * 4);
128
129 wl_surface_attach(touch->surface, buffer->buffer, 0, 0);
130 wl_surface_damage(touch->surface, 0, 0, touch->width, touch->height);
131 wl_surface_commit(touch->surface);
Kristian Høgsberg558949b2011-12-21 22:54:49 -0500132}
133
134static void
135shm_format(void *data, struct wl_shm *wl_shm, uint32_t format)
136{
137 struct touch *touch = data;
138
Kristian Høgsberg8e81df42012-01-11 14:24:46 -0500139 if (format == WL_SHM_FORMAT_ARGB8888)
Emmanuel Gil Peyrotb94219a2021-10-14 11:41:28 +0200140 touch->has_argb = true;
Kristian Høgsberg558949b2011-12-21 22:54:49 -0500141}
142
Stefan Schmidt85c40f22013-08-05 13:50:50 +0100143struct wl_shm_listener shm_listener = {
Kristian Høgsberg558949b2011-12-21 22:54:49 -0500144 shm_format
145};
146
147
148static void
Kristian Høgsberg558949b2011-12-21 22:54:49 -0500149touch_paint(struct touch *touch, int32_t x, int32_t y, int32_t id)
150{
151 uint32_t *p, c;
152 static const uint32_t colors[] = {
153 0xffff0000,
154 0xffffff00,
155 0xff0000ff,
156 0xffff00ff,
Pekka Paalanen55b7cb22012-07-31 13:21:11 +0300157 0xff00ff00,
158 0xff00ffff,
Kristian Høgsberg558949b2011-12-21 22:54:49 -0500159 };
160
Kristian Høgsberg875ab9e2012-03-30 11:52:39 -0400161 if (id < (int32_t) ARRAY_LENGTH(colors))
Kristian Høgsberg558949b2011-12-21 22:54:49 -0500162 c = colors[id];
163 else
164 c = 0xffffffff;
165
Pekka Paalanen07684192012-07-31 13:21:12 +0300166 if (x < 2 || x >= touch->width - 2 ||
167 y < 2 || y >= touch->height - 2)
Kristian Høgsberg558949b2011-12-21 22:54:49 -0500168 return;
169
Marius Vlad539c5a62021-08-13 18:18:34 +0300170 p = ((uint32_t *) touch->buffer->data) + (x - 2) + (y - 2) * touch->width;
Pekka Paalanen55b7cb22012-07-31 13:21:11 +0300171 p[2] = c;
172 p += touch->width;
Kristian Høgsberg558949b2011-12-21 22:54:49 -0500173 p[1] = c;
Pekka Paalanen55b7cb22012-07-31 13:21:11 +0300174 p[2] = c;
175 p[3] = c;
Kristian Høgsberg558949b2011-12-21 22:54:49 -0500176 p += touch->width;
177 p[0] = c;
178 p[1] = c;
179 p[2] = c;
Pekka Paalanen55b7cb22012-07-31 13:21:11 +0300180 p[3] = c;
181 p[4] = c;
Kristian Høgsberg558949b2011-12-21 22:54:49 -0500182 p += touch->width;
183 p[1] = c;
Pekka Paalanen55b7cb22012-07-31 13:21:11 +0300184 p[2] = c;
185 p[3] = c;
186 p += touch->width;
187 p[2] = c;
Kristian Høgsberg558949b2011-12-21 22:54:49 -0500188
Marius Vlad539c5a62021-08-13 18:18:34 +0300189 wl_surface_attach(touch->surface, touch->buffer->buffer, 0, 0);
Pekka Paalanen76fc57e2012-07-31 13:21:13 +0300190 wl_surface_damage(touch->surface, x - 2, y - 2, 5, 5);
Pekka Paalanen8e159182012-10-10 12:49:25 +0300191 /* todo: We could queue up more damage before committing, if there
192 * are more input events to handle.
193 */
194 wl_surface_commit(touch->surface);
Kristian Høgsberg558949b2011-12-21 22:54:49 -0500195}
196
197static void
Daniel Stone37816df2012-05-16 18:45:18 +0100198touch_handle_down(void *data, struct wl_touch *wl_touch,
199 uint32_t serial, uint32_t time, struct wl_surface *surface,
200 int32_t id, wl_fixed_t x_w, wl_fixed_t y_w)
Kristian Høgsberg558949b2011-12-21 22:54:49 -0500201{
202 struct touch *touch = data;
Kristian Høgsberg80680c72012-05-10 12:21:37 -0400203 float x = wl_fixed_to_double(x_w);
204 float y = wl_fixed_to_double(y_w);
Kristian Høgsberg558949b2011-12-21 22:54:49 -0500205
206 touch_paint(touch, x, y, id);
207}
208
209static void
Daniel Stone37816df2012-05-16 18:45:18 +0100210touch_handle_up(void *data, struct wl_touch *wl_touch,
211 uint32_t serial, uint32_t time, int32_t id)
Kristian Høgsberg558949b2011-12-21 22:54:49 -0500212{
213}
214
215static void
Daniel Stone37816df2012-05-16 18:45:18 +0100216touch_handle_motion(void *data, struct wl_touch *wl_touch,
217 uint32_t time, int32_t id, wl_fixed_t x_w, wl_fixed_t y_w)
Kristian Høgsberg558949b2011-12-21 22:54:49 -0500218{
219 struct touch *touch = data;
Kristian Høgsberg80680c72012-05-10 12:21:37 -0400220 float x = wl_fixed_to_double(x_w);
221 float y = wl_fixed_to_double(y_w);
Kristian Høgsberg558949b2011-12-21 22:54:49 -0500222
223 touch_paint(touch, x, y, id);
224}
225
226static void
Daniel Stone37816df2012-05-16 18:45:18 +0100227touch_handle_frame(void *data, struct wl_touch *wl_touch)
Kristian Høgsberg558949b2011-12-21 22:54:49 -0500228{
229}
230
231static void
Daniel Stone37816df2012-05-16 18:45:18 +0100232touch_handle_cancel(void *data, struct wl_touch *wl_touch)
Kristian Høgsberg558949b2011-12-21 22:54:49 -0500233{
234}
235
Daniel Stone37816df2012-05-16 18:45:18 +0100236static const struct wl_touch_listener touch_listener = {
237 touch_handle_down,
238 touch_handle_up,
239 touch_handle_motion,
240 touch_handle_frame,
241 touch_handle_cancel,
242};
243
244static void
Ander Conselvan de Oliveirac3f03f52014-05-07 11:57:27 +0300245seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
Daniel Stone37816df2012-05-16 18:45:18 +0100246 enum wl_seat_capability caps)
247{
Ander Conselvan de Oliveirac3f03f52014-05-07 11:57:27 +0300248 struct seat *seat = data;
249 struct touch *touch = seat->touch;
Daniel Stone37816df2012-05-16 18:45:18 +0100250
Ander Conselvan de Oliveirac3f03f52014-05-07 11:57:27 +0300251 if ((caps & WL_SEAT_CAPABILITY_TOUCH) && !seat->wl_touch) {
252 seat->wl_touch = wl_seat_get_touch(wl_seat);
253 wl_touch_set_user_data(seat->wl_touch, touch);
254 wl_touch_add_listener(seat->wl_touch, &touch_listener, touch);
255 } else if (!(caps & WL_SEAT_CAPABILITY_TOUCH) && seat->wl_touch) {
256 wl_touch_destroy(seat->wl_touch);
257 seat->wl_touch = NULL;
Daniel Stone37816df2012-05-16 18:45:18 +0100258 }
259}
260
261static const struct wl_seat_listener seat_listener = {
262 seat_handle_capabilities,
Kristian Høgsberg558949b2011-12-21 22:54:49 -0500263};
264
265static void
Ander Conselvan de Oliveirac3f03f52014-05-07 11:57:27 +0300266add_seat(struct touch *touch, uint32_t name, uint32_t version)
267{
268 struct seat *seat;
269
270 seat = malloc(sizeof *seat);
271 assert(seat);
272
273 seat->touch = touch;
274 seat->wl_touch = NULL;
275 seat->seat = wl_registry_bind(touch->registry, name,
276 &wl_seat_interface, 1);
277 wl_seat_add_listener(seat->seat, &seat_listener, seat);
278}
279
280static void
Marius Vlad539c5a62021-08-13 18:18:34 +0300281handle_xdg_surface_configure(void *data, struct xdg_surface *surface,
282 uint32_t serial)
Pekka Paalanen7e94a982012-07-31 13:21:10 +0300283{
Marius Vlad539c5a62021-08-13 18:18:34 +0300284 struct touch *touch = data;
285
286 xdg_surface_ack_configure(surface, serial);
287
288 if (touch->wait_for_configure) {
289 initial_redraw(touch);
290 touch->wait_for_configure = false;
291 }
Pekka Paalanen7e94a982012-07-31 13:21:10 +0300292}
293
Marius Vlad539c5a62021-08-13 18:18:34 +0300294static const struct xdg_surface_listener xdg_surface_listener = {
295 handle_xdg_surface_configure,
296};
297
Pekka Paalanen7e94a982012-07-31 13:21:10 +0300298static void
Marius Vlad539c5a62021-08-13 18:18:34 +0300299xdg_wm_base_ping(void *data, struct xdg_wm_base *shell, uint32_t serial)
Pekka Paalanen7e94a982012-07-31 13:21:10 +0300300{
Marius Vlad539c5a62021-08-13 18:18:34 +0300301 xdg_wm_base_pong(shell, serial);
Pekka Paalanen7e94a982012-07-31 13:21:10 +0300302}
303
Marius Vlad539c5a62021-08-13 18:18:34 +0300304static const struct xdg_wm_base_listener wm_base_listener = {
305 xdg_wm_base_ping,
Pekka Paalanen7e94a982012-07-31 13:21:10 +0300306};
307
308static void
Kristian Høgsbergfa80e112012-10-10 21:34:26 -0400309handle_global(void *data, struct wl_registry *registry,
310 uint32_t name, const char *interface, uint32_t version)
Kristian Høgsberg558949b2011-12-21 22:54:49 -0500311{
312 struct touch *touch = data;
313
314 if (strcmp(interface, "wl_compositor") == 0) {
315 touch->compositor =
Kristian Høgsbergfa80e112012-10-10 21:34:26 -0400316 wl_registry_bind(registry, name,
317 &wl_compositor_interface, 1);
Marius Vlad539c5a62021-08-13 18:18:34 +0300318 } else if (strcmp(interface, "xdg_wm_base") == 0) {
319 touch->wm_base =
Kristian Høgsbergfa80e112012-10-10 21:34:26 -0400320 wl_registry_bind(registry, name,
Marius Vlad539c5a62021-08-13 18:18:34 +0300321 &xdg_wm_base_interface, 1);
322 xdg_wm_base_add_listener(touch->wm_base,
323 &wm_base_listener, touch);
Kristian Høgsberg558949b2011-12-21 22:54:49 -0500324 } else if (strcmp(interface, "wl_shm") == 0) {
Kristian Høgsbergfa80e112012-10-10 21:34:26 -0400325 touch->shm = wl_registry_bind(registry, name,
326 &wl_shm_interface, 1);
Stefan Schmidt85c40f22013-08-05 13:50:50 +0100327 wl_shm_add_listener(touch->shm, &shm_listener, touch);
Daniel Stone37816df2012-05-16 18:45:18 +0100328 } else if (strcmp(interface, "wl_seat") == 0) {
Ander Conselvan de Oliveirac3f03f52014-05-07 11:57:27 +0300329 add_seat(touch, name, version);
Kristian Høgsberg558949b2011-12-21 22:54:49 -0500330 }
331}
332
Pekka Paalanen0eab05d2013-01-22 14:53:55 +0200333static void
334handle_global_remove(void *data, struct wl_registry *registry, uint32_t name)
335{
336}
337
Kristian Høgsbergfa80e112012-10-10 21:34:26 -0400338static const struct wl_registry_listener registry_listener = {
Pekka Paalanen0eab05d2013-01-22 14:53:55 +0200339 handle_global,
340 handle_global_remove
Kristian Høgsbergfa80e112012-10-10 21:34:26 -0400341};
Kristian Høgsberg558949b2011-12-21 22:54:49 -0500342
Marius Vlad539c5a62021-08-13 18:18:34 +0300343static void
344handle_toplevel_configure(void *data, struct xdg_toplevel *xdg_toplevel,
345 int32_t width, int32_t height,
346 struct wl_array *state)
347{
348}
349
350static void
351handle_toplevel_close(void *data, struct xdg_toplevel *xdg_toplevel)
352{
Emmanuel Gil Peyrot152405b2021-10-14 11:43:46 +0200353 struct touch *touch = data;
354 touch->running = false;
Marius Vlad539c5a62021-08-13 18:18:34 +0300355}
356
357static const struct xdg_toplevel_listener xdg_toplevel_listener = {
358 handle_toplevel_configure,
359 handle_toplevel_close,
360};
361
Kristian Høgsberg558949b2011-12-21 22:54:49 -0500362static struct touch *
363touch_create(int width, int height)
364{
365 struct touch *touch;
366
367 touch = malloc(sizeof *touch);
Kristian Høgsbergc85a9172013-08-15 11:40:30 -0700368 if (touch == NULL) {
369 fprintf(stderr, "out of memory\n");
370 exit(1);
371 }
Kristian Høgsberg558949b2011-12-21 22:54:49 -0500372 touch->display = wl_display_connect(NULL);
373 assert(touch->display);
374
Emmanuel Gil Peyrotb94219a2021-10-14 11:41:28 +0200375 touch->has_argb = false;
Kristian Høgsbergfa80e112012-10-10 21:34:26 -0400376 touch->registry = wl_display_get_registry(touch->display);
377 wl_registry_add_listener(touch->registry, &registry_listener, touch);
378 wl_display_dispatch(touch->display);
Kristian Høgsberg558949b2011-12-21 22:54:49 -0500379 wl_display_roundtrip(touch->display);
380
381 if (!touch->has_argb) {
382 fprintf(stderr, "WL_SHM_FORMAT_ARGB32 not available\n");
383 exit(1);
384 }
385
Marius Vlad539c5a62021-08-13 18:18:34 +0300386 if (!touch->wm_base) {
387 fprintf(stderr, "xdg-shell required!\n");
388 exit(1);
389 }
390
Kristian Høgsberg558949b2011-12-21 22:54:49 -0500391 touch->width = width;
392 touch->height = height;
393 touch->surface = wl_compositor_create_surface(touch->compositor);
Kristian Høgsberg558949b2011-12-21 22:54:49 -0500394
Marius Vlad539c5a62021-08-13 18:18:34 +0300395 touch->xdg_surface =
396 xdg_wm_base_get_xdg_surface(touch->wm_base, touch->surface);
397 assert(touch->xdg_surface);
Pekka Paalanen7e94a982012-07-31 13:21:10 +0300398
Marius Vlad539c5a62021-08-13 18:18:34 +0300399 xdg_surface_add_listener(touch->xdg_surface, &xdg_surface_listener, touch);
Kristian Høgsberg558949b2011-12-21 22:54:49 -0500400
Marius Vlad539c5a62021-08-13 18:18:34 +0300401 touch->xdg_toplevel = xdg_surface_get_toplevel(touch->xdg_surface);
402 assert(touch->xdg_toplevel);
403 xdg_toplevel_add_listener(touch->xdg_toplevel,
404 &xdg_toplevel_listener, touch);
405 xdg_toplevel_set_title(touch->xdg_toplevel, "simple-touch");
406 xdg_toplevel_set_app_id(touch->xdg_toplevel, "simple-touch");
407 touch->wait_for_configure = true;
Pekka Paalanenc9e00c02012-10-10 12:49:24 +0300408 wl_surface_commit(touch->surface);
Kristian Høgsberg558949b2011-12-21 22:54:49 -0500409
Emmanuel Gil Peyrot152405b2021-10-14 11:43:46 +0200410 touch->running = true;
411
Kristian Høgsberg558949b2011-12-21 22:54:49 -0500412 return touch;
413}
414
Marius Vlad539c5a62021-08-13 18:18:34 +0300415static void
416destroy_touch(struct touch *touch)
417{
418 if (touch->buffer->buffer)
419 wl_buffer_destroy(touch->buffer->buffer);
420
421 if (touch->xdg_toplevel)
422 xdg_toplevel_destroy(touch->xdg_toplevel);
423 if (touch->xdg_surface)
424 xdg_surface_destroy(touch->xdg_surface);
425 if (touch->wm_base)
426 xdg_wm_base_destroy(touch->wm_base);
427 if (touch->shm)
428 wl_shm_destroy(touch->shm);
429 if (touch->compositor)
430 wl_compositor_destroy(touch->compositor);
431
432
433 wl_surface_destroy(touch->surface);
434 free(touch->buffer);
435 free(touch);
436}
437
Kristian Høgsberg558949b2011-12-21 22:54:49 -0500438int
439main(int argc, char **argv)
440{
441 struct touch *touch;
Kristian Høgsberga17f7a12012-10-16 13:16:10 -0400442 int ret = 0;
Kristian Høgsberg558949b2011-12-21 22:54:49 -0500443
444 touch = touch_create(600, 500);
445
Emmanuel Gil Peyrot152405b2021-10-14 11:43:46 +0200446 while (ret != -1 && touch->running)
Kristian Høgsberga17f7a12012-10-16 13:16:10 -0400447 ret = wl_display_dispatch(touch->display);
Kristian Høgsberg558949b2011-12-21 22:54:49 -0500448
Marius Vlad539c5a62021-08-13 18:18:34 +0300449 destroy_touch(touch);
Kristian Høgsberg558949b2011-12-21 22:54:49 -0500450 return 0;
451}