diff options
author | Geoffrey Casper <gcasper42@gmail.com> | 2020-09-15 10:53:35 -0400 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2020-09-16 00:14:20 +0200 |
commit | 65a751a21f61b30808b7e703257c6ca3b71f50eb (patch) | |
tree | beddddbadda474e353ae8d1151d53ccf51ea3698 /sway/server.c | |
parent | Fix minor typos in German README (diff) | |
download | sway-65a751a21f61b30808b7e703257c6ca3b71f50eb.tar.gz sway-65a751a21f61b30808b7e703257c6ca3b71f50eb.tar.zst sway-65a751a21f61b30808b7e703257c6ca3b71f50eb.zip |
server: Avoid using "wayland-0" as WAYLAND_DISPLAY
See https://gitlab.freedesktop.org/wayland/weston/-/merge_requests/486
Diffstat (limited to 'sway/server.c')
-rw-r--r-- | sway/server.c | 14 |
1 files 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 @@ | |||
1 | #define _POSIX_C_SOURCE 200112L | 1 | #define _POSIX_C_SOURCE 200809L |
2 | #include <assert.h> | 2 | #include <assert.h> |
3 | #include <stdbool.h> | 3 | #include <stdbool.h> |
4 | #include <stdlib.h> | 4 | #include <stdlib.h> |
5 | #include <string.h> | ||
5 | #include <wayland-server-core.h> | 6 | #include <wayland-server-core.h> |
6 | #include <wlr/backend.h> | 7 | #include <wlr/backend.h> |
7 | #include <wlr/backend/headless.h> | 8 | #include <wlr/backend/headless.h> |
@@ -151,7 +152,16 @@ bool server_init(struct sway_server *server) { | |||
151 | wlr_primary_selection_v1_device_manager_create(server->wl_display); | 152 | wlr_primary_selection_v1_device_manager_create(server->wl_display); |
152 | wlr_viewporter_create(server->wl_display); | 153 | wlr_viewporter_create(server->wl_display); |
153 | 154 | ||
154 | server->socket = wl_display_add_socket_auto(server->wl_display); | 155 | // Avoid using "wayland-0" as display socket |
156 | char name_candidate[16]; | ||
157 | for (int i = 1; i <= 32; ++i) { | ||
158 | sprintf(name_candidate, "wayland-%d", i); | ||
159 | if (wl_display_add_socket(server->wl_display, name_candidate) >= 0) { | ||
160 | server->socket = strdup(name_candidate); | ||
161 | break; | ||
162 | } | ||
163 | } | ||
164 | |||
155 | if (!server->socket) { | 165 | if (!server->socket) { |
156 | sway_log(SWAY_ERROR, "Unable to open wayland socket"); | 166 | sway_log(SWAY_ERROR, "Unable to open wayland socket"); |
157 | wlr_backend_destroy(server->backend); | 167 | wlr_backend_destroy(server->backend); |