diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-10-15 15:37:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-15 15:37:17 +0200 |
commit | f6ad4908bc2f366ccbee18889ffe35c7ee436389 (patch) | |
tree | 8fb3b25e4e244bf32ddb4a27ecaffce9661a13c5 | |
parent | Merge pull request #2835 from RyanDwyer/swap-crash (diff) | |
parent | Sway clients: Exit gracefully when compositor is unavailable (diff) | |
download | sway-f6ad4908bc2f366ccbee18889ffe35c7ee436389.tar.gz sway-f6ad4908bc2f366ccbee18889ffe35c7ee436389.tar.zst sway-f6ad4908bc2f366ccbee18889ffe35c7ee436389.zip |
Merge pull request #2838 from RyanDwyer/compositor-unavailable-crash
Sway clients: Exit gracefully when compositor is unavailable
-rw-r--r-- | swaybar/bar.c | 6 | ||||
-rw-r--r-- | swaybg/main.c | 7 | ||||
-rw-r--r-- | swayidle/main.c | 4 | ||||
-rw-r--r-- | swaylock/main.c | 6 | ||||
-rw-r--r-- | swaynag/swaynag.c | 6 |
5 files changed, 24 insertions, 5 deletions
diff --git a/swaybar/bar.c b/swaybar/bar.c index be290c18..0deba72d 100644 --- a/swaybar/bar.c +++ b/swaybar/bar.c | |||
@@ -586,7 +586,11 @@ bool bar_setup(struct swaybar *bar, const char *socket_path) { | |||
586 | } | 586 | } |
587 | 587 | ||
588 | bar->display = wl_display_connect(NULL); | 588 | bar->display = wl_display_connect(NULL); |
589 | assert(bar->display); | 589 | if (!bar->display) { |
590 | sway_abort("Unable to connect to the compositor. " | ||
591 | "If your compositor is running, check or set the " | ||
592 | "WAYLAND_DISPLAY environment variable."); | ||
593 | } | ||
590 | 594 | ||
591 | struct wl_registry *registry = wl_display_get_registry(bar->display); | 595 | struct wl_registry *registry = wl_display_get_registry(bar->display); |
592 | wl_registry_add_listener(registry, ®istry_listener, bar); | 596 | wl_registry_add_listener(registry, ®istry_listener, bar); |
diff --git a/swaybg/main.c b/swaybg/main.c index 742669ef..45b7a913 100644 --- a/swaybg/main.c +++ b/swaybg/main.c | |||
@@ -222,7 +222,12 @@ int main(int argc, const char **argv) { | |||
222 | } | 222 | } |
223 | 223 | ||
224 | state.display = wl_display_connect(NULL); | 224 | state.display = wl_display_connect(NULL); |
225 | assert(state.display); | 225 | if (!state.display) { |
226 | wlr_log(WLR_ERROR, "Unable to connect to the compositor. " | ||
227 | "If your compositor is running, check or set the " | ||
228 | "WAYLAND_DISPLAY environment variable."); | ||
229 | return 1; | ||
230 | } | ||
226 | 231 | ||
227 | struct wl_registry *registry = wl_display_get_registry(state.display); | 232 | struct wl_registry *registry = wl_display_get_registry(state.display); |
228 | wl_registry_add_listener(registry, ®istry_listener, &state); | 233 | wl_registry_add_listener(registry, ®istry_listener, &state); |
diff --git a/swayidle/main.c b/swayidle/main.c index 5b6c95a7..93f4c94b 100644 --- a/swayidle/main.c +++ b/swayidle/main.c | |||
@@ -388,7 +388,9 @@ int main(int argc, char *argv[]) { | |||
388 | 388 | ||
389 | state.display = wl_display_connect(NULL); | 389 | state.display = wl_display_connect(NULL); |
390 | if (state.display == NULL) { | 390 | if (state.display == NULL) { |
391 | wlr_log(WLR_ERROR, "Failed to create display"); | 391 | wlr_log(WLR_ERROR, "Unable to connect to the compositor. " |
392 | "If your compositor is running, check or set the " | ||
393 | "WAYLAND_DISPLAY environment variable."); | ||
392 | return -3; | 394 | return -3; |
393 | } | 395 | } |
394 | 396 | ||
diff --git a/swaylock/main.c b/swaylock/main.c index 27bcfe32..04c0bb07 100644 --- a/swaylock/main.c +++ b/swaylock/main.c | |||
@@ -908,7 +908,11 @@ int main(int argc, char **argv) { | |||
908 | wl_list_init(&state.surfaces); | 908 | wl_list_init(&state.surfaces); |
909 | state.xkb.context = xkb_context_new(XKB_CONTEXT_NO_FLAGS); | 909 | state.xkb.context = xkb_context_new(XKB_CONTEXT_NO_FLAGS); |
910 | state.display = wl_display_connect(NULL); | 910 | state.display = wl_display_connect(NULL); |
911 | assert(state.display); | 911 | if (!state.display) { |
912 | sway_abort("Unable to connect to the compositor. " | ||
913 | "If your compositor is running, check or set the " | ||
914 | "WAYLAND_DISPLAY environment variable."); | ||
915 | } | ||
912 | 916 | ||
913 | struct wl_registry *registry = wl_display_get_registry(state.display); | 917 | struct wl_registry *registry = wl_display_get_registry(state.display); |
914 | wl_registry_add_listener(registry, ®istry_listener, &state); | 918 | wl_registry_add_listener(registry, ®istry_listener, &state); |
diff --git a/swaynag/swaynag.c b/swaynag/swaynag.c index 69da851e..fa6bbe05 100644 --- a/swaynag/swaynag.c +++ b/swaynag/swaynag.c | |||
@@ -342,7 +342,11 @@ static const struct wl_registry_listener registry_listener = { | |||
342 | 342 | ||
343 | void swaynag_setup(struct swaynag *swaynag) { | 343 | void swaynag_setup(struct swaynag *swaynag) { |
344 | swaynag->display = wl_display_connect(NULL); | 344 | swaynag->display = wl_display_connect(NULL); |
345 | assert(swaynag->display); | 345 | if (!swaynag->display) { |
346 | sway_abort("Unable to connect to the compositor. " | ||
347 | "If your compositor is running, check or set the " | ||
348 | "WAYLAND_DISPLAY environment variable."); | ||
349 | } | ||
346 | 350 | ||
347 | swaynag->scale = 1; | 351 | swaynag->scale = 1; |
348 | wl_list_init(&swaynag->outputs); | 352 | wl_list_init(&swaynag->outputs); |