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 pending_seats array which holds the IDs of any seats we get during display initialisation, and then add them when we're ready.
Signed-off-by: Daniel Stone <[email protected]> --- src/compositor-wayland.c | 60 ++++++++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c index 51163f7..61868af 100644 --- a/src/compositor-wayland.c +++ b/src/compositor-wayland.c @@ -69,6 +69,8 @@ struct wayland_compositor { } border; struct wl_list input_list; + struct wl_array pending_seats; + int no_new_input; }; struct wayland_output { @@ -245,23 +247,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; @@ -665,6 +650,13 @@ static void display_add_seat(struct wayland_compositor *c, uint32_t id) { struct wayland_input *input; + uint32_t *ptr; + + if (c->no_new_input) { + ptr = wl_array_add(&c->pending_seats, sizeof *ptr); + *ptr = id; + return; + } input = malloc(sizeof *input); if (input == NULL) @@ -727,9 +719,35 @@ 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; + uint32_t *id; + + seat = malloc(sizeof *seat); + if (seat == NULL) + return -1; + + memset(seat, 0, sizeof *seat); + weston_seat_init(seat, &c->base); + + c->base.seat = seat; + + c->no_new_input = 0; + + wl_array_for_each(id, &c->pending_seats) + display_add_seat(c, *id); + + return 0; +} + static void wayland_destroy(struct weston_compositor *ec) { + struct wayland_compositor *c = (struct wayland_compositor *) ec; + + wl_array_release(&c->pending_seats); weston_compositor_shutdown(ec); free(ec); @@ -756,7 +774,9 @@ wayland_compositor_create(struct wl_display *display, return NULL; } + c->no_new_input = 1; wl_list_init(&c->input_list); + wl_array_init(&c->pending_seats); wl_display_add_global_listener(c->parent.display, display_handle_global, c); @@ -772,11 +792,11 @@ wayland_compositor_create(struct wl_display *display, if (weston_compositor_init(&c->base, display) < 0) return NULL; - create_border(c); - if (wayland_compositor_create_output(c, width, height) < 0) + if (wayland_input_create(c) < 0) return NULL; - if (wayland_input_create(c) < 0) + create_border(c); + if (wayland_compositor_create_output(c, width, height) < 0) return NULL; loop = wl_display_get_event_loop(c->base.wl_display); -- 1.7.10 _______________________________________________ wayland-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/wayland-devel
