Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2011 Benjamin Franzke |
| 3 | * Copyright © 2011 Intel Corporation |
| 4 | * |
| 5 | * Permission to use, copy, modify, distribute, and sell this software and its |
| 6 | * documentation for any purpose is hereby granted without fee, provided that |
| 7 | * the above copyright notice appear in all copies and that both that copyright |
| 8 | * notice and this permission notice appear in supporting documentation, and |
| 9 | * that the name of the copyright holders not be used in advertising or |
| 10 | * publicity pertaining to distribution of the software without specific, |
| 11 | * written prior permission. The copyright holders make no representations |
| 12 | * about the suitability of this software for any purpose. It is provided "as |
| 13 | * is" without express or implied warranty. |
| 14 | * |
| 15 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, |
| 16 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO |
| 17 | * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR |
| 18 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, |
| 19 | * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 20 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE |
| 21 | * OF THIS SOFTWARE. |
| 22 | */ |
| 23 | |
Kristian Høgsberg | c7d2c4c | 2013-08-26 14:43:17 -0700 | [diff] [blame] | 24 | #include <config.h> |
| 25 | |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 26 | #include <stdio.h> |
| 27 | #include <stdlib.h> |
| 28 | #include <string.h> |
| 29 | #include <stdbool.h> |
| 30 | #include <assert.h> |
| 31 | #include <unistd.h> |
| 32 | #include <sys/mman.h> |
| 33 | |
| 34 | #include <wayland-client.h> |
Pekka Paalanen | 1da1b8f | 2012-06-06 16:59:43 +0300 | [diff] [blame] | 35 | #include "../shared/os-compatibility.h" |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 36 | |
Kristian Høgsberg | 5717b6d | 2012-10-19 17:12:38 -0400 | [diff] [blame] | 37 | #define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0]) |
| 38 | |
Ander Conselvan de Oliveira | c3f03f5 | 2014-05-07 11:57:27 +0300 | [diff] [blame^] | 39 | struct seat { |
| 40 | struct touch *touch; |
| 41 | struct wl_seat *seat; |
| 42 | struct wl_touch *wl_touch; |
| 43 | }; |
| 44 | |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 45 | struct touch { |
| 46 | struct wl_display *display; |
Kristian Høgsberg | fa80e11 | 2012-10-10 21:34:26 -0400 | [diff] [blame] | 47 | struct wl_registry *registry; |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 48 | struct wl_compositor *compositor; |
| 49 | struct wl_shell *shell; |
| 50 | struct wl_shm *shm; |
Daniel Stone | 37816df | 2012-05-16 18:45:18 +0100 | [diff] [blame] | 51 | struct wl_pointer *pointer; |
| 52 | struct wl_keyboard *keyboard; |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 53 | struct wl_surface *surface; |
| 54 | struct wl_shell_surface *shell_surface; |
| 55 | struct wl_buffer *buffer; |
| 56 | int has_argb; |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 57 | int width, height; |
| 58 | void *data; |
| 59 | }; |
| 60 | |
| 61 | static void |
| 62 | create_shm_buffer(struct touch *touch) |
| 63 | { |
Kristian Høgsberg | 1662628 | 2012-04-03 11:21:27 -0400 | [diff] [blame] | 64 | struct wl_shm_pool *pool; |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 65 | int fd, size, stride; |
| 66 | |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 67 | stride = touch->width * 4; |
| 68 | size = stride * touch->height; |
Pekka Paalanen | 1da1b8f | 2012-06-06 16:59:43 +0300 | [diff] [blame] | 69 | |
| 70 | fd = os_create_anonymous_file(size); |
| 71 | if (fd < 0) { |
| 72 | fprintf(stderr, "creating a buffer file for %d B failed: %m\n", |
| 73 | size); |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 74 | exit(1); |
| 75 | } |
| 76 | |
| 77 | touch->data = |
| 78 | mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 79 | if (touch->data == MAP_FAILED) { |
| 80 | fprintf(stderr, "mmap failed: %m\n"); |
| 81 | close(fd); |
| 82 | exit(1); |
| 83 | } |
| 84 | |
Kristian Høgsberg | 1662628 | 2012-04-03 11:21:27 -0400 | [diff] [blame] | 85 | pool = wl_shm_create_pool(touch->shm, fd, size); |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 86 | touch->buffer = |
Kristian Høgsberg | 1662628 | 2012-04-03 11:21:27 -0400 | [diff] [blame] | 87 | wl_shm_pool_create_buffer(pool, 0, |
| 88 | touch->width, touch->height, stride, |
| 89 | WL_SHM_FORMAT_ARGB8888); |
| 90 | wl_shm_pool_destroy(pool); |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 91 | |
| 92 | close(fd); |
| 93 | } |
| 94 | |
| 95 | static void |
| 96 | shm_format(void *data, struct wl_shm *wl_shm, uint32_t format) |
| 97 | { |
| 98 | struct touch *touch = data; |
| 99 | |
Kristian Høgsberg | 8e81df4 | 2012-01-11 14:24:46 -0500 | [diff] [blame] | 100 | if (format == WL_SHM_FORMAT_ARGB8888) |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 101 | touch->has_argb = 1; |
| 102 | } |
| 103 | |
Stefan Schmidt | 85c40f2 | 2013-08-05 13:50:50 +0100 | [diff] [blame] | 104 | struct wl_shm_listener shm_listener = { |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 105 | shm_format |
| 106 | }; |
| 107 | |
| 108 | |
| 109 | static void |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 110 | touch_paint(struct touch *touch, int32_t x, int32_t y, int32_t id) |
| 111 | { |
| 112 | uint32_t *p, c; |
| 113 | static const uint32_t colors[] = { |
| 114 | 0xffff0000, |
| 115 | 0xffffff00, |
| 116 | 0xff0000ff, |
| 117 | 0xffff00ff, |
Pekka Paalanen | 55b7cb2 | 2012-07-31 13:21:11 +0300 | [diff] [blame] | 118 | 0xff00ff00, |
| 119 | 0xff00ffff, |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 120 | }; |
| 121 | |
Kristian Høgsberg | 875ab9e | 2012-03-30 11:52:39 -0400 | [diff] [blame] | 122 | if (id < (int32_t) ARRAY_LENGTH(colors)) |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 123 | c = colors[id]; |
| 124 | else |
| 125 | c = 0xffffffff; |
| 126 | |
Pekka Paalanen | 0768419 | 2012-07-31 13:21:12 +0300 | [diff] [blame] | 127 | if (x < 2 || x >= touch->width - 2 || |
| 128 | y < 2 || y >= touch->height - 2) |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 129 | return; |
| 130 | |
Pekka Paalanen | 55b7cb2 | 2012-07-31 13:21:11 +0300 | [diff] [blame] | 131 | p = (uint32_t *) touch->data + (x - 2) + (y - 2) * touch->width; |
| 132 | p[2] = c; |
| 133 | p += touch->width; |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 134 | p[1] = c; |
Pekka Paalanen | 55b7cb2 | 2012-07-31 13:21:11 +0300 | [diff] [blame] | 135 | p[2] = c; |
| 136 | p[3] = c; |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 137 | p += touch->width; |
| 138 | p[0] = c; |
| 139 | p[1] = c; |
| 140 | p[2] = c; |
Pekka Paalanen | 55b7cb2 | 2012-07-31 13:21:11 +0300 | [diff] [blame] | 141 | p[3] = c; |
| 142 | p[4] = c; |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 143 | p += touch->width; |
| 144 | p[1] = c; |
Pekka Paalanen | 55b7cb2 | 2012-07-31 13:21:11 +0300 | [diff] [blame] | 145 | p[2] = c; |
| 146 | p[3] = c; |
| 147 | p += touch->width; |
| 148 | p[2] = c; |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 149 | |
Kristian Høgsberg | 5addaa1 | 2013-07-22 14:32:41 -0700 | [diff] [blame] | 150 | wl_surface_attach(touch->surface, touch->buffer, 0, 0); |
Pekka Paalanen | 76fc57e | 2012-07-31 13:21:13 +0300 | [diff] [blame] | 151 | wl_surface_damage(touch->surface, x - 2, y - 2, 5, 5); |
Pekka Paalanen | 8e15918 | 2012-10-10 12:49:25 +0300 | [diff] [blame] | 152 | /* todo: We could queue up more damage before committing, if there |
| 153 | * are more input events to handle. |
| 154 | */ |
| 155 | wl_surface_commit(touch->surface); |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | static void |
Daniel Stone | 37816df | 2012-05-16 18:45:18 +0100 | [diff] [blame] | 159 | touch_handle_down(void *data, struct wl_touch *wl_touch, |
| 160 | uint32_t serial, uint32_t time, struct wl_surface *surface, |
| 161 | int32_t id, wl_fixed_t x_w, wl_fixed_t y_w) |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 162 | { |
| 163 | struct touch *touch = data; |
Kristian Høgsberg | 80680c7 | 2012-05-10 12:21:37 -0400 | [diff] [blame] | 164 | float x = wl_fixed_to_double(x_w); |
| 165 | float y = wl_fixed_to_double(y_w); |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 166 | |
| 167 | touch_paint(touch, x, y, id); |
| 168 | } |
| 169 | |
| 170 | static void |
Daniel Stone | 37816df | 2012-05-16 18:45:18 +0100 | [diff] [blame] | 171 | touch_handle_up(void *data, struct wl_touch *wl_touch, |
| 172 | uint32_t serial, uint32_t time, int32_t id) |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 173 | { |
| 174 | } |
| 175 | |
| 176 | static void |
Daniel Stone | 37816df | 2012-05-16 18:45:18 +0100 | [diff] [blame] | 177 | touch_handle_motion(void *data, struct wl_touch *wl_touch, |
| 178 | uint32_t time, int32_t id, wl_fixed_t x_w, wl_fixed_t y_w) |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 179 | { |
| 180 | struct touch *touch = data; |
Kristian Høgsberg | 80680c7 | 2012-05-10 12:21:37 -0400 | [diff] [blame] | 181 | float x = wl_fixed_to_double(x_w); |
| 182 | float y = wl_fixed_to_double(y_w); |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 183 | |
| 184 | touch_paint(touch, x, y, id); |
| 185 | } |
| 186 | |
| 187 | static void |
Daniel Stone | 37816df | 2012-05-16 18:45:18 +0100 | [diff] [blame] | 188 | touch_handle_frame(void *data, struct wl_touch *wl_touch) |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 189 | { |
| 190 | } |
| 191 | |
| 192 | static void |
Daniel Stone | 37816df | 2012-05-16 18:45:18 +0100 | [diff] [blame] | 193 | touch_handle_cancel(void *data, struct wl_touch *wl_touch) |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 194 | { |
| 195 | } |
| 196 | |
Daniel Stone | 37816df | 2012-05-16 18:45:18 +0100 | [diff] [blame] | 197 | static const struct wl_touch_listener touch_listener = { |
| 198 | touch_handle_down, |
| 199 | touch_handle_up, |
| 200 | touch_handle_motion, |
| 201 | touch_handle_frame, |
| 202 | touch_handle_cancel, |
| 203 | }; |
| 204 | |
| 205 | static void |
Ander Conselvan de Oliveira | c3f03f5 | 2014-05-07 11:57:27 +0300 | [diff] [blame^] | 206 | seat_handle_capabilities(void *data, struct wl_seat *wl_seat, |
Daniel Stone | 37816df | 2012-05-16 18:45:18 +0100 | [diff] [blame] | 207 | enum wl_seat_capability caps) |
| 208 | { |
Ander Conselvan de Oliveira | c3f03f5 | 2014-05-07 11:57:27 +0300 | [diff] [blame^] | 209 | struct seat *seat = data; |
| 210 | struct touch *touch = seat->touch; |
Daniel Stone | 37816df | 2012-05-16 18:45:18 +0100 | [diff] [blame] | 211 | |
Ander Conselvan de Oliveira | c3f03f5 | 2014-05-07 11:57:27 +0300 | [diff] [blame^] | 212 | if ((caps & WL_SEAT_CAPABILITY_TOUCH) && !seat->wl_touch) { |
| 213 | seat->wl_touch = wl_seat_get_touch(wl_seat); |
| 214 | wl_touch_set_user_data(seat->wl_touch, touch); |
| 215 | wl_touch_add_listener(seat->wl_touch, &touch_listener, touch); |
| 216 | } else if (!(caps & WL_SEAT_CAPABILITY_TOUCH) && seat->wl_touch) { |
| 217 | wl_touch_destroy(seat->wl_touch); |
| 218 | seat->wl_touch = NULL; |
Daniel Stone | 37816df | 2012-05-16 18:45:18 +0100 | [diff] [blame] | 219 | } |
| 220 | } |
| 221 | |
| 222 | static const struct wl_seat_listener seat_listener = { |
| 223 | seat_handle_capabilities, |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 224 | }; |
| 225 | |
| 226 | static void |
Ander Conselvan de Oliveira | c3f03f5 | 2014-05-07 11:57:27 +0300 | [diff] [blame^] | 227 | add_seat(struct touch *touch, uint32_t name, uint32_t version) |
| 228 | { |
| 229 | struct seat *seat; |
| 230 | |
| 231 | seat = malloc(sizeof *seat); |
| 232 | assert(seat); |
| 233 | |
| 234 | seat->touch = touch; |
| 235 | seat->wl_touch = NULL; |
| 236 | seat->seat = wl_registry_bind(touch->registry, name, |
| 237 | &wl_seat_interface, 1); |
| 238 | wl_seat_add_listener(seat->seat, &seat_listener, seat); |
| 239 | } |
| 240 | |
| 241 | static void |
Pekka Paalanen | 7e94a98 | 2012-07-31 13:21:10 +0300 | [diff] [blame] | 242 | handle_ping(void *data, struct wl_shell_surface *shell_surface, |
| 243 | uint32_t serial) |
| 244 | { |
| 245 | wl_shell_surface_pong(shell_surface, serial); |
| 246 | } |
| 247 | |
| 248 | static void |
| 249 | handle_configure(void *data, struct wl_shell_surface *shell_surface, |
| 250 | uint32_t edges, int32_t width, int32_t height) |
| 251 | { |
| 252 | } |
| 253 | |
| 254 | static void |
| 255 | handle_popup_done(void *data, struct wl_shell_surface *shell_surface) |
| 256 | { |
| 257 | } |
| 258 | |
| 259 | static const struct wl_shell_surface_listener shell_surface_listener = { |
| 260 | handle_ping, |
| 261 | handle_configure, |
| 262 | handle_popup_done |
| 263 | }; |
| 264 | |
| 265 | static void |
Kristian Høgsberg | fa80e11 | 2012-10-10 21:34:26 -0400 | [diff] [blame] | 266 | handle_global(void *data, struct wl_registry *registry, |
| 267 | uint32_t name, const char *interface, uint32_t version) |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 268 | { |
| 269 | struct touch *touch = data; |
| 270 | |
| 271 | if (strcmp(interface, "wl_compositor") == 0) { |
| 272 | touch->compositor = |
Kristian Høgsberg | fa80e11 | 2012-10-10 21:34:26 -0400 | [diff] [blame] | 273 | wl_registry_bind(registry, name, |
| 274 | &wl_compositor_interface, 1); |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 275 | } else if (strcmp(interface, "wl_shell") == 0) { |
| 276 | touch->shell = |
Kristian Høgsberg | fa80e11 | 2012-10-10 21:34:26 -0400 | [diff] [blame] | 277 | wl_registry_bind(registry, name, |
| 278 | &wl_shell_interface, 1); |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 279 | } else if (strcmp(interface, "wl_shm") == 0) { |
Kristian Høgsberg | fa80e11 | 2012-10-10 21:34:26 -0400 | [diff] [blame] | 280 | touch->shm = wl_registry_bind(registry, name, |
| 281 | &wl_shm_interface, 1); |
Stefan Schmidt | 85c40f2 | 2013-08-05 13:50:50 +0100 | [diff] [blame] | 282 | wl_shm_add_listener(touch->shm, &shm_listener, touch); |
Daniel Stone | 37816df | 2012-05-16 18:45:18 +0100 | [diff] [blame] | 283 | } else if (strcmp(interface, "wl_seat") == 0) { |
Ander Conselvan de Oliveira | c3f03f5 | 2014-05-07 11:57:27 +0300 | [diff] [blame^] | 284 | add_seat(touch, name, version); |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 285 | } |
| 286 | } |
| 287 | |
Pekka Paalanen | 0eab05d | 2013-01-22 14:53:55 +0200 | [diff] [blame] | 288 | static void |
| 289 | handle_global_remove(void *data, struct wl_registry *registry, uint32_t name) |
| 290 | { |
| 291 | } |
| 292 | |
Kristian Høgsberg | fa80e11 | 2012-10-10 21:34:26 -0400 | [diff] [blame] | 293 | static const struct wl_registry_listener registry_listener = { |
Pekka Paalanen | 0eab05d | 2013-01-22 14:53:55 +0200 | [diff] [blame] | 294 | handle_global, |
| 295 | handle_global_remove |
Kristian Høgsberg | fa80e11 | 2012-10-10 21:34:26 -0400 | [diff] [blame] | 296 | }; |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 297 | |
| 298 | static struct touch * |
| 299 | touch_create(int width, int height) |
| 300 | { |
| 301 | struct touch *touch; |
| 302 | |
| 303 | touch = malloc(sizeof *touch); |
Kristian Høgsberg | c85a917 | 2013-08-15 11:40:30 -0700 | [diff] [blame] | 304 | if (touch == NULL) { |
| 305 | fprintf(stderr, "out of memory\n"); |
| 306 | exit(1); |
| 307 | } |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 308 | touch->display = wl_display_connect(NULL); |
| 309 | assert(touch->display); |
| 310 | |
| 311 | touch->has_argb = 0; |
Kristian Høgsberg | fa80e11 | 2012-10-10 21:34:26 -0400 | [diff] [blame] | 312 | touch->registry = wl_display_get_registry(touch->display); |
| 313 | wl_registry_add_listener(touch->registry, ®istry_listener, touch); |
| 314 | wl_display_dispatch(touch->display); |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 315 | wl_display_roundtrip(touch->display); |
| 316 | |
| 317 | if (!touch->has_argb) { |
| 318 | fprintf(stderr, "WL_SHM_FORMAT_ARGB32 not available\n"); |
| 319 | exit(1); |
| 320 | } |
| 321 | |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 322 | touch->width = width; |
| 323 | touch->height = height; |
| 324 | touch->surface = wl_compositor_create_surface(touch->compositor); |
| 325 | touch->shell_surface = wl_shell_get_shell_surface(touch->shell, |
| 326 | touch->surface); |
| 327 | create_shm_buffer(touch); |
| 328 | |
Pekka Paalanen | 7e94a98 | 2012-07-31 13:21:10 +0300 | [diff] [blame] | 329 | if (touch->shell_surface) { |
| 330 | wl_shell_surface_add_listener(touch->shell_surface, |
| 331 | &shell_surface_listener, touch); |
| 332 | wl_shell_surface_set_toplevel(touch->shell_surface); |
| 333 | } |
| 334 | |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 335 | wl_surface_set_user_data(touch->surface, touch); |
Scott Moreau | 01a9f1b | 2012-10-07 08:56:30 -0600 | [diff] [blame] | 336 | wl_shell_surface_set_title(touch->shell_surface, "simple-touch"); |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 337 | |
| 338 | memset(touch->data, 64, width * height * 4); |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 339 | wl_surface_attach(touch->surface, touch->buffer, 0, 0); |
| 340 | wl_surface_damage(touch->surface, 0, 0, width, height); |
Pekka Paalanen | c9e00c0 | 2012-10-10 12:49:24 +0300 | [diff] [blame] | 341 | wl_surface_commit(touch->surface); |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 342 | |
| 343 | return touch; |
| 344 | } |
| 345 | |
| 346 | int |
| 347 | main(int argc, char **argv) |
| 348 | { |
| 349 | struct touch *touch; |
Kristian Høgsberg | a17f7a1 | 2012-10-16 13:16:10 -0400 | [diff] [blame] | 350 | int ret = 0; |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 351 | |
| 352 | touch = touch_create(600, 500); |
| 353 | |
Kristian Høgsberg | a17f7a1 | 2012-10-16 13:16:10 -0400 | [diff] [blame] | 354 | while (ret != -1) |
| 355 | ret = wl_display_dispatch(touch->display); |
Kristian Høgsberg | 558949b | 2011-12-21 22:54:49 -0500 | [diff] [blame] | 356 | |
| 357 | return 0; |
| 358 | } |