aboutsummaryrefslogtreecommitdiff
path: root/swaynag
diff options
context:
space:
mode:
authorLuke Drummond <ldrumm@rtps.co>2020-06-10 01:13:21 +0100
committerSimon Ser <contact@emersion.fr>2020-06-10 15:50:31 +0200
commit62a530513c9fee1509536b19bcb76cd243621f27 (patch)
tree093a82a479cd314e2cd648177851964a54948176 /swaynag
parented08f2f20cc533716001829398bdad8f0e98049b (diff)
swaynag: sway_abort on failure to properly register
In case `wl_display_roundtrip` returns an error after registering for events, print a more user-friendly error message and exit. Previously, if the build did not have assertions enabled, this would likely result in a segfault. With assertions enabled, it's not user friendly to terminate with internal implementation information.
Diffstat (limited to 'swaynag')
-rw-r--r--swaynag/swaynag.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/swaynag/swaynag.c b/swaynag/swaynag.c
index 6c326ca8..d9bec368 100644
--- a/swaynag/swaynag.c
+++ b/swaynag/swaynag.c
@@ -445,7 +445,10 @@ void swaynag_setup(struct swaynag *swaynag) {
struct wl_registry *registry = wl_display_get_registry(swaynag->display);
wl_registry_add_listener(registry, &registry_listener, swaynag);
- wl_display_roundtrip(swaynag->display);
+ if (wl_display_roundtrip(swaynag->display) < 0) {
+ sway_abort("failed to register with the wayland display");
+ }
+
assert(swaynag->compositor && swaynag->layer_shell && swaynag->shm);
while (swaynag->querying_outputs > 0) {