blob: e21439c70af6920c8c626ee3adf14b1de5a94707 [file] [log] [blame]
U. Artie Eoff1ba9b382012-12-07 13:50:32 -08001/*
2 * Copyright © 2012 Intel Corporation
3 *
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that copyright
7 * notice and this permission notice appear in supporting documentation, and
8 * that the name of the copyright holders not be used in advertising or
9 * publicity pertaining to distribution of the software without specific,
10 * written prior permission. The copyright holders make no representations
11 * about the suitability of this software for any purpose. It is provided "as
12 * is" without express or implied warranty.
13 *
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20 * OF THIS SOFTWARE.
21 */
22
Bryce Harrington12cc4052014-11-19 17:18:33 -080023#include "config.h"
Kristian Høgsbergc7d2c4c2013-08-26 14:43:17 -070024
U. Artie Eoff1ba9b382012-12-07 13:50:32 -080025#include <stdlib.h>
26#include <stdio.h>
27#include <string.h>
28#include <unistd.h>
Marek Chalupa4d06d462014-07-16 11:27:06 +020029#include <errno.h>
U. Artie Eoff1ba9b382012-12-07 13:50:32 -080030#include <sys/mman.h>
31
32#include "../shared/os-compatibility.h"
33#include "weston-test-client-helper.h"
34
35int
36surface_contains(struct surface *surface, int x, int y)
37{
38 /* test whether a global x,y point is contained in the surface */
39 int sx = surface->x;
40 int sy = surface->y;
41 int sw = surface->width;
42 int sh = surface->height;
43 return x >= sx && y >= sy && x < sx + sw && y < sy + sh;
44}
45
Kristian Høgsbergdb6dc7d2012-12-11 21:49:13 -050046static void
Pekka Paalanen8aaef7d2013-02-08 17:01:25 +020047frame_callback_handler(void *data, struct wl_callback *callback, uint32_t time)
Kristian Høgsbergdb6dc7d2012-12-11 21:49:13 -050048{
49 int *done = data;
50
51 *done = 1;
52
53 wl_callback_destroy(callback);
54}
55
56static const struct wl_callback_listener frame_listener = {
Pekka Paalanen8aaef7d2013-02-08 17:01:25 +020057 frame_callback_handler
Kristian Høgsbergdb6dc7d2012-12-11 21:49:13 -050058};
59
Pekka Paalanen8aaef7d2013-02-08 17:01:25 +020060struct wl_callback *
61frame_callback_set(struct wl_surface *surface, int *done)
62{
63 struct wl_callback *callback;
64
65 *done = 0;
66 callback = wl_surface_frame(surface);
67 wl_callback_add_listener(callback, &frame_listener, done);
68
69 return callback;
70}
71
Marek Chalupa1740aa82014-07-16 11:32:50 +020072int
73frame_callback_wait_nofail(struct client *client, int *done)
Pekka Paalanen8aaef7d2013-02-08 17:01:25 +020074{
75 while (!*done) {
Marek Chalupa1740aa82014-07-16 11:32:50 +020076 if (wl_display_dispatch(client->wl_display) < 0)
77 return 0;
Pekka Paalanen8aaef7d2013-02-08 17:01:25 +020078 }
Marek Chalupa1740aa82014-07-16 11:32:50 +020079
80 return 1;
Pekka Paalanen8aaef7d2013-02-08 17:01:25 +020081}
82
U. Artie Eoff1ba9b382012-12-07 13:50:32 -080083void
84move_client(struct client *client, int x, int y)
85{
86 struct surface *surface = client->surface;
Kristian Høgsbergdb6dc7d2012-12-11 21:49:13 -050087 int done;
U. Artie Eoff1ba9b382012-12-07 13:50:32 -080088
89 client->surface->x = x;
90 client->surface->y = y;
91 wl_test_move_surface(client->test->wl_test, surface->wl_surface,
92 surface->x, surface->y);
Bryce Harringtoncb50ed22014-12-10 18:33:47 -080093 /* The attach here is necessary because commit() will call configure
Giulio Camuffo82cb5052013-02-28 18:44:54 +010094 * only on surfaces newly attached, and the one that sets the surface
95 * position is the configure. */
96 wl_surface_attach(surface->wl_surface, surface->wl_buffer, 0, 0);
U. Artie Eoff1ba9b382012-12-07 13:50:32 -080097 wl_surface_damage(surface->wl_surface, 0, 0, surface->width,
98 surface->height);
Kristian Høgsbergdb6dc7d2012-12-11 21:49:13 -050099
Pekka Paalanen8aaef7d2013-02-08 17:01:25 +0200100 frame_callback_set(surface->wl_surface, &done);
Kristian Høgsbergdb6dc7d2012-12-11 21:49:13 -0500101
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800102 wl_surface_commit(surface->wl_surface);
103
Pekka Paalanen8aaef7d2013-02-08 17:01:25 +0200104 frame_callback_wait(client, &done);
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800105}
106
Neil Roberts40c0c3f2013-10-29 20:13:45 +0000107int
108get_n_egl_buffers(struct client *client)
109{
110 client->test->n_egl_buffers = -1;
111
112 wl_test_get_n_egl_buffers(client->test->wl_test);
113 wl_display_roundtrip(client->wl_display);
114
115 return client->test->n_egl_buffers;
116}
117
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800118static void
119pointer_handle_enter(void *data, struct wl_pointer *wl_pointer,
120 uint32_t serial, struct wl_surface *wl_surface,
121 wl_fixed_t x, wl_fixed_t y)
122{
123 struct pointer *pointer = data;
124
125 pointer->focus = wl_surface_get_user_data(wl_surface);
126 pointer->x = wl_fixed_to_int(x);
127 pointer->y = wl_fixed_to_int(y);
128
129 fprintf(stderr, "test-client: got pointer enter %d %d, surface %p\n",
130 pointer->x, pointer->y, pointer->focus);
131}
132
133static void
134pointer_handle_leave(void *data, struct wl_pointer *wl_pointer,
135 uint32_t serial, struct wl_surface *wl_surface)
136{
137 struct pointer *pointer = data;
138
139 pointer->focus = NULL;
140
141 fprintf(stderr, "test-client: got pointer leave, surface %p\n",
142 wl_surface_get_user_data(wl_surface));
143}
144
145static void
146pointer_handle_motion(void *data, struct wl_pointer *wl_pointer,
147 uint32_t time, wl_fixed_t x, wl_fixed_t y)
148{
149 struct pointer *pointer = data;
150
151 pointer->x = wl_fixed_to_int(x);
152 pointer->y = wl_fixed_to_int(y);
153
154 fprintf(stderr, "test-client: got pointer motion %d %d\n",
155 pointer->x, pointer->y);
156}
157
158static void
159pointer_handle_button(void *data, struct wl_pointer *wl_pointer,
160 uint32_t serial, uint32_t time, uint32_t button,
161 uint32_t state)
162{
163 struct pointer *pointer = data;
164
165 pointer->button = button;
166 pointer->state = state;
167
168 fprintf(stderr, "test-client: got pointer button %u %u\n",
169 button, state);
170}
171
172static void
173pointer_handle_axis(void *data, struct wl_pointer *wl_pointer,
174 uint32_t time, uint32_t axis, wl_fixed_t value)
175{
Kristian Høgsberg4c8ce202013-10-09 14:23:00 -0700176 fprintf(stderr, "test-client: got pointer axis %u %f\n",
177 axis, wl_fixed_to_double(value));
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800178}
179
180static const struct wl_pointer_listener pointer_listener = {
181 pointer_handle_enter,
182 pointer_handle_leave,
183 pointer_handle_motion,
184 pointer_handle_button,
185 pointer_handle_axis,
186};
187
188static void
189keyboard_handle_keymap(void *data, struct wl_keyboard *wl_keyboard,
190 uint32_t format, int fd, uint32_t size)
191{
192 close(fd);
193
194 fprintf(stderr, "test-client: got keyboard keymap\n");
195}
196
197static void
198keyboard_handle_enter(void *data, struct wl_keyboard *wl_keyboard,
199 uint32_t serial, struct wl_surface *wl_surface,
200 struct wl_array *keys)
201{
202 struct keyboard *keyboard = data;
203
204 keyboard->focus = wl_surface_get_user_data(wl_surface);
205
206 fprintf(stderr, "test-client: got keyboard enter, surface %p\n",
207 keyboard->focus);
208}
209
210static void
211keyboard_handle_leave(void *data, struct wl_keyboard *wl_keyboard,
212 uint32_t serial, struct wl_surface *wl_surface)
213{
214 struct keyboard *keyboard = data;
215
216 keyboard->focus = NULL;
217
218 fprintf(stderr, "test-client: got keyboard leave, surface %p\n",
219 wl_surface_get_user_data(wl_surface));
220}
221
222static void
223keyboard_handle_key(void *data, struct wl_keyboard *wl_keyboard,
224 uint32_t serial, uint32_t time, uint32_t key,
225 uint32_t state)
226{
227 struct keyboard *keyboard = data;
228
229 keyboard->key = key;
230 keyboard->state = state;
231
232 fprintf(stderr, "test-client: got keyboard key %u %u\n", key, state);
233}
234
235static void
236keyboard_handle_modifiers(void *data, struct wl_keyboard *wl_keyboard,
237 uint32_t serial, uint32_t mods_depressed,
238 uint32_t mods_latched, uint32_t mods_locked,
239 uint32_t group)
240{
241 struct keyboard *keyboard = data;
242
243 keyboard->mods_depressed = mods_depressed;
244 keyboard->mods_latched = mods_latched;
245 keyboard->mods_locked = mods_locked;
246 keyboard->group = group;
247
248 fprintf(stderr, "test-client: got keyboard modifiers %u %u %u %u\n",
249 mods_depressed, mods_latched, mods_locked, group);
250}
251
252static const struct wl_keyboard_listener keyboard_listener = {
253 keyboard_handle_keymap,
254 keyboard_handle_enter,
255 keyboard_handle_leave,
256 keyboard_handle_key,
257 keyboard_handle_modifiers,
258};
259
260static void
261surface_enter(void *data,
262 struct wl_surface *wl_surface, struct wl_output *output)
263{
264 struct surface *surface = data;
265
266 surface->output = wl_output_get_user_data(output);
267
268 fprintf(stderr, "test-client: got surface enter output %p\n",
269 surface->output);
270}
271
272static void
273surface_leave(void *data,
274 struct wl_surface *wl_surface, struct wl_output *output)
275{
276 struct surface *surface = data;
277
278 surface->output = NULL;
279
280 fprintf(stderr, "test-client: got surface leave output %p\n",
281 wl_output_get_user_data(output));
282}
283
284static const struct wl_surface_listener surface_listener = {
285 surface_enter,
286 surface_leave
287};
288
Pekka Paalanen32ac9b92013-02-08 17:01:26 +0200289struct wl_buffer *
290create_shm_buffer(struct client *client, int width, int height, void **pixels)
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800291{
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800292 struct wl_shm *shm = client->wl_shm;
Pekka Paalanen32ac9b92013-02-08 17:01:26 +0200293 int stride = width * 4;
294 int size = stride * height;
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800295 struct wl_shm_pool *pool;
Pekka Paalanen32ac9b92013-02-08 17:01:26 +0200296 struct wl_buffer *buffer;
297 int fd;
298 void *data;
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800299
300 fd = os_create_anonymous_file(size);
301 assert(fd >= 0);
302
Pekka Paalanen32ac9b92013-02-08 17:01:26 +0200303 data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
304 if (data == MAP_FAILED) {
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800305 close(fd);
Pekka Paalanen32ac9b92013-02-08 17:01:26 +0200306 assert(data != MAP_FAILED);
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800307 }
308
309 pool = wl_shm_create_pool(shm, fd, size);
Pekka Paalanen32ac9b92013-02-08 17:01:26 +0200310 buffer = wl_shm_pool_create_buffer(pool, 0, width, height, stride,
311 WL_SHM_FORMAT_ARGB8888);
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800312 wl_shm_pool_destroy(pool);
313
314 close(fd);
Pekka Paalanen32ac9b92013-02-08 17:01:26 +0200315
316 if (pixels)
317 *pixels = data;
318
319 return buffer;
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800320}
321
322static void
323shm_format(void *data, struct wl_shm *wl_shm, uint32_t format)
324{
325 struct client *client = data;
326
327 if (format == WL_SHM_FORMAT_ARGB8888)
328 client->has_argb = 1;
329}
330
331struct wl_shm_listener shm_listener = {
332 shm_format
333};
334
335static void
336test_handle_pointer_position(void *data, struct wl_test *wl_test,
337 wl_fixed_t x, wl_fixed_t y)
338{
339 struct test *test = data;
340 test->pointer_x = wl_fixed_to_int(x);
341 test->pointer_y = wl_fixed_to_int(y);
342
343 fprintf(stderr, "test-client: got global pointer %d %d\n",
344 test->pointer_x, test->pointer_y);
345}
346
Neil Roberts40c0c3f2013-10-29 20:13:45 +0000347static void
348test_handle_n_egl_buffers(void *data, struct wl_test *wl_test, uint32_t n)
349{
350 struct test *test = data;
351
352 test->n_egl_buffers = n;
353}
354
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800355static const struct wl_test_listener test_listener = {
Neil Roberts40c0c3f2013-10-29 20:13:45 +0000356 test_handle_pointer_position,
357 test_handle_n_egl_buffers,
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800358};
359
360static void
361seat_handle_capabilities(void *data, struct wl_seat *seat,
362 enum wl_seat_capability caps)
363{
364 struct input *input = data;
365 struct pointer *pointer;
366 struct keyboard *keyboard;
367
368 if ((caps & WL_SEAT_CAPABILITY_POINTER) && !input->pointer) {
Kristian Høgsbergc1b244f2013-10-09 14:01:23 -0700369 pointer = xzalloc(sizeof *pointer);
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800370 pointer->wl_pointer = wl_seat_get_pointer(seat);
371 wl_pointer_set_user_data(pointer->wl_pointer, pointer);
372 wl_pointer_add_listener(pointer->wl_pointer, &pointer_listener,
373 pointer);
374 input->pointer = pointer;
375 } else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && input->pointer) {
376 wl_pointer_destroy(input->pointer->wl_pointer);
377 free(input->pointer);
378 input->pointer = NULL;
379 }
380
381 if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !input->keyboard) {
Kristian Høgsbergc1b244f2013-10-09 14:01:23 -0700382 keyboard = xzalloc(sizeof *keyboard);
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800383 keyboard->wl_keyboard = wl_seat_get_keyboard(seat);
384 wl_keyboard_set_user_data(keyboard->wl_keyboard, keyboard);
385 wl_keyboard_add_listener(keyboard->wl_keyboard, &keyboard_listener,
386 keyboard);
387 input->keyboard = keyboard;
388 } else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && input->keyboard) {
389 wl_keyboard_destroy(input->keyboard->wl_keyboard);
390 free(input->keyboard);
391 input->keyboard = NULL;
392 }
393}
394
395static const struct wl_seat_listener seat_listener = {
396 seat_handle_capabilities,
397};
398
399static void
400output_handle_geometry(void *data,
401 struct wl_output *wl_output,
402 int x, int y,
403 int physical_width,
404 int physical_height,
405 int subpixel,
406 const char *make,
407 const char *model,
408 int32_t transform)
409{
410 struct output *output = data;
411
412 output->x = x;
413 output->y = y;
414}
415
416static void
417output_handle_mode(void *data,
418 struct wl_output *wl_output,
419 uint32_t flags,
420 int width,
421 int height,
422 int refresh)
423{
424 struct output *output = data;
425
426 if (flags & WL_OUTPUT_MODE_CURRENT) {
427 output->width = width;
428 output->height = height;
429 }
430}
431
432static const struct wl_output_listener output_listener = {
433 output_handle_geometry,
434 output_handle_mode
435};
436
437static void
438handle_global(void *data, struct wl_registry *registry,
439 uint32_t id, const char *interface, uint32_t version)
440{
441 struct client *client = data;
442 struct input *input;
443 struct output *output;
444 struct test *test;
Kristian Høgsberg1cb3df42012-12-11 23:03:56 -0500445 struct global *global;
446
Kristian Høgsbergc1b244f2013-10-09 14:01:23 -0700447 global = xzalloc(sizeof *global);
Kristian Høgsberg1cb3df42012-12-11 23:03:56 -0500448 global->name = id;
449 global->interface = strdup(interface);
450 assert(interface);
451 global->version = version;
452 wl_list_insert(client->global_list.prev, &global->link);
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800453
454 if (strcmp(interface, "wl_compositor") == 0) {
455 client->wl_compositor =
456 wl_registry_bind(registry, id,
457 &wl_compositor_interface, 1);
458 } else if (strcmp(interface, "wl_seat") == 0) {
Kristian Høgsbergc1b244f2013-10-09 14:01:23 -0700459 input = xzalloc(sizeof *input);
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800460 input->wl_seat =
461 wl_registry_bind(registry, id,
462 &wl_seat_interface, 1);
463 wl_seat_add_listener(input->wl_seat, &seat_listener, input);
464 client->input = input;
465 } else if (strcmp(interface, "wl_shm") == 0) {
466 client->wl_shm =
467 wl_registry_bind(registry, id,
468 &wl_shm_interface, 1);
469 wl_shm_add_listener(client->wl_shm, &shm_listener, client);
470 } else if (strcmp(interface, "wl_output") == 0) {
Kristian Høgsbergc1b244f2013-10-09 14:01:23 -0700471 output = xzalloc(sizeof *output);
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800472 output->wl_output =
473 wl_registry_bind(registry, id,
474 &wl_output_interface, 1);
475 wl_output_add_listener(output->wl_output,
476 &output_listener, output);
477 client->output = output;
478 } else if (strcmp(interface, "wl_test") == 0) {
Kristian Høgsbergc1b244f2013-10-09 14:01:23 -0700479 test = xzalloc(sizeof *test);
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800480 test->wl_test =
481 wl_registry_bind(registry, id,
482 &wl_test_interface, 1);
483 wl_test_add_listener(test->wl_test, &test_listener, test);
484 client->test = test;
485 }
486}
487
488static const struct wl_registry_listener registry_listener = {
489 handle_global
490};
491
Kristian Høgsberg42284f52014-01-01 17:38:04 -0800492void
493skip(const char *fmt, ...)
494{
495 va_list argp;
496
497 va_start(argp, fmt);
498 vfprintf(stderr, fmt, argp);
499 va_end(argp);
500
Emilio Pozuelo Monfortdae8a4b2014-02-07 09:34:48 +0100501 /* automake tests uses exit code 77. weston-test-runner will see
502 * this and use it, and then weston-test's sigchld handler (in the
503 * weston process) will use that as an exit status, which is what
504 * automake will see in the end. */
505 exit(77);
Kristian Høgsberg42284f52014-01-01 17:38:04 -0800506}
507
Marek Chalupa4d06d462014-07-16 11:27:06 +0200508void
509expect_protocol_error(struct client *client,
510 const struct wl_interface *intf,
511 uint32_t code)
512{
513 int err;
514 uint32_t errcode, failed = 0;
515 const struct wl_interface *interface;
516 unsigned int id;
517
518 /* if the error has not come yet, make it happen */
519 wl_display_roundtrip(client->wl_display);
520
521 err = wl_display_get_error(client->wl_display);
522
523 assert(err && "Expected protocol error but nothing came");
524 assert(err == EPROTO && "Expected protocol error but got local error");
525
526 errcode = wl_display_get_protocol_error(client->wl_display,
527 &interface, &id);
528
529 /* check error */
530 if (errcode != code) {
531 fprintf(stderr, "Should get error code %d but got %d\n",
532 code, errcode);
533 failed = 1;
534 }
535
536 /* this should be definitely set */
537 assert(interface);
538
539 if (strcmp(intf->name, interface->name) != 0) {
540 fprintf(stderr, "Should get interface '%s' but got '%s'\n",
541 intf->name, interface->name);
542 failed = 1;
543 }
544
545 if (failed) {
546 fprintf(stderr, "Expected other protocol error\n");
547 abort();
548 }
549
550 /* all OK */
551 fprintf(stderr, "Got expected protocol error on '%s' (object id: %d) "
552 "with code %d\n", interface->name, id, errcode);
553}
554
Pekka Paalanen07921d72012-12-12 14:26:40 +0200555static void
556log_handler(const char *fmt, va_list args)
557{
558 fprintf(stderr, "libwayland: ");
559 vfprintf(stderr, fmt, args);
560}
561
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800562struct client *
563client_create(int x, int y, int width, int height)
564{
565 struct client *client;
566 struct surface *surface;
567
Pekka Paalanen07921d72012-12-12 14:26:40 +0200568 wl_log_set_handler_client(log_handler);
569
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800570 /* connect to display */
Kristian Høgsbergc1b244f2013-10-09 14:01:23 -0700571 client = xzalloc(sizeof *client);
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800572 client->wl_display = wl_display_connect(NULL);
573 assert(client->wl_display);
Kristian Høgsberg1cb3df42012-12-11 23:03:56 -0500574 wl_list_init(&client->global_list);
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800575
576 /* setup registry so we can bind to interfaces */
577 client->wl_registry = wl_display_get_registry(client->wl_display);
578 wl_registry_add_listener(client->wl_registry, &registry_listener, client);
579
580 /* trigger global listener */
581 wl_display_dispatch(client->wl_display);
582 wl_display_roundtrip(client->wl_display);
583
584 /* must have WL_SHM_FORMAT_ARGB32 */
585 assert(client->has_argb);
586
587 /* must have wl_test interface */
588 assert(client->test);
589
590 /* must have an output */
591 assert(client->output);
592
593 /* initialize the client surface */
Kristian Høgsbergc1b244f2013-10-09 14:01:23 -0700594 surface = xzalloc(sizeof *surface);
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800595 surface->wl_surface =
596 wl_compositor_create_surface(client->wl_compositor);
597 assert(surface->wl_surface);
598
599 wl_surface_add_listener(surface->wl_surface, &surface_listener,
600 surface);
601
602 client->surface = surface;
603 wl_surface_set_user_data(surface->wl_surface, surface);
604
605 surface->width = width;
606 surface->height = height;
Pekka Paalanen32ac9b92013-02-08 17:01:26 +0200607 surface->wl_buffer = create_shm_buffer(client, width, height,
608 &surface->data);
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800609
610 memset(surface->data, 64, width * height * 4);
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800611
612 move_client(client, x, y);
613
614 return client;
615}