From 34a5bbb7e9779a7576fdd1e41dd677248c23749d Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sun, 14 Oct 2012 20:56:13 +0200 Subject: [PATCH] exit with a proper error message when there are no outputs available (Thanks flo) fixes #842 --- src/randr.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/randr.c b/src/randr.c index a73a94c9..267d6e41 100644 --- a/src/randr.c +++ b/src/randr.c @@ -69,7 +69,7 @@ Output *get_first_output(void) { if (output->active) return output; - return NULL; + die("No usable outputs available.\n"); } /* @@ -647,8 +647,7 @@ void randr_query_outputs(void) { output->active = false; DLOG("Output %s disabled, re-assigning workspaces/docks\n", output->name); - if ((first = get_first_output()) == NULL) - die("No usable outputs available\n"); + first = get_first_output(); /* TODO: refactor the following code into a nice function. maybe * use an on_destroy callback which is implement differently for @@ -736,6 +735,9 @@ void randr_query_outputs(void) { disable_randr(conn); } + /* Verifies that there is at least one active output as a side-effect. */ + get_first_output(); + /* Just go through each active output and assign one workspace */ TAILQ_FOREACH(output, &outputs, outputs) { if (!output->active)