[PATCH weston 1/3] compositor-wayland: Delay seat creation
Daniel Stone
daniel at fooishbar.org
Mon Jun 4 03:40:46 PDT 2012
We'll get a rash of seats added when we run our first wl_display_iterate
across the parent display, but won't actually be ready to create them.
Create a new global listener on our parent display for wl_seats only,
and run that from wayland_input_create.
Signed-off-by: Daniel Stone <daniel at fooishbar.org>
---
src/compositor-wayland.c | 56 ++++++++++++++++++++++++++++++----------------
1 file changed, 37 insertions(+), 19 deletions(-)
diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c
index 9e1f8a3..c25f093 100644
--- a/src/compositor-wayland.c
+++ b/src/compositor-wayland.c
@@ -246,23 +246,6 @@ create_border(struct wayland_compositor *c)
}
static int
-wayland_input_create(struct wayland_compositor *c)
-{
- struct weston_seat *seat;
-
- seat = malloc(sizeof *seat);
- if (seat == NULL)
- return -1;
-
- memset(seat, 0, sizeof *seat);
- weston_seat_init(seat, &c->base);
-
- c->base.seat = seat;
-
- return 0;
-}
-
-static int
wayland_compositor_init_egl(struct wayland_compositor *c)
{
EGLint major, minor;
@@ -722,6 +705,22 @@ display_add_seat(struct wayland_compositor *c, uint32_t id)
wl_seat_set_user_data(input->seat, input);
}
+/* We can't start adding input devices until weston_compositor_init, but
+ * also can't call weston_compositor_init until we've handled some of the
+ * base display code first. So, we have a separate global handler for
+ * seats. */
+static void
+display_handle_global_input(struct wl_display *display, uint32_t id,
+ const char *interface, uint32_t version,
+ void *data)
+{
+ struct wayland_compositor *c = data;
+
+ if (strcmp(interface, "wl_seat") == 0)
+ display_add_seat(c, id);
+}
+
+
static void
display_handle_global(struct wl_display *display, uint32_t id,
const char *interface, uint32_t version, void *data)
@@ -735,8 +734,6 @@ display_handle_global(struct wl_display *display, uint32_t id,
c->parent.output =
wl_display_bind(display, id, &wl_output_interface);
wl_output_add_listener(c->parent.output, &output_listener, c);
- } else if (strcmp(interface, "wl_seat") == 0) {
- display_add_seat(c, id);
} else if (strcmp(interface, "wl_shell") == 0) {
c->parent.shell =
wl_display_bind(display, id, &wl_shell_interface);
@@ -768,6 +765,27 @@ wayland_compositor_handle_event(int fd, uint32_t mask, void *data)
return 1;
}
+static int
+wayland_input_create(struct wayland_compositor *c)
+{
+ struct weston_seat *seat;
+
+ seat = malloc(sizeof *seat);
+ if (seat == NULL)
+ return -1;
+
+ memset(seat, 0, sizeof *seat);
+ weston_seat_init(seat, &c->base);
+
+ c->base.seat = seat;
+
+ wl_display_add_global_listener(c->parent.display,
+ display_handle_global_input,
+ c);
+
+ return 0;
+}
+
static void
wayland_destroy(struct weston_compositor *ec)
{
--
1.7.10
More information about the wayland-devel
mailing list