[PATCH weston v2 1/6] compositor-headless: create input devices

Emilio Pozuelo Monfort pochu27 at gmail.com
Fri Feb 7 00:34:43 PST 2014


From: Emilio Pozuelo Monfort <emilio.pozuelo at collabora.co.uk>

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 at collabora.co.uk>
---
 src/compositor-headless.c | 30 ++++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/src/compositor-headless.c b/src/compositor-headless.c
index 5a5c1e6..4ecb8d4 100644
--- a/src/compositor-headless.c
+++ b/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:
-- 
1.9.rc1



More information about the wayland-devel mailing list