blob: 03e2c54b914b7794245b429df40035a98829f350 [file] [log] [blame]
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -08001/*
2 * Copyright © 2012 Intel Corporation
3 *
Bryce Harrington2cc92972015-06-11 15:39:40 -07004 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sublicense, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -080011 *
Bryce Harrington2cc92972015-06-11 15:39:40 -070012 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial
14 * portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
20 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -080024 */
25
Neil Roberts40c0c3f2013-10-29 20:13:45 +000026#include "config.h"
27
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -080028#include <stdlib.h>
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -080029#include <assert.h>
30#include <signal.h>
31#include <unistd.h>
Marek Chalupac8daf772015-03-30 06:37:55 -040032#include <string.h>
Bryce Harringtona7680262014-11-19 17:18:34 -080033
Jon Cruz4678bab2015-06-15 15:37:07 -070034#include "src/compositor.h"
Derek Foremanf6a65922015-02-24 09:32:14 -060035#include "weston-test-server-protocol.h"
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -080036
Neil Roberts40c0c3f2013-10-29 20:13:45 +000037#ifdef ENABLE_EGL
38#include <EGL/egl.h>
39#include <EGL/eglext.h>
Jon Cruz4678bab2015-06-15 15:37:07 -070040#include "src/weston-egl-ext.h"
Neil Roberts40c0c3f2013-10-29 20:13:45 +000041#endif /* ENABLE_EGL */
42
Jon Cruz867d50e2015-06-15 15:37:10 -070043#include "shared/helpers.h"
44
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -080045struct weston_test {
46 struct weston_compositor *compositor;
47 struct weston_layer layer;
48 struct weston_process process;
Marek Chalupac3c3fc42015-03-30 09:17:40 -040049 struct weston_seat seat;
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -080050};
51
52struct weston_test_surface {
53 struct weston_surface *surface;
Jason Ekstranda7af7042013-10-12 22:38:11 -050054 struct weston_view *view;
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -080055 int32_t x, y;
56 struct weston_test *test;
57};
58
59static void
60test_client_sigchld(struct weston_process *process, int status)
61{
62 struct weston_test *test =
63 container_of(process, struct weston_test, process);
64
Emilio Pozuelo Monfortdae8a4b2014-02-07 09:34:48 +010065 /* Chain up from weston-test-runner's exit code so that automake
66 * knows the exit status and can report e.g. skipped tests. */
67 if (WIFEXITED(status) && WEXITSTATUS(status) != 0)
68 exit(WEXITSTATUS(status));
69
70 /* In case the child aborted or segfaulted... */
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -080071 assert(status == 0);
72
73 wl_display_terminate(test->compositor->wl_display);
74}
75
76static struct weston_seat *
77get_seat(struct weston_test *test)
78{
Marek Chalupac3c3fc42015-03-30 09:17:40 -040079 return &test->seat;
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -080080}
81
82static void
83notify_pointer_position(struct weston_test *test, struct wl_resource *resource)
84{
85 struct weston_seat *seat = get_seat(test);
Derek Foreman1281a362015-07-31 16:55:32 -050086 struct weston_pointer *pointer = weston_seat_get_pointer(seat);
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -080087
Derek Foremanf6a65922015-02-24 09:32:14 -060088 weston_test_send_pointer_position(resource, pointer->x, pointer->y);
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -080089}
90
91static void
Jason Ekstrand918f2dd2013-12-02 21:01:53 -060092test_surface_configure(struct weston_surface *surface, int32_t sx, int32_t sy)
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -080093{
Giulio Camuffo7fe01b12013-03-28 18:02:42 +010094 struct weston_test_surface *test_surface = surface->configure_private;
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -080095 struct weston_test *test = test_surface->test;
96
Giulio Camuffo412e6a52014-07-09 22:12:56 +030097 if (wl_list_empty(&test_surface->view->layer_link.link))
98 weston_layer_entry_insert(&test->layer.view_list,
99 &test_surface->view->layer_link);
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800100
Jason Ekstrand918f2dd2013-12-02 21:01:53 -0600101 weston_view_set_position(test_surface->view,
102 test_surface->x, test_surface->y);
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800103
Kristian Høgsbergace0a392013-11-13 21:55:57 -0800104 weston_view_update_transform(test_surface->view);
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800105}
106
107static void
108move_surface(struct wl_client *client, struct wl_resource *resource,
109 struct wl_resource *surface_resource,
110 int32_t x, int32_t y)
111{
Kristian Høgsberg8f7f4832013-06-25 16:18:35 -0400112 struct weston_surface *surface =
113 wl_resource_get_user_data(surface_resource);
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800114 struct weston_test_surface *test_surface;
115
Giulio Camuffo7fe01b12013-03-28 18:02:42 +0100116 test_surface = surface->configure_private;
Jason Ekstranda7af7042013-10-12 22:38:11 -0500117 if (!test_surface) {
118 test_surface = malloc(sizeof *test_surface);
119 if (!test_surface) {
120 wl_resource_post_no_memory(resource);
121 return;
122 }
123
124 test_surface->view = weston_view_create(surface);
125 if (!test_surface->view) {
126 wl_resource_post_no_memory(resource);
127 free(test_surface);
128 return;
129 }
130
131 surface->configure_private = test_surface;
132 surface->configure = test_surface_configure;
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800133 }
134
135 test_surface->surface = surface;
Kristian Høgsberg8f7f4832013-06-25 16:18:35 -0400136 test_surface->test = wl_resource_get_user_data(resource);
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800137 test_surface->x = x;
138 test_surface->y = y;
139}
140
141static void
142move_pointer(struct wl_client *client, struct wl_resource *resource,
143 int32_t x, int32_t y)
144{
Kristian Høgsberg8f7f4832013-06-25 16:18:35 -0400145 struct weston_test *test = wl_resource_get_user_data(resource);
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800146 struct weston_seat *seat = get_seat(test);
Derek Foreman1281a362015-07-31 16:55:32 -0500147 struct weston_pointer *pointer = weston_seat_get_pointer(seat);
Jonas Ådahld2510102014-10-05 21:39:14 +0200148 struct weston_pointer_motion_event event = { 0 };
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800149
Jonas Ådahld2510102014-10-05 21:39:14 +0200150 event = (struct weston_pointer_motion_event) {
151 .mask = WESTON_POINTER_MOTION_REL,
152 .dx = wl_fixed_to_double(wl_fixed_from_int(x) - pointer->x),
153 .dy = wl_fixed_to_double(wl_fixed_from_int(y) - pointer->y),
154 };
155
156 notify_motion(seat, 100, &event);
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800157
158 notify_pointer_position(test, resource);
159}
160
161static void
162send_button(struct wl_client *client, struct wl_resource *resource,
163 int32_t button, uint32_t state)
164{
Kristian Høgsberg8f7f4832013-06-25 16:18:35 -0400165 struct weston_test *test = wl_resource_get_user_data(resource);
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800166 struct weston_seat *seat = get_seat(test);
167
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800168 notify_button(seat, 100, button, state);
169}
170
171static void
172activate_surface(struct wl_client *client, struct wl_resource *resource,
173 struct wl_resource *surface_resource)
174{
175 struct weston_surface *surface = surface_resource ?
Kristian Høgsberg8f7f4832013-06-25 16:18:35 -0400176 wl_resource_get_user_data(surface_resource) : NULL;
177 struct weston_test *test = wl_resource_get_user_data(resource);
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800178 struct weston_seat *seat;
Derek Foreman1281a362015-07-31 16:55:32 -0500179 struct weston_keyboard *keyboard;
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800180
181 seat = get_seat(test);
Derek Foreman1281a362015-07-31 16:55:32 -0500182 keyboard = weston_seat_get_keyboard(seat);
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800183 if (surface) {
184 weston_surface_activate(surface, seat);
Derek Foreman1281a362015-07-31 16:55:32 -0500185 notify_keyboard_focus_in(seat, &keyboard->keys,
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800186 STATE_UPDATE_AUTOMATIC);
187 }
188 else {
189 notify_keyboard_focus_out(seat);
190 weston_surface_activate(surface, seat);
191 }
192}
193
194static void
195send_key(struct wl_client *client, struct wl_resource *resource,
196 uint32_t key, enum wl_keyboard_key_state state)
197{
Kristian Høgsberg8f7f4832013-06-25 16:18:35 -0400198 struct weston_test *test = wl_resource_get_user_data(resource);
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800199 struct weston_seat *seat = get_seat(test);
200
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800201 notify_key(seat, 100, key, state, STATE_UPDATE_AUTOMATIC);
202}
203
Marek Chalupac8daf772015-03-30 06:37:55 -0400204static void
205device_release(struct wl_client *client,
206 struct wl_resource *resource, const char *device)
207{
208 struct weston_test *test = wl_resource_get_user_data(resource);
209 struct weston_seat *seat = get_seat(test);
210
211 if (strcmp(device, "pointer") == 0) {
212 weston_seat_release_pointer(seat);
213 } else if (strcmp(device, "keyboard") == 0) {
214 weston_seat_release_keyboard(seat);
215 } else if (strcmp(device, "touch") == 0) {
216 weston_seat_release_touch(seat);
217 } else if (strcmp(device, "seat") == 0) {
218 weston_seat_release(seat);
219 } else {
220 assert(0 && "Unsupported device");
221 }
222}
223
224static void
225device_add(struct wl_client *client,
226 struct wl_resource *resource, const char *device)
227{
228 struct weston_test *test = wl_resource_get_user_data(resource);
229 struct weston_seat *seat = get_seat(test);
230
231 if (strcmp(device, "pointer") == 0) {
232 weston_seat_init_pointer(seat);
233 } else if (strcmp(device, "keyboard") == 0) {
234 weston_seat_init_keyboard(seat, NULL);
235 } else if (strcmp(device, "touch") == 0) {
236 weston_seat_init_touch(seat);
237 } else {
238 assert(0 && "Unsupported device");
239 }
240}
241
Neil Roberts40c0c3f2013-10-29 20:13:45 +0000242#ifdef ENABLE_EGL
243static int
244is_egl_buffer(struct wl_resource *resource)
245{
246 PFNEGLQUERYWAYLANDBUFFERWL query_buffer =
247 (void *) eglGetProcAddress("eglQueryWaylandBufferWL");
248 EGLint format;
249
250 if (query_buffer(eglGetCurrentDisplay(),
251 resource,
252 EGL_TEXTURE_FORMAT,
253 &format))
254 return 1;
255
256 return 0;
257}
258#endif /* ENABLE_EGL */
259
260static void
261get_n_buffers(struct wl_client *client, struct wl_resource *resource)
262{
263 int n_buffers = 0;
264
265#ifdef ENABLE_EGL
266 struct wl_resource *buffer_resource;
267 int i;
268
269 for (i = 0; i < 1000; i++) {
270 buffer_resource = wl_client_get_object(client, i);
271
272 if (buffer_resource == NULL)
273 continue;
274
275 if (is_egl_buffer(buffer_resource))
276 n_buffers++;
277 }
278#endif /* ENABLE_EGL */
279
Derek Foremanf6a65922015-02-24 09:32:14 -0600280 weston_test_send_n_egl_buffers(resource, n_buffers);
Neil Roberts40c0c3f2013-10-29 20:13:45 +0000281}
282
Bryce Harringtonf280d112015-05-05 15:13:20 -0700283enum weston_test_screenshot_outcome {
284 WESTON_TEST_SCREENSHOT_SUCCESS,
285 WESTON_TEST_SCREENSHOT_NO_MEMORY,
286 WESTON_TEST_SCREENSHOT_BAD_BUFFER
287 };
288
289typedef void (*weston_test_screenshot_done_func_t)(void *data,
290 enum weston_test_screenshot_outcome outcome);
291
292struct test_screenshot {
293 struct weston_compositor *compositor;
294 struct wl_global *global;
295 struct wl_client *client;
296 struct weston_process process;
297 struct wl_listener destroy_listener;
298};
299
300struct test_screenshot_frame_listener {
301 struct wl_listener listener;
302 struct weston_buffer *buffer;
303 weston_test_screenshot_done_func_t done;
304 void *data;
305};
306
307static void
308copy_bgra_yflip(uint8_t *dst, uint8_t *src, int height, int stride)
309{
310 uint8_t *end;
311
312 end = dst + height * stride;
313 while (dst < end) {
314 memcpy(dst, src, stride);
315 dst += stride;
316 src -= stride;
317 }
318}
319
320
321static void
322copy_bgra(uint8_t *dst, uint8_t *src, int height, int stride)
323{
324 /* TODO: optimize this out */
325 memcpy(dst, src, height * stride);
326}
327
328static void
329copy_row_swap_RB(void *vdst, void *vsrc, int bytes)
330{
331 uint32_t *dst = vdst;
332 uint32_t *src = vsrc;
333 uint32_t *end = dst + bytes / 4;
334
335 while (dst < end) {
336 uint32_t v = *src++;
337 /* A R G B */
338 uint32_t tmp = v & 0xff00ff00;
339 tmp |= (v >> 16) & 0x000000ff;
340 tmp |= (v << 16) & 0x00ff0000;
341 *dst++ = tmp;
342 }
343}
344
345static void
346copy_rgba_yflip(uint8_t *dst, uint8_t *src, int height, int stride)
347{
348 uint8_t *end;
349
350 end = dst + height * stride;
351 while (dst < end) {
352 copy_row_swap_RB(dst, src, stride);
353 dst += stride;
354 src -= stride;
355 }
356}
357
358static void
359copy_rgba(uint8_t *dst, uint8_t *src, int height, int stride)
360{
361 uint8_t *end;
362
363 end = dst + height * stride;
364 while (dst < end) {
365 copy_row_swap_RB(dst, src, stride);
366 dst += stride;
367 src += stride;
368 }
369}
370
371static void
372test_screenshot_frame_notify(struct wl_listener *listener, void *data)
373{
374 struct test_screenshot_frame_listener *l =
375 container_of(listener,
376 struct test_screenshot_frame_listener, listener);
377 struct weston_output *output = data;
378 struct weston_compositor *compositor = output->compositor;
379 int32_t stride;
380 uint8_t *pixels, *d, *s;
381
382 output->disable_planes--;
383 wl_list_remove(&listener->link);
384 stride = l->buffer->width * (PIXMAN_FORMAT_BPP(compositor->read_format) / 8);
385 pixels = malloc(stride * l->buffer->height);
386
387 if (pixels == NULL) {
388 l->done(l->data, WESTON_TEST_SCREENSHOT_NO_MEMORY);
389 free(l);
390 return;
391 }
392
Chris Michael2ec5f2a2015-12-03 12:23:12 -0500393 /* FIXME: Needs to handle output transformations */
Bryce Harringtonf280d112015-05-05 15:13:20 -0700394
395 compositor->renderer->read_pixels(output,
396 compositor->read_format,
397 pixels,
398 0, 0,
399 output->current_mode->width,
400 output->current_mode->height);
401
402 stride = wl_shm_buffer_get_stride(l->buffer->shm_buffer);
403
404 d = wl_shm_buffer_get_data(l->buffer->shm_buffer);
405 s = pixels + stride * (l->buffer->height - 1);
406
407 wl_shm_buffer_begin_access(l->buffer->shm_buffer);
408
409 /* XXX: It would be nice if we used Pixman to do all this rather
410 * than our own implementation
411 */
412 switch (compositor->read_format) {
413 case PIXMAN_a8r8g8b8:
414 case PIXMAN_x8r8g8b8:
415 if (compositor->capabilities & WESTON_CAP_CAPTURE_YFLIP)
416 copy_bgra_yflip(d, s, output->current_mode->height, stride);
417 else
418 copy_bgra(d, pixels, output->current_mode->height, stride);
419 break;
420 case PIXMAN_x8b8g8r8:
421 case PIXMAN_a8b8g8r8:
422 if (compositor->capabilities & WESTON_CAP_CAPTURE_YFLIP)
423 copy_rgba_yflip(d, s, output->current_mode->height, stride);
424 else
425 copy_rgba(d, pixels, output->current_mode->height, stride);
426 break;
427 default:
428 break;
429 }
430
431 wl_shm_buffer_end_access(l->buffer->shm_buffer);
432
433 l->done(l->data, WESTON_TEST_SCREENSHOT_SUCCESS);
434 free(pixels);
435 free(l);
436}
437
438static bool
439weston_test_screenshot_shoot(struct weston_output *output,
440 struct weston_buffer *buffer,
441 weston_test_screenshot_done_func_t done,
442 void *data)
443{
444 struct test_screenshot_frame_listener *l;
445
446 /* Get the shm buffer resource the client created */
447 if (!wl_shm_buffer_get(buffer->resource)) {
448 done(data, WESTON_TEST_SCREENSHOT_BAD_BUFFER);
449 return false;
450 }
451
452 buffer->shm_buffer = wl_shm_buffer_get(buffer->resource);
453 buffer->width = wl_shm_buffer_get_width(buffer->shm_buffer);
454 buffer->height = wl_shm_buffer_get_height(buffer->shm_buffer);
455
456 /* Verify buffer is big enough */
457 if (buffer->width < output->current_mode->width ||
458 buffer->height < output->current_mode->height) {
459 done(data, WESTON_TEST_SCREENSHOT_BAD_BUFFER);
460 return false;
461 }
462
463 /* allocate the frame listener */
464 l = malloc(sizeof *l);
465 if (l == NULL) {
466 done(data, WESTON_TEST_SCREENSHOT_NO_MEMORY);
467 return false;
468 }
469
470 /* Set up the listener */
471 l->buffer = buffer;
472 l->done = done;
473 l->data = data;
474 l->listener.notify = test_screenshot_frame_notify;
475 wl_signal_add(&output->frame_signal, &l->listener);
476
477 /* Fire off a repaint */
478 output->disable_planes++;
479 weston_output_schedule_repaint(output);
480
481 return true;
482}
483
484static void
485capture_screenshot_done(void *data, enum weston_test_screenshot_outcome outcome)
486{
487 struct wl_resource *resource = data;
488
489 switch (outcome) {
490 case WESTON_TEST_SCREENSHOT_SUCCESS:
491 weston_test_send_capture_screenshot_done(resource);
492 break;
493 case WESTON_TEST_SCREENSHOT_NO_MEMORY:
494 wl_resource_post_no_memory(resource);
495 break;
496 default:
497 break;
498 }
499}
500
501
502/**
503 * Grabs a snapshot of the screen.
504 */
505static void
506capture_screenshot(struct wl_client *client,
507 struct wl_resource *resource,
508 struct wl_resource *output_resource,
509 struct wl_resource *buffer_resource)
510{
511 struct weston_output *output =
512 wl_resource_get_user_data(output_resource);
513 struct weston_buffer *buffer =
514 weston_buffer_from_resource(buffer_resource);
515
516 if (buffer == NULL) {
517 wl_resource_post_no_memory(resource);
518 return;
519 }
520
521 weston_test_screenshot_shoot(output, buffer,
522 capture_screenshot_done, resource);
523}
524
Derek Foremanf6a65922015-02-24 09:32:14 -0600525static const struct weston_test_interface test_implementation = {
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800526 move_surface,
527 move_pointer,
528 send_button,
529 activate_surface,
Neil Roberts40c0c3f2013-10-29 20:13:45 +0000530 send_key,
Marek Chalupac8daf772015-03-30 06:37:55 -0400531 device_release,
532 device_add,
Neil Roberts40c0c3f2013-10-29 20:13:45 +0000533 get_n_buffers,
Bryce Harringtonf280d112015-05-05 15:13:20 -0700534 capture_screenshot,
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800535};
536
537static void
538bind_test(struct wl_client *client, void *data, uint32_t version, uint32_t id)
539{
540 struct weston_test *test = data;
541 struct wl_resource *resource;
542
Derek Foremanf6a65922015-02-24 09:32:14 -0600543 resource = wl_resource_create(client, &weston_test_interface, 1, id);
Marek Chalupa42ebdda2014-07-11 12:33:02 +0200544 if (!resource) {
545 wl_client_post_no_memory(client);
546 return;
547 }
548
Kristian Høgsberg442a5fa2013-07-03 18:13:33 -0400549 wl_resource_set_implementation(resource,
550 &test_implementation, test, NULL);
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800551
552 notify_pointer_position(test, resource);
553}
554
555static void
556idle_launch_client(void *data)
557{
558 struct weston_test *test = data;
559 pid_t pid;
560 sigset_t allsigs;
561 char *path;
562
563 path = getenv("WESTON_TEST_CLIENT_PATH");
564 if (path == NULL)
Pekka Paalanenf72e4792013-11-21 16:23:57 +0200565 return;
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800566 pid = fork();
567 if (pid == -1)
568 exit(EXIT_FAILURE);
569 if (pid == 0) {
570 sigfillset(&allsigs);
571 sigprocmask(SIG_UNBLOCK, &allsigs, NULL);
572 execl(path, path, NULL);
573 weston_log("compositor: executing '%s' failed: %m\n", path);
574 exit(EXIT_FAILURE);
575 }
576
577 test->process.pid = pid;
578 test->process.cleanup = test_client_sigchld;
579 weston_watch_process(&test->process);
580}
581
582WL_EXPORT int
Kristian Høgsbergcb4685b2013-02-20 15:37:49 -0500583module_init(struct weston_compositor *ec,
Ossama Othmana50e6e42013-05-14 09:48:26 -0700584 int *argc, char *argv[])
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800585{
586 struct weston_test *test;
587 struct wl_event_loop *loop;
588
Peter Huttererf3d62272013-08-08 11:57:05 +1000589 test = zalloc(sizeof *test);
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800590 if (test == NULL)
591 return -1;
592
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800593 test->compositor = ec;
594 weston_layer_init(&test->layer, &ec->cursor_layer.link);
595
Derek Foremanf6a65922015-02-24 09:32:14 -0600596 if (wl_global_create(ec->wl_display, &weston_test_interface, 1,
Kristian Høgsberg919cddb2013-07-08 19:03:57 -0400597 test, bind_test) == NULL)
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800598 return -1;
599
Marek Chalupac3c3fc42015-03-30 09:17:40 -0400600 /* create our own seat */
601 weston_seat_init(&test->seat, ec, "test-seat");
602
603 /* add devices */
604 weston_seat_init_pointer(&test->seat);
605 weston_seat_init_keyboard(&test->seat, NULL);
606 weston_seat_init_touch(&test->seat);
607
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800608 loop = wl_display_get_event_loop(ec->wl_display);
609 wl_event_loop_add_idle(loop, idle_launch_client, test);
610
611 return 0;
612}