compositor-headless: create input devices

Fixes a segfault when using compositor-headless for the test suite
as many tests assume there are input devices and try to use them
through the wl_test interface.

Signed-off-by: Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>
dev
Emilio Pozuelo Monfort 11 years ago committed by Kristian Høgsberg
parent db1fccb3d8
commit dd9f6bc69b
  1. 30
      src/compositor-headless.c

@ -131,6 +131,25 @@ headless_compositor_create_output(struct headless_compositor *c,
return 0;
}
static int
headless_input_create(struct headless_compositor *c)
{
weston_seat_init(&c->fake_seat, &c->base, "default");
weston_seat_init_pointer(&c->fake_seat);
if (weston_seat_init_keyboard(&c->fake_seat, NULL) < 0)
return -1;
return 0;
}
static void
headless_input_destroy(struct headless_compositor *c)
{
weston_seat_release(&c->fake_seat);
}
static void
headless_restore(struct weston_compositor *ec)
{
@ -141,7 +160,7 @@ headless_destroy(struct weston_compositor *ec)
{
struct headless_compositor *c = (struct headless_compositor *) ec;
weston_seat_release(&c->fake_seat);
headless_input_destroy(c);
weston_compositor_shutdown(ec);
free(ec);
@ -162,19 +181,22 @@ headless_compositor_create(struct wl_display *display,
if (weston_compositor_init(&c->base, display, argc, argv, config) < 0)
goto err_free;
weston_seat_init(&c->fake_seat, &c->base, "default");
if (headless_input_create(c) < 0)
goto err_compositor;
c->base.destroy = headless_destroy;
c->base.restore = headless_restore;
if (headless_compositor_create_output(c, width, height) < 0)
goto err_compositor;
goto err_input;
if (noop_renderer_init(&c->base) < 0)
goto err_compositor;
goto err_input;
return &c->base;
err_input:
headless_input_destroy(c);
err_compositor:
weston_compositor_shutdown(&c->base);
err_free:

Loading…
Cancel
Save