blob: eadc29b922be79f9ffe8f883bd09a2cb95840a80 [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
Kristian Høgsbergc1b244f2013-10-09 14:01:23 -070035static inline void *
36xzalloc(size_t size)
37{
38 void *p;
39
40 p = calloc(1, size);
41 assert(p);
42
43 return p;
44}
45
U. Artie Eoff1ba9b382012-12-07 13:50:32 -080046int
47surface_contains(struct surface *surface, int x, int y)
48{
49 /* test whether a global x,y point is contained in the surface */
50 int sx = surface->x;
51 int sy = surface->y;
52 int sw = surface->width;
53 int sh = surface->height;
54 return x >= sx && y >= sy && x < sx + sw && y < sy + sh;
55}
56
Kristian Høgsbergdb6dc7d2012-12-11 21:49:13 -050057static void
Pekka Paalanen8aaef7d2013-02-08 17:01:25 +020058frame_callback_handler(void *data, struct wl_callback *callback, uint32_t time)
Kristian Høgsbergdb6dc7d2012-12-11 21:49:13 -050059{
60 int *done = data;
61
62 *done = 1;
63
64 wl_callback_destroy(callback);
65}
66
67static const struct wl_callback_listener frame_listener = {
Pekka Paalanen8aaef7d2013-02-08 17:01:25 +020068 frame_callback_handler
Kristian Høgsbergdb6dc7d2012-12-11 21:49:13 -050069};
70
Pekka Paalanen8aaef7d2013-02-08 17:01:25 +020071struct wl_callback *
72frame_callback_set(struct wl_surface *surface, int *done)
73{
74 struct wl_callback *callback;
75
76 *done = 0;
77 callback = wl_surface_frame(surface);
78 wl_callback_add_listener(callback, &frame_listener, done);
79
80 return callback;
81}
82
Marek Chalupa1740aa82014-07-16 11:32:50 +020083int
84frame_callback_wait_nofail(struct client *client, int *done)
Pekka Paalanen8aaef7d2013-02-08 17:01:25 +020085{
86 while (!*done) {
Marek Chalupa1740aa82014-07-16 11:32:50 +020087 if (wl_display_dispatch(client->wl_display) < 0)
88 return 0;
Pekka Paalanen8aaef7d2013-02-08 17:01:25 +020089 }
Marek Chalupa1740aa82014-07-16 11:32:50 +020090
91 return 1;
Pekka Paalanen8aaef7d2013-02-08 17:01:25 +020092}
93
U. Artie Eoff1ba9b382012-12-07 13:50:32 -080094void
95move_client(struct client *client, int x, int y)
96{
97 struct surface *surface = client->surface;
Kristian Høgsbergdb6dc7d2012-12-11 21:49:13 -050098 int done;
U. Artie Eoff1ba9b382012-12-07 13:50:32 -080099
100 client->surface->x = x;
101 client->surface->y = y;
102 wl_test_move_surface(client->test->wl_test, surface->wl_surface,
103 surface->x, surface->y);
Giulio Camuffo82cb5052013-02-28 18:44:54 +0100104 /* The attach here is necessary because commit() will call congfigure
105 * only on surfaces newly attached, and the one that sets the surface
106 * position is the configure. */
107 wl_surface_attach(surface->wl_surface, surface->wl_buffer, 0, 0);
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800108 wl_surface_damage(surface->wl_surface, 0, 0, surface->width,
109 surface->height);
Kristian Høgsbergdb6dc7d2012-12-11 21:49:13 -0500110
Pekka Paalanen8aaef7d2013-02-08 17:01:25 +0200111 frame_callback_set(surface->wl_surface, &done);
Kristian Høgsbergdb6dc7d2012-12-11 21:49:13 -0500112
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800113 wl_surface_commit(surface->wl_surface);
114
Pekka Paalanen8aaef7d2013-02-08 17:01:25 +0200115 frame_callback_wait(client, &done);
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800116}
117
Neil Roberts40c0c3f2013-10-29 20:13:45 +0000118int
119get_n_egl_buffers(struct client *client)
120{
121 client->test->n_egl_buffers = -1;
122
123 wl_test_get_n_egl_buffers(client->test->wl_test);
124 wl_display_roundtrip(client->wl_display);
125
126 return client->test->n_egl_buffers;
127}
128
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800129static void
130pointer_handle_enter(void *data, struct wl_pointer *wl_pointer,
131 uint32_t serial, struct wl_surface *wl_surface,
132 wl_fixed_t x, wl_fixed_t y)
133{
134 struct pointer *pointer = data;
135
136 pointer->focus = wl_surface_get_user_data(wl_surface);
137 pointer->x = wl_fixed_to_int(x);
138 pointer->y = wl_fixed_to_int(y);
139
140 fprintf(stderr, "test-client: got pointer enter %d %d, surface %p\n",
141 pointer->x, pointer->y, pointer->focus);
142}
143
144static void
145pointer_handle_leave(void *data, struct wl_pointer *wl_pointer,
146 uint32_t serial, struct wl_surface *wl_surface)
147{
148 struct pointer *pointer = data;
149
150 pointer->focus = NULL;
151
152 fprintf(stderr, "test-client: got pointer leave, surface %p\n",
153 wl_surface_get_user_data(wl_surface));
154}
155
156static void
157pointer_handle_motion(void *data, struct wl_pointer *wl_pointer,
158 uint32_t time, wl_fixed_t x, wl_fixed_t y)
159{
160 struct pointer *pointer = data;
161
162 pointer->x = wl_fixed_to_int(x);
163 pointer->y = wl_fixed_to_int(y);
164
165 fprintf(stderr, "test-client: got pointer motion %d %d\n",
166 pointer->x, pointer->y);
167}
168
169static void
170pointer_handle_button(void *data, struct wl_pointer *wl_pointer,
171 uint32_t serial, uint32_t time, uint32_t button,
172 uint32_t state)
173{
174 struct pointer *pointer = data;
175
176 pointer->button = button;
177 pointer->state = state;
178
179 fprintf(stderr, "test-client: got pointer button %u %u\n",
180 button, state);
181}
182
183static void
184pointer_handle_axis(void *data, struct wl_pointer *wl_pointer,
185 uint32_t time, uint32_t axis, wl_fixed_t value)
186{
Kristian Høgsberg4c8ce202013-10-09 14:23:00 -0700187 fprintf(stderr, "test-client: got pointer axis %u %f\n",
188 axis, wl_fixed_to_double(value));
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800189}
190
191static const struct wl_pointer_listener pointer_listener = {
192 pointer_handle_enter,
193 pointer_handle_leave,
194 pointer_handle_motion,
195 pointer_handle_button,
196 pointer_handle_axis,
197};
198
199static void
200keyboard_handle_keymap(void *data, struct wl_keyboard *wl_keyboard,
201 uint32_t format, int fd, uint32_t size)
202{
203 close(fd);
204
205 fprintf(stderr, "test-client: got keyboard keymap\n");
206}
207
208static void
209keyboard_handle_enter(void *data, struct wl_keyboard *wl_keyboard,
210 uint32_t serial, struct wl_surface *wl_surface,
211 struct wl_array *keys)
212{
213 struct keyboard *keyboard = data;
214
215 keyboard->focus = wl_surface_get_user_data(wl_surface);
216
217 fprintf(stderr, "test-client: got keyboard enter, surface %p\n",
218 keyboard->focus);
219}
220
221static void
222keyboard_handle_leave(void *data, struct wl_keyboard *wl_keyboard,
223 uint32_t serial, struct wl_surface *wl_surface)
224{
225 struct keyboard *keyboard = data;
226
227 keyboard->focus = NULL;
228
229 fprintf(stderr, "test-client: got keyboard leave, surface %p\n",
230 wl_surface_get_user_data(wl_surface));
231}
232
233static void
234keyboard_handle_key(void *data, struct wl_keyboard *wl_keyboard,
235 uint32_t serial, uint32_t time, uint32_t key,
236 uint32_t state)
237{
238 struct keyboard *keyboard = data;
239
240 keyboard->key = key;
241 keyboard->state = state;
242
243 fprintf(stderr, "test-client: got keyboard key %u %u\n", key, state);
244}
245
246static void
247keyboard_handle_modifiers(void *data, struct wl_keyboard *wl_keyboard,
248 uint32_t serial, uint32_t mods_depressed,
249 uint32_t mods_latched, uint32_t mods_locked,
250 uint32_t group)
251{
252 struct keyboard *keyboard = data;
253
254 keyboard->mods_depressed = mods_depressed;
255 keyboard->mods_latched = mods_latched;
256 keyboard->mods_locked = mods_locked;
257 keyboard->group = group;
258
259 fprintf(stderr, "test-client: got keyboard modifiers %u %u %u %u\n",
260 mods_depressed, mods_latched, mods_locked, group);
261}
262
263static const struct wl_keyboard_listener keyboard_listener = {
264 keyboard_handle_keymap,
265 keyboard_handle_enter,
266 keyboard_handle_leave,
267 keyboard_handle_key,
268 keyboard_handle_modifiers,
269};
270
271static void
272surface_enter(void *data,
273 struct wl_surface *wl_surface, struct wl_output *output)
274{
275 struct surface *surface = data;
276
277 surface->output = wl_output_get_user_data(output);
278
279 fprintf(stderr, "test-client: got surface enter output %p\n",
280 surface->output);
281}
282
283static void
284surface_leave(void *data,
285 struct wl_surface *wl_surface, struct wl_output *output)
286{
287 struct surface *surface = data;
288
289 surface->output = NULL;
290
291 fprintf(stderr, "test-client: got surface leave output %p\n",
292 wl_output_get_user_data(output));
293}
294
295static const struct wl_surface_listener surface_listener = {
296 surface_enter,
297 surface_leave
298};
299
Pekka Paalanen32ac9b92013-02-08 17:01:26 +0200300struct wl_buffer *
301create_shm_buffer(struct client *client, int width, int height, void **pixels)
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800302{
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800303 struct wl_shm *shm = client->wl_shm;
Pekka Paalanen32ac9b92013-02-08 17:01:26 +0200304 int stride = width * 4;
305 int size = stride * height;
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800306 struct wl_shm_pool *pool;
Pekka Paalanen32ac9b92013-02-08 17:01:26 +0200307 struct wl_buffer *buffer;
308 int fd;
309 void *data;
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800310
311 fd = os_create_anonymous_file(size);
312 assert(fd >= 0);
313
Pekka Paalanen32ac9b92013-02-08 17:01:26 +0200314 data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
315 if (data == MAP_FAILED) {
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800316 close(fd);
Pekka Paalanen32ac9b92013-02-08 17:01:26 +0200317 assert(data != MAP_FAILED);
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800318 }
319
320 pool = wl_shm_create_pool(shm, fd, size);
Pekka Paalanen32ac9b92013-02-08 17:01:26 +0200321 buffer = wl_shm_pool_create_buffer(pool, 0, width, height, stride,
322 WL_SHM_FORMAT_ARGB8888);
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800323 wl_shm_pool_destroy(pool);
324
325 close(fd);
Pekka Paalanen32ac9b92013-02-08 17:01:26 +0200326
327 if (pixels)
328 *pixels = data;
329
330 return buffer;
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800331}
332
333static void
334shm_format(void *data, struct wl_shm *wl_shm, uint32_t format)
335{
336 struct client *client = data;
337
338 if (format == WL_SHM_FORMAT_ARGB8888)
339 client->has_argb = 1;
340}
341
342struct wl_shm_listener shm_listener = {
343 shm_format
344};
345
346static void
347test_handle_pointer_position(void *data, struct wl_test *wl_test,
348 wl_fixed_t x, wl_fixed_t y)
349{
350 struct test *test = data;
351 test->pointer_x = wl_fixed_to_int(x);
352 test->pointer_y = wl_fixed_to_int(y);
353
354 fprintf(stderr, "test-client: got global pointer %d %d\n",
355 test->pointer_x, test->pointer_y);
356}
357
Neil Roberts40c0c3f2013-10-29 20:13:45 +0000358static void
359test_handle_n_egl_buffers(void *data, struct wl_test *wl_test, uint32_t n)
360{
361 struct test *test = data;
362
363 test->n_egl_buffers = n;
364}
365
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800366static const struct wl_test_listener test_listener = {
Neil Roberts40c0c3f2013-10-29 20:13:45 +0000367 test_handle_pointer_position,
368 test_handle_n_egl_buffers,
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800369};
370
371static void
372seat_handle_capabilities(void *data, struct wl_seat *seat,
373 enum wl_seat_capability caps)
374{
375 struct input *input = data;
376 struct pointer *pointer;
377 struct keyboard *keyboard;
378
379 if ((caps & WL_SEAT_CAPABILITY_POINTER) && !input->pointer) {
Kristian Høgsbergc1b244f2013-10-09 14:01:23 -0700380 pointer = xzalloc(sizeof *pointer);
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800381 pointer->wl_pointer = wl_seat_get_pointer(seat);
382 wl_pointer_set_user_data(pointer->wl_pointer, pointer);
383 wl_pointer_add_listener(pointer->wl_pointer, &pointer_listener,
384 pointer);
385 input->pointer = pointer;
386 } else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && input->pointer) {
387 wl_pointer_destroy(input->pointer->wl_pointer);
388 free(input->pointer);
389 input->pointer = NULL;
390 }
391
392 if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !input->keyboard) {
Kristian Høgsbergc1b244f2013-10-09 14:01:23 -0700393 keyboard = xzalloc(sizeof *keyboard);
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800394 keyboard->wl_keyboard = wl_seat_get_keyboard(seat);
395 wl_keyboard_set_user_data(keyboard->wl_keyboard, keyboard);
396 wl_keyboard_add_listener(keyboard->wl_keyboard, &keyboard_listener,
397 keyboard);
398 input->keyboard = keyboard;
399 } else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && input->keyboard) {
400 wl_keyboard_destroy(input->keyboard->wl_keyboard);
401 free(input->keyboard);
402 input->keyboard = NULL;
403 }
404}
405
406static const struct wl_seat_listener seat_listener = {
407 seat_handle_capabilities,
408};
409
410static void
411output_handle_geometry(void *data,
412 struct wl_output *wl_output,
413 int x, int y,
414 int physical_width,
415 int physical_height,
416 int subpixel,
417 const char *make,
418 const char *model,
419 int32_t transform)
420{
421 struct output *output = data;
422
423 output->x = x;
424 output->y = y;
425}
426
427static void
428output_handle_mode(void *data,
429 struct wl_output *wl_output,
430 uint32_t flags,
431 int width,
432 int height,
433 int refresh)
434{
435 struct output *output = data;
436
437 if (flags & WL_OUTPUT_MODE_CURRENT) {
438 output->width = width;
439 output->height = height;
440 }
441}
442
443static const struct wl_output_listener output_listener = {
444 output_handle_geometry,
445 output_handle_mode
446};
447
448static void
449handle_global(void *data, struct wl_registry *registry,
450 uint32_t id, const char *interface, uint32_t version)
451{
452 struct client *client = data;
453 struct input *input;
454 struct output *output;
455 struct test *test;
Kristian Høgsberg1cb3df42012-12-11 23:03:56 -0500456 struct global *global;
457
Kristian Høgsbergc1b244f2013-10-09 14:01:23 -0700458 global = xzalloc(sizeof *global);
Kristian Høgsberg1cb3df42012-12-11 23:03:56 -0500459 global->name = id;
460 global->interface = strdup(interface);
461 assert(interface);
462 global->version = version;
463 wl_list_insert(client->global_list.prev, &global->link);
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800464
465 if (strcmp(interface, "wl_compositor") == 0) {
466 client->wl_compositor =
467 wl_registry_bind(registry, id,
468 &wl_compositor_interface, 1);
469 } else if (strcmp(interface, "wl_seat") == 0) {
Kristian Høgsbergc1b244f2013-10-09 14:01:23 -0700470 input = xzalloc(sizeof *input);
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800471 input->wl_seat =
472 wl_registry_bind(registry, id,
473 &wl_seat_interface, 1);
474 wl_seat_add_listener(input->wl_seat, &seat_listener, input);
475 client->input = input;
476 } else if (strcmp(interface, "wl_shm") == 0) {
477 client->wl_shm =
478 wl_registry_bind(registry, id,
479 &wl_shm_interface, 1);
480 wl_shm_add_listener(client->wl_shm, &shm_listener, client);
481 } else if (strcmp(interface, "wl_output") == 0) {
Kristian Høgsbergc1b244f2013-10-09 14:01:23 -0700482 output = xzalloc(sizeof *output);
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800483 output->wl_output =
484 wl_registry_bind(registry, id,
485 &wl_output_interface, 1);
486 wl_output_add_listener(output->wl_output,
487 &output_listener, output);
488 client->output = output;
489 } else if (strcmp(interface, "wl_test") == 0) {
Kristian Høgsbergc1b244f2013-10-09 14:01:23 -0700490 test = xzalloc(sizeof *test);
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800491 test->wl_test =
492 wl_registry_bind(registry, id,
493 &wl_test_interface, 1);
494 wl_test_add_listener(test->wl_test, &test_listener, test);
495 client->test = test;
496 }
497}
498
499static const struct wl_registry_listener registry_listener = {
500 handle_global
501};
502
Kristian Høgsberg42284f52014-01-01 17:38:04 -0800503void
504skip(const char *fmt, ...)
505{
506 va_list argp;
507
508 va_start(argp, fmt);
509 vfprintf(stderr, fmt, argp);
510 va_end(argp);
511
Emilio Pozuelo Monfortdae8a4b2014-02-07 09:34:48 +0100512 /* automake tests uses exit code 77. weston-test-runner will see
513 * this and use it, and then weston-test's sigchld handler (in the
514 * weston process) will use that as an exit status, which is what
515 * automake will see in the end. */
516 exit(77);
Kristian Høgsberg42284f52014-01-01 17:38:04 -0800517}
518
Marek Chalupa4d06d462014-07-16 11:27:06 +0200519void
520expect_protocol_error(struct client *client,
521 const struct wl_interface *intf,
522 uint32_t code)
523{
524 int err;
525 uint32_t errcode, failed = 0;
526 const struct wl_interface *interface;
527 unsigned int id;
528
529 /* if the error has not come yet, make it happen */
530 wl_display_roundtrip(client->wl_display);
531
532 err = wl_display_get_error(client->wl_display);
533
534 assert(err && "Expected protocol error but nothing came");
535 assert(err == EPROTO && "Expected protocol error but got local error");
536
537 errcode = wl_display_get_protocol_error(client->wl_display,
538 &interface, &id);
539
540 /* check error */
541 if (errcode != code) {
542 fprintf(stderr, "Should get error code %d but got %d\n",
543 code, errcode);
544 failed = 1;
545 }
546
547 /* this should be definitely set */
548 assert(interface);
549
550 if (strcmp(intf->name, interface->name) != 0) {
551 fprintf(stderr, "Should get interface '%s' but got '%s'\n",
552 intf->name, interface->name);
553 failed = 1;
554 }
555
556 if (failed) {
557 fprintf(stderr, "Expected other protocol error\n");
558 abort();
559 }
560
561 /* all OK */
562 fprintf(stderr, "Got expected protocol error on '%s' (object id: %d) "
563 "with code %d\n", interface->name, id, errcode);
564}
565
Pekka Paalanen07921d72012-12-12 14:26:40 +0200566static void
567log_handler(const char *fmt, va_list args)
568{
569 fprintf(stderr, "libwayland: ");
570 vfprintf(stderr, fmt, args);
571}
572
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800573struct client *
574client_create(int x, int y, int width, int height)
575{
576 struct client *client;
577 struct surface *surface;
578
Pekka Paalanen07921d72012-12-12 14:26:40 +0200579 wl_log_set_handler_client(log_handler);
580
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800581 /* connect to display */
Kristian Høgsbergc1b244f2013-10-09 14:01:23 -0700582 client = xzalloc(sizeof *client);
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800583 client->wl_display = wl_display_connect(NULL);
584 assert(client->wl_display);
Kristian Høgsberg1cb3df42012-12-11 23:03:56 -0500585 wl_list_init(&client->global_list);
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800586
587 /* setup registry so we can bind to interfaces */
588 client->wl_registry = wl_display_get_registry(client->wl_display);
589 wl_registry_add_listener(client->wl_registry, &registry_listener, client);
590
591 /* trigger global listener */
592 wl_display_dispatch(client->wl_display);
593 wl_display_roundtrip(client->wl_display);
594
595 /* must have WL_SHM_FORMAT_ARGB32 */
596 assert(client->has_argb);
597
598 /* must have wl_test interface */
599 assert(client->test);
600
601 /* must have an output */
602 assert(client->output);
603
604 /* initialize the client surface */
Kristian Høgsbergc1b244f2013-10-09 14:01:23 -0700605 surface = xzalloc(sizeof *surface);
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800606 surface->wl_surface =
607 wl_compositor_create_surface(client->wl_compositor);
608 assert(surface->wl_surface);
609
610 wl_surface_add_listener(surface->wl_surface, &surface_listener,
611 surface);
612
613 client->surface = surface;
614 wl_surface_set_user_data(surface->wl_surface, surface);
615
616 surface->width = width;
617 surface->height = height;
Pekka Paalanen32ac9b92013-02-08 17:01:26 +0200618 surface->wl_buffer = create_shm_buffer(client, width, height,
619 &surface->data);
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800620
621 memset(surface->data, 64, width * height * 4);
U. Artie Eoff1ba9b382012-12-07 13:50:32 -0800622
623 move_client(client, x, y);
624
625 return client;
626}