From 18a7afa1b34bb1c37df1547ff6e1dc0c4e2a88b8 Mon Sep 17 00:00:00 2001
From: "S. Christoffer Eliesen" <christoffer@eliesen.no>
Date: Fri, 18 Dec 2015 03:33:42 +0100
Subject: [PATCH] focus: Fix moving last workspace.

If there's only one workspace on an output and it's moved to a different
output then active workspace will be NULL.
---
 sway/focus.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sway/focus.c b/sway/focus.c
index c60f410c..c1170ca4 100644
--- a/sway/focus.c
+++ b/sway/focus.c
@@ -96,7 +96,10 @@ bool set_focused_container(swayc_t *c) {
 		return false;
 	}
 	swayc_t *active_ws = swayc_active_workspace();
-	int active_ws_child_count = active_ws->children->length + active_ws->floating->length;
+	int active_ws_child_count = 0;
+	if (active_ws) {
+		active_ws_child_count = active_ws->children->length + active_ws->floating->length;
+	}
 
 	swayc_log(L_DEBUG, c, "Setting focus to %p:%ld", c, c->handle);