blob: 0123e994637d16ea2bf1c5143b7c207c865169ac [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
Jussi Kukkonen649bbce2016-07-19 14:16:27 +030028#include <stdint.h>
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -080029#include <stdlib.h>
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -080030#include <assert.h>
31#include <signal.h>
32#include <unistd.h>
Marek Chalupac8daf772015-03-30 06:37:55 -040033#include <string.h>
Bryce Harringtona7680262014-11-19 17:18:34 -080034
Pekka Paalanenb5e3ea22016-06-03 17:12:10 +030035#include "compositor.h"
Pekka Paalanen58f98c92016-06-03 16:45:21 +030036#include "compositor/weston.h"
Derek Foremanf6a65922015-02-24 09:32:14 -060037#include "weston-test-server-protocol.h"
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -080038
Neil Roberts40c0c3f2013-10-29 20:13:45 +000039#ifdef ENABLE_EGL
40#include <EGL/egl.h>
41#include <EGL/eglext.h>
Pekka Paalanenb5e3ea22016-06-03 17:12:10 +030042#include "weston-egl-ext.h"
Neil Roberts40c0c3f2013-10-29 20:13:45 +000043#endif /* ENABLE_EGL */
44
Jon Cruz867d50e2015-06-15 15:37:10 -070045#include "shared/helpers.h"
46
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -080047struct weston_test {
48 struct weston_compositor *compositor;
49 struct weston_layer layer;
50 struct weston_process process;
Marek Chalupac3c3fc42015-03-30 09:17:40 -040051 struct weston_seat seat;
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -080052};
53
54struct weston_test_surface {
55 struct weston_surface *surface;
Jason Ekstranda7af7042013-10-12 22:38:11 -050056 struct weston_view *view;
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -080057 int32_t x, y;
58 struct weston_test *test;
59};
60
61static void
62test_client_sigchld(struct weston_process *process, int status)
63{
64 struct weston_test *test =
65 container_of(process, struct weston_test, process);
66
Emilio Pozuelo Monfortdae8a4b2014-02-07 09:34:48 +010067 /* Chain up from weston-test-runner's exit code so that automake
68 * knows the exit status and can report e.g. skipped tests. */
69 if (WIFEXITED(status) && WEXITSTATUS(status) != 0)
70 exit(WEXITSTATUS(status));
71
72 /* In case the child aborted or segfaulted... */
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -080073 assert(status == 0);
74
75 wl_display_terminate(test->compositor->wl_display);
76}
77
78static struct weston_seat *
79get_seat(struct weston_test *test)
80{
Marek Chalupac3c3fc42015-03-30 09:17:40 -040081 return &test->seat;
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -080082}
83
84static void
85notify_pointer_position(struct weston_test *test, struct wl_resource *resource)
86{
87 struct weston_seat *seat = get_seat(test);
Derek Foreman1281a362015-07-31 16:55:32 -050088 struct weston_pointer *pointer = weston_seat_get_pointer(seat);
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -080089
Derek Foremanf6a65922015-02-24 09:32:14 -060090 weston_test_send_pointer_position(resource, pointer->x, pointer->y);
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -080091}
92
93static void
Quentin Glidic2edc3d52016-08-12 10:41:33 +020094test_surface_committed(struct weston_surface *surface, int32_t sx, int32_t sy)
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -080095{
Quentin Glidic2edc3d52016-08-12 10:41:33 +020096 struct weston_test_surface *test_surface = surface->committed_private;
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -080097 struct weston_test *test = test_surface->test;
98
Giulio Camuffo412e6a52014-07-09 22:12:56 +030099 if (wl_list_empty(&test_surface->view->layer_link.link))
100 weston_layer_entry_insert(&test->layer.view_list,
101 &test_surface->view->layer_link);
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800102
Jason Ekstrand918f2dd2013-12-02 21:01:53 -0600103 weston_view_set_position(test_surface->view,
104 test_surface->x, test_surface->y);
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800105
Kristian Høgsbergace0a392013-11-13 21:55:57 -0800106 weston_view_update_transform(test_surface->view);
Armin Krezovićd0cf4412016-06-30 06:04:32 +0200107
108 test_surface->surface->is_mapped = true;
109 test_surface->view->is_mapped = true;
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800110}
111
112static void
113move_surface(struct wl_client *client, struct wl_resource *resource,
114 struct wl_resource *surface_resource,
115 int32_t x, int32_t y)
116{
Kristian Høgsberg8f7f4832013-06-25 16:18:35 -0400117 struct weston_surface *surface =
118 wl_resource_get_user_data(surface_resource);
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800119 struct weston_test_surface *test_surface;
120
Quentin Glidic2edc3d52016-08-12 10:41:33 +0200121 test_surface = surface->committed_private;
Jason Ekstranda7af7042013-10-12 22:38:11 -0500122 if (!test_surface) {
123 test_surface = malloc(sizeof *test_surface);
124 if (!test_surface) {
125 wl_resource_post_no_memory(resource);
126 return;
127 }
128
129 test_surface->view = weston_view_create(surface);
130 if (!test_surface->view) {
131 wl_resource_post_no_memory(resource);
132 free(test_surface);
133 return;
134 }
135
Quentin Glidic2edc3d52016-08-12 10:41:33 +0200136 surface->committed_private = test_surface;
137 surface->committed = test_surface_committed;
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800138 }
139
140 test_surface->surface = surface;
Kristian Høgsberg8f7f4832013-06-25 16:18:35 -0400141 test_surface->test = wl_resource_get_user_data(resource);
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800142 test_surface->x = x;
143 test_surface->y = y;
144}
145
146static void
147move_pointer(struct wl_client *client, struct wl_resource *resource,
148 int32_t x, int32_t y)
149{
Kristian Høgsberg8f7f4832013-06-25 16:18:35 -0400150 struct weston_test *test = wl_resource_get_user_data(resource);
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800151 struct weston_seat *seat = get_seat(test);
Derek Foreman1281a362015-07-31 16:55:32 -0500152 struct weston_pointer *pointer = weston_seat_get_pointer(seat);
Jonas Ådahld2510102014-10-05 21:39:14 +0200153 struct weston_pointer_motion_event event = { 0 };
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800154
Jonas Ådahld2510102014-10-05 21:39:14 +0200155 event = (struct weston_pointer_motion_event) {
156 .mask = WESTON_POINTER_MOTION_REL,
157 .dx = wl_fixed_to_double(wl_fixed_from_int(x) - pointer->x),
158 .dy = wl_fixed_to_double(wl_fixed_from_int(y) - pointer->y),
159 };
160
161 notify_motion(seat, 100, &event);
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800162
163 notify_pointer_position(test, resource);
164}
165
166static void
167send_button(struct wl_client *client, struct wl_resource *resource,
168 int32_t button, uint32_t state)
169{
Kristian Høgsberg8f7f4832013-06-25 16:18:35 -0400170 struct weston_test *test = wl_resource_get_user_data(resource);
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800171 struct weston_seat *seat = get_seat(test);
172
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800173 notify_button(seat, 100, button, state);
174}
175
176static void
177activate_surface(struct wl_client *client, struct wl_resource *resource,
178 struct wl_resource *surface_resource)
179{
180 struct weston_surface *surface = surface_resource ?
Kristian Høgsberg8f7f4832013-06-25 16:18:35 -0400181 wl_resource_get_user_data(surface_resource) : NULL;
182 struct weston_test *test = wl_resource_get_user_data(resource);
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800183 struct weston_seat *seat;
Derek Foreman1281a362015-07-31 16:55:32 -0500184 struct weston_keyboard *keyboard;
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800185
186 seat = get_seat(test);
Derek Foreman1281a362015-07-31 16:55:32 -0500187 keyboard = weston_seat_get_keyboard(seat);
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800188 if (surface) {
Bryce Harrington260c2ff2016-06-29 19:04:06 -0700189 weston_seat_set_keyboard_focus(seat, surface);
Derek Foreman1281a362015-07-31 16:55:32 -0500190 notify_keyboard_focus_in(seat, &keyboard->keys,
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800191 STATE_UPDATE_AUTOMATIC);
192 }
193 else {
194 notify_keyboard_focus_out(seat);
Bryce Harrington260c2ff2016-06-29 19:04:06 -0700195 weston_seat_set_keyboard_focus(seat, surface);
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800196 }
197}
198
199static void
200send_key(struct wl_client *client, struct wl_resource *resource,
201 uint32_t key, enum wl_keyboard_key_state state)
202{
Kristian Høgsberg8f7f4832013-06-25 16:18:35 -0400203 struct weston_test *test = wl_resource_get_user_data(resource);
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800204 struct weston_seat *seat = get_seat(test);
205
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800206 notify_key(seat, 100, key, state, STATE_UPDATE_AUTOMATIC);
207}
208
Marek Chalupac8daf772015-03-30 06:37:55 -0400209static void
210device_release(struct wl_client *client,
211 struct wl_resource *resource, const char *device)
212{
213 struct weston_test *test = wl_resource_get_user_data(resource);
214 struct weston_seat *seat = get_seat(test);
215
216 if (strcmp(device, "pointer") == 0) {
217 weston_seat_release_pointer(seat);
218 } else if (strcmp(device, "keyboard") == 0) {
219 weston_seat_release_keyboard(seat);
220 } else if (strcmp(device, "touch") == 0) {
221 weston_seat_release_touch(seat);
222 } else if (strcmp(device, "seat") == 0) {
223 weston_seat_release(seat);
224 } else {
225 assert(0 && "Unsupported device");
226 }
227}
228
229static void
230device_add(struct wl_client *client,
231 struct wl_resource *resource, const char *device)
232{
233 struct weston_test *test = wl_resource_get_user_data(resource);
234 struct weston_seat *seat = get_seat(test);
235
236 if (strcmp(device, "pointer") == 0) {
237 weston_seat_init_pointer(seat);
238 } else if (strcmp(device, "keyboard") == 0) {
239 weston_seat_init_keyboard(seat, NULL);
240 } else if (strcmp(device, "touch") == 0) {
241 weston_seat_init_touch(seat);
242 } else {
243 assert(0 && "Unsupported device");
244 }
245}
246
Bryce Harringtonf280d112015-05-05 15:13:20 -0700247enum weston_test_screenshot_outcome {
248 WESTON_TEST_SCREENSHOT_SUCCESS,
249 WESTON_TEST_SCREENSHOT_NO_MEMORY,
250 WESTON_TEST_SCREENSHOT_BAD_BUFFER
251 };
252
253typedef void (*weston_test_screenshot_done_func_t)(void *data,
254 enum weston_test_screenshot_outcome outcome);
255
256struct test_screenshot {
257 struct weston_compositor *compositor;
258 struct wl_global *global;
259 struct wl_client *client;
260 struct weston_process process;
261 struct wl_listener destroy_listener;
262};
263
264struct test_screenshot_frame_listener {
265 struct wl_listener listener;
266 struct weston_buffer *buffer;
267 weston_test_screenshot_done_func_t done;
268 void *data;
269};
270
271static void
272copy_bgra_yflip(uint8_t *dst, uint8_t *src, int height, int stride)
273{
274 uint8_t *end;
275
276 end = dst + height * stride;
277 while (dst < end) {
278 memcpy(dst, src, stride);
279 dst += stride;
280 src -= stride;
281 }
282}
283
284
285static void
286copy_bgra(uint8_t *dst, uint8_t *src, int height, int stride)
287{
288 /* TODO: optimize this out */
289 memcpy(dst, src, height * stride);
290}
291
292static void
293copy_row_swap_RB(void *vdst, void *vsrc, int bytes)
294{
295 uint32_t *dst = vdst;
296 uint32_t *src = vsrc;
297 uint32_t *end = dst + bytes / 4;
298
299 while (dst < end) {
300 uint32_t v = *src++;
301 /* A R G B */
302 uint32_t tmp = v & 0xff00ff00;
303 tmp |= (v >> 16) & 0x000000ff;
304 tmp |= (v << 16) & 0x00ff0000;
305 *dst++ = tmp;
306 }
307}
308
309static void
310copy_rgba_yflip(uint8_t *dst, uint8_t *src, int height, int stride)
311{
312 uint8_t *end;
313
314 end = dst + height * stride;
315 while (dst < end) {
316 copy_row_swap_RB(dst, src, stride);
317 dst += stride;
318 src -= stride;
319 }
320}
321
322static void
323copy_rgba(uint8_t *dst, uint8_t *src, int height, int stride)
324{
325 uint8_t *end;
326
327 end = dst + height * stride;
328 while (dst < end) {
329 copy_row_swap_RB(dst, src, stride);
330 dst += stride;
331 src += stride;
332 }
333}
334
335static void
336test_screenshot_frame_notify(struct wl_listener *listener, void *data)
337{
338 struct test_screenshot_frame_listener *l =
339 container_of(listener,
340 struct test_screenshot_frame_listener, listener);
341 struct weston_output *output = data;
342 struct weston_compositor *compositor = output->compositor;
343 int32_t stride;
344 uint8_t *pixels, *d, *s;
345
346 output->disable_planes--;
347 wl_list_remove(&listener->link);
348 stride = l->buffer->width * (PIXMAN_FORMAT_BPP(compositor->read_format) / 8);
349 pixels = malloc(stride * l->buffer->height);
350
351 if (pixels == NULL) {
352 l->done(l->data, WESTON_TEST_SCREENSHOT_NO_MEMORY);
353 free(l);
354 return;
355 }
356
Chris Michael2ec5f2a2015-12-03 12:23:12 -0500357 /* FIXME: Needs to handle output transformations */
Bryce Harringtonf280d112015-05-05 15:13:20 -0700358
359 compositor->renderer->read_pixels(output,
360 compositor->read_format,
361 pixels,
362 0, 0,
363 output->current_mode->width,
364 output->current_mode->height);
365
366 stride = wl_shm_buffer_get_stride(l->buffer->shm_buffer);
367
368 d = wl_shm_buffer_get_data(l->buffer->shm_buffer);
369 s = pixels + stride * (l->buffer->height - 1);
370
371 wl_shm_buffer_begin_access(l->buffer->shm_buffer);
372
373 /* XXX: It would be nice if we used Pixman to do all this rather
374 * than our own implementation
375 */
376 switch (compositor->read_format) {
377 case PIXMAN_a8r8g8b8:
378 case PIXMAN_x8r8g8b8:
379 if (compositor->capabilities & WESTON_CAP_CAPTURE_YFLIP)
380 copy_bgra_yflip(d, s, output->current_mode->height, stride);
381 else
382 copy_bgra(d, pixels, output->current_mode->height, stride);
383 break;
384 case PIXMAN_x8b8g8r8:
385 case PIXMAN_a8b8g8r8:
386 if (compositor->capabilities & WESTON_CAP_CAPTURE_YFLIP)
387 copy_rgba_yflip(d, s, output->current_mode->height, stride);
388 else
389 copy_rgba(d, pixels, output->current_mode->height, stride);
390 break;
391 default:
392 break;
393 }
394
395 wl_shm_buffer_end_access(l->buffer->shm_buffer);
396
397 l->done(l->data, WESTON_TEST_SCREENSHOT_SUCCESS);
398 free(pixels);
399 free(l);
400}
401
402static bool
403weston_test_screenshot_shoot(struct weston_output *output,
404 struct weston_buffer *buffer,
405 weston_test_screenshot_done_func_t done,
406 void *data)
407{
408 struct test_screenshot_frame_listener *l;
409
410 /* Get the shm buffer resource the client created */
411 if (!wl_shm_buffer_get(buffer->resource)) {
412 done(data, WESTON_TEST_SCREENSHOT_BAD_BUFFER);
413 return false;
414 }
415
416 buffer->shm_buffer = wl_shm_buffer_get(buffer->resource);
417 buffer->width = wl_shm_buffer_get_width(buffer->shm_buffer);
418 buffer->height = wl_shm_buffer_get_height(buffer->shm_buffer);
419
420 /* Verify buffer is big enough */
421 if (buffer->width < output->current_mode->width ||
422 buffer->height < output->current_mode->height) {
423 done(data, WESTON_TEST_SCREENSHOT_BAD_BUFFER);
424 return false;
425 }
426
427 /* allocate the frame listener */
428 l = malloc(sizeof *l);
429 if (l == NULL) {
430 done(data, WESTON_TEST_SCREENSHOT_NO_MEMORY);
431 return false;
432 }
433
434 /* Set up the listener */
435 l->buffer = buffer;
436 l->done = done;
437 l->data = data;
438 l->listener.notify = test_screenshot_frame_notify;
439 wl_signal_add(&output->frame_signal, &l->listener);
440
441 /* Fire off a repaint */
442 output->disable_planes++;
443 weston_output_schedule_repaint(output);
444
445 return true;
446}
447
448static void
449capture_screenshot_done(void *data, enum weston_test_screenshot_outcome outcome)
450{
451 struct wl_resource *resource = data;
452
453 switch (outcome) {
454 case WESTON_TEST_SCREENSHOT_SUCCESS:
455 weston_test_send_capture_screenshot_done(resource);
456 break;
457 case WESTON_TEST_SCREENSHOT_NO_MEMORY:
458 wl_resource_post_no_memory(resource);
459 break;
460 default:
461 break;
462 }
463}
464
465
466/**
467 * Grabs a snapshot of the screen.
468 */
469static void
470capture_screenshot(struct wl_client *client,
471 struct wl_resource *resource,
472 struct wl_resource *output_resource,
473 struct wl_resource *buffer_resource)
474{
475 struct weston_output *output =
476 wl_resource_get_user_data(output_resource);
477 struct weston_buffer *buffer =
478 weston_buffer_from_resource(buffer_resource);
479
480 if (buffer == NULL) {
481 wl_resource_post_no_memory(resource);
482 return;
483 }
484
485 weston_test_screenshot_shoot(output, buffer,
486 capture_screenshot_done, resource);
487}
488
Derek Foremanf6a65922015-02-24 09:32:14 -0600489static const struct weston_test_interface test_implementation = {
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800490 move_surface,
491 move_pointer,
492 send_button,
493 activate_surface,
Neil Roberts40c0c3f2013-10-29 20:13:45 +0000494 send_key,
Marek Chalupac8daf772015-03-30 06:37:55 -0400495 device_release,
496 device_add,
Bryce Harringtonf280d112015-05-05 15:13:20 -0700497 capture_screenshot,
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800498};
499
500static void
501bind_test(struct wl_client *client, void *data, uint32_t version, uint32_t id)
502{
503 struct weston_test *test = data;
504 struct wl_resource *resource;
505
Derek Foremanf6a65922015-02-24 09:32:14 -0600506 resource = wl_resource_create(client, &weston_test_interface, 1, id);
Marek Chalupa42ebdda2014-07-11 12:33:02 +0200507 if (!resource) {
508 wl_client_post_no_memory(client);
509 return;
510 }
511
Kristian Høgsberg442a5fa2013-07-03 18:13:33 -0400512 wl_resource_set_implementation(resource,
513 &test_implementation, test, NULL);
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800514
515 notify_pointer_position(test, resource);
516}
517
518static void
519idle_launch_client(void *data)
520{
521 struct weston_test *test = data;
522 pid_t pid;
523 sigset_t allsigs;
524 char *path;
525
526 path = getenv("WESTON_TEST_CLIENT_PATH");
527 if (path == NULL)
Pekka Paalanenf72e4792013-11-21 16:23:57 +0200528 return;
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800529 pid = fork();
530 if (pid == -1)
531 exit(EXIT_FAILURE);
532 if (pid == 0) {
533 sigfillset(&allsigs);
534 sigprocmask(SIG_UNBLOCK, &allsigs, NULL);
535 execl(path, path, NULL);
536 weston_log("compositor: executing '%s' failed: %m\n", path);
537 exit(EXIT_FAILURE);
538 }
539
540 test->process.pid = pid;
541 test->process.cleanup = test_client_sigchld;
542 weston_watch_process(&test->process);
543}
544
545WL_EXPORT int
Quentin Glidic8af2bec2016-12-02 14:21:46 +0100546wet_module_init(struct weston_compositor *ec,
547 int *argc, char *argv[])
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800548{
549 struct weston_test *test;
550 struct wl_event_loop *loop;
551
Peter Huttererf3d62272013-08-08 11:57:05 +1000552 test = zalloc(sizeof *test);
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800553 if (test == NULL)
554 return -1;
555
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800556 test->compositor = ec;
Quentin Glidic82681572016-12-17 13:40:51 +0100557 weston_layer_init(&test->layer, ec);
558 weston_layer_set_position(&test->layer, WESTON_LAYER_POSITION_CURSOR - 1);
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800559
Derek Foremanf6a65922015-02-24 09:32:14 -0600560 if (wl_global_create(ec->wl_display, &weston_test_interface, 1,
Kristian Høgsberg919cddb2013-07-08 19:03:57 -0400561 test, bind_test) == NULL)
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800562 return -1;
563
Marek Chalupac3c3fc42015-03-30 09:17:40 -0400564 /* create our own seat */
565 weston_seat_init(&test->seat, ec, "test-seat");
566
567 /* add devices */
568 weston_seat_init_pointer(&test->seat);
Pekka Paalanen315bf8c2016-06-16 12:04:53 +0300569 if (weston_seat_init_keyboard(&test->seat, NULL) < 0)
570 return -1;
Marek Chalupac3c3fc42015-03-30 09:17:40 -0400571 weston_seat_init_touch(&test->seat);
572
U. Artie Eoff65e7e7a2012-12-07 13:50:29 -0800573 loop = wl_display_get_event_loop(ec->wl_display);
574 wl_event_loop_add_idle(loop, idle_launch_client, test);
575
576 return 0;
577}