mirror of
https://github.com/swaywm/sway.git
synced 2024-11-14 06:24:20 +01:00
Merge pull request #2838 from RyanDwyer/compositor-unavailable-crash
Sway clients: Exit gracefully when compositor is unavailable
This commit is contained in:
commit
f6ad4908bc
@ -586,7 +586,11 @@ bool bar_setup(struct swaybar *bar, const char *socket_path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bar->display = wl_display_connect(NULL);
|
bar->display = wl_display_connect(NULL);
|
||||||
assert(bar->display);
|
if (!bar->display) {
|
||||||
|
sway_abort("Unable to connect to the compositor. "
|
||||||
|
"If your compositor is running, check or set the "
|
||||||
|
"WAYLAND_DISPLAY environment variable.");
|
||||||
|
}
|
||||||
|
|
||||||
struct wl_registry *registry = wl_display_get_registry(bar->display);
|
struct wl_registry *registry = wl_display_get_registry(bar->display);
|
||||||
wl_registry_add_listener(registry, ®istry_listener, bar);
|
wl_registry_add_listener(registry, ®istry_listener, bar);
|
||||||
|
@ -222,7 +222,12 @@ int main(int argc, const char **argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
state.display = wl_display_connect(NULL);
|
state.display = wl_display_connect(NULL);
|
||||||
assert(state.display);
|
if (!state.display) {
|
||||||
|
wlr_log(WLR_ERROR, "Unable to connect to the compositor. "
|
||||||
|
"If your compositor is running, check or set the "
|
||||||
|
"WAYLAND_DISPLAY environment variable.");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
struct wl_registry *registry = wl_display_get_registry(state.display);
|
struct wl_registry *registry = wl_display_get_registry(state.display);
|
||||||
wl_registry_add_listener(registry, ®istry_listener, &state);
|
wl_registry_add_listener(registry, ®istry_listener, &state);
|
||||||
|
@ -388,7 +388,9 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
state.display = wl_display_connect(NULL);
|
state.display = wl_display_connect(NULL);
|
||||||
if (state.display == NULL) {
|
if (state.display == NULL) {
|
||||||
wlr_log(WLR_ERROR, "Failed to create display");
|
wlr_log(WLR_ERROR, "Unable to connect to the compositor. "
|
||||||
|
"If your compositor is running, check or set the "
|
||||||
|
"WAYLAND_DISPLAY environment variable.");
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -908,7 +908,11 @@ int main(int argc, char **argv) {
|
|||||||
wl_list_init(&state.surfaces);
|
wl_list_init(&state.surfaces);
|
||||||
state.xkb.context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
|
state.xkb.context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
|
||||||
state.display = wl_display_connect(NULL);
|
state.display = wl_display_connect(NULL);
|
||||||
assert(state.display);
|
if (!state.display) {
|
||||||
|
sway_abort("Unable to connect to the compositor. "
|
||||||
|
"If your compositor is running, check or set the "
|
||||||
|
"WAYLAND_DISPLAY environment variable.");
|
||||||
|
}
|
||||||
|
|
||||||
struct wl_registry *registry = wl_display_get_registry(state.display);
|
struct wl_registry *registry = wl_display_get_registry(state.display);
|
||||||
wl_registry_add_listener(registry, ®istry_listener, &state);
|
wl_registry_add_listener(registry, ®istry_listener, &state);
|
||||||
|
@ -342,7 +342,11 @@ static const struct wl_registry_listener registry_listener = {
|
|||||||
|
|
||||||
void swaynag_setup(struct swaynag *swaynag) {
|
void swaynag_setup(struct swaynag *swaynag) {
|
||||||
swaynag->display = wl_display_connect(NULL);
|
swaynag->display = wl_display_connect(NULL);
|
||||||
assert(swaynag->display);
|
if (!swaynag->display) {
|
||||||
|
sway_abort("Unable to connect to the compositor. "
|
||||||
|
"If your compositor is running, check or set the "
|
||||||
|
"WAYLAND_DISPLAY environment variable.");
|
||||||
|
}
|
||||||
|
|
||||||
swaynag->scale = 1;
|
swaynag->scale = 1;
|
||||||
wl_list_init(&swaynag->outputs);
|
wl_list_init(&swaynag->outputs);
|
||||||
|
Loading…
Reference in New Issue
Block a user