From 19c0ec6a08fd8462bc2060b657277250452eb2ba Mon Sep 17 00:00:00 2001
From: Drew DeVault <sir@cmpwn.com>
Date: Sun, 16 Aug 2015 14:47:08 -0400
Subject: [PATCH] Fix movement between outputs

---
 sway/layout.c   | 3 +++
 sway/movement.c | 4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/sway/layout.c b/sway/layout.c
index 918da9f0..20b5999c 100644
--- a/sway/layout.c
+++ b/sway/layout.c
@@ -244,6 +244,9 @@ void focus_view(swayc_t *view) {
 	}
 	while (view && view->type != C_VIEW) {
 		view = view->focused;
+		if (view && view->type == C_OUTPUT) {
+			wlc_output_focus(view->handle);
+		}
 	}
 	if (view) {
 		wlc_view_set_state(view->handle, WLC_BIT_ACTIVATED, true);
diff --git a/sway/movement.c b/sway/movement.c
index de987679..12726392 100644
--- a/sway/movement.c
+++ b/sway/movement.c
@@ -28,7 +28,7 @@ bool move_focus(enum movement_direction direction) {
 		bool can_move = false;
 		int diff = 0;
 		if (direction == MOVE_LEFT || direction == MOVE_RIGHT) {
-			if (parent->layout == L_HORIZ) {
+			if (parent->layout == L_HORIZ || parent->type == C_ROOT) {
 				can_move = true;
 				diff = direction == MOVE_LEFT ? -1 : 1;
 			}
@@ -61,7 +61,7 @@ bool move_focus(enum movement_direction direction) {
 			sway_log(L_DEBUG, "Can't move at current level, moving up tree");
 			current = parent;
 			parent = parent->parent;
-			if (parent->type == C_ROOT) {
+			if (!parent) {
 				// Nothing we can do
 				return false;
 			}