From 7eafcc75f6f8abd2346e0d72b063bc10ce24378f Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sat, 11 Nov 2017 11:58:43 -0500 Subject: Initialize outputs from backend and add to tree --- sway/server.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'sway/server.c') diff --git a/sway/server.c b/sway/server.c index 4a74cfb5..b7ce4612 100644 --- a/sway/server.c +++ b/sway/server.c @@ -27,23 +27,14 @@ bool server_init(struct sway_server *server) { server->data_device_manager = wlr_data_device_manager_create(server->wl_display); - const char *socket = wl_display_add_socket_auto(server->wl_display); - if (!socket) { - sway_log_errno(L_ERROR, "Unable to open wayland socket"); - wlr_backend_destroy(server->backend); - return false; - } + server->output_add.notify = output_add_notify; + wl_signal_add(&server->backend->events.output_add, &server->output_add); - sway_log(L_INFO, "Running compositor on wayland display '%s'", socket); - setenv("_WAYLAND_DISPLAY", socket, true); - - if (!wlr_backend_start(server->backend)) { - sway_log(L_ERROR, "Failed to start backend"); + server->socket = wl_display_add_socket_auto(server->wl_display); + if (!sway_assert(server->socket, "Unable to open wayland socket")) { wlr_backend_destroy(server->backend); return false; } - - setenv("WAYLAND_DISPLAY", socket, true); return true; } @@ -51,3 +42,16 @@ void server_fini(struct sway_server *server) { // TODO WLR: tear down more stuff wlr_backend_destroy(server->backend); } + +void server_run(struct sway_server *server) { + sway_log(L_INFO, "Running compositor on wayland display '%s'", + server->socket); + setenv("_WAYLAND_DISPLAY", server->socket, true); + if (!sway_assert(wlr_backend_start(server->backend), + "Failed to start backend")) { + wlr_backend_destroy(server->backend); + return; + } + setenv("WAYLAND_DISPLAY", server->socket, true); + wl_display_run(server->wl_display); +} -- cgit v1.2.3