From 65a751a21f61b30808b7e703257c6ca3b71f50eb Mon Sep 17 00:00:00 2001 From: Geoffrey Casper Date: Tue, 15 Sep 2020 10:53:35 -0400 Subject: [PATCH] server: Avoid using "wayland-0" as WAYLAND_DISPLAY See https://gitlab.freedesktop.org/wayland/weston/-/merge_requests/486 --- sway/server.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/sway/server.c b/sway/server.c index ff848450..5de73b39 100644 --- a/sway/server.c +++ b/sway/server.c @@ -1,7 +1,8 @@ -#define _POSIX_C_SOURCE 200112L +#define _POSIX_C_SOURCE 200809L #include #include #include +#include #include #include #include @@ -151,7 +152,16 @@ bool server_init(struct sway_server *server) { wlr_primary_selection_v1_device_manager_create(server->wl_display); wlr_viewporter_create(server->wl_display); - server->socket = wl_display_add_socket_auto(server->wl_display); + // Avoid using "wayland-0" as display socket + char name_candidate[16]; + for (int i = 1; i <= 32; ++i) { + sprintf(name_candidate, "wayland-%d", i); + if (wl_display_add_socket(server->wl_display, name_candidate) >= 0) { + server->socket = strdup(name_candidate); + break; + } + } + if (!server->socket) { sway_log(SWAY_ERROR, "Unable to open wayland socket"); wlr_backend_destroy(server->backend);