xwayland/server: delay non-lazy startup
This allows users to setup event listeners before the server is actually started.
This commit is contained in:
parent
3f40b0031f
commit
d19191ff6b
|
@ -39,6 +39,7 @@ struct wlr_xwayland_server {
|
||||||
struct wlr_xwayland_server_options options;
|
struct wlr_xwayland_server_options options;
|
||||||
|
|
||||||
struct wl_display *wl_display;
|
struct wl_display *wl_display;
|
||||||
|
struct wl_event_source *idle_source;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
struct wl_signal start;
|
struct wl_signal start;
|
||||||
|
|
|
@ -426,11 +426,20 @@ static bool server_start_lazy(struct wlr_xwayland_server *server) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handle_idle(void *data) {
|
||||||
|
struct wlr_xwayland_server *server = data;
|
||||||
|
server->idle_source = NULL;
|
||||||
|
server_start(server);
|
||||||
|
}
|
||||||
|
|
||||||
void wlr_xwayland_server_destroy(struct wlr_xwayland_server *server) {
|
void wlr_xwayland_server_destroy(struct wlr_xwayland_server *server) {
|
||||||
if (!server) {
|
if (!server) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (server->idle_source != NULL) {
|
||||||
|
wl_event_source_remove(server->idle_source);
|
||||||
|
}
|
||||||
server_finish_process(server);
|
server_finish_process(server);
|
||||||
server_finish_display(server);
|
server_finish_display(server);
|
||||||
wl_signal_emit_mutable(&server->events.destroy, NULL);
|
wl_signal_emit_mutable(&server->events.destroy, NULL);
|
||||||
|
@ -475,7 +484,9 @@ struct wlr_xwayland_server *wlr_xwayland_server_create(
|
||||||
goto error_display;
|
goto error_display;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!server_start(server)) {
|
struct wl_event_loop *loop = wl_display_get_event_loop(wl_display);
|
||||||
|
server->idle_source = wl_event_loop_add_idle(loop, handle_idle, server);
|
||||||
|
if (server->idle_source == NULL) {
|
||||||
goto error_display;
|
goto error_display;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue