From b88f06e70a62722e70855772dcfa5b20b3a10291 Mon Sep 17 00:00:00 2001
From: Tony Crisci <tony@dubstepdish.com>
Date: Mon, 19 Feb 2018 17:55:16 -0500
Subject: [PATCH] bugfix: get right layout box for rendering views

---
 sway/desktop/output.c | 2 +-
 sway/tree/layout.c    | 5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index a3d9efd8..039aba25 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -51,7 +51,7 @@ static void render_surface(struct wlr_surface *surface,
 
 	// FIXME: view coords are inconsistently assumed to be in output or layout coords
 	struct wlr_box layout_box = {
-		.x = lx + owidth, .y = ly + oheight,
+		.x = lx + wlr_output->lx, .y = ly + wlr_output->ly,
 		.width = render_width, .height = render_height,
 	};
 	if (wlr_output_layout_intersects(layout, wlr_output, &layout_box)) {
diff --git a/sway/tree/layout.c b/sway/tree/layout.c
index be494791..3c78b6bc 100644
--- a/sway/tree/layout.c
+++ b/sway/tree/layout.c
@@ -531,7 +531,10 @@ static swayc_t *get_swayc_in_direction_under(swayc_t *container,
 				return wrap_candidate;
 			}
 			swayc_t *next = get_swayc_in_output_direction(adjacent, dir, seat);
-			if (next->children->length) {
+			if (next == NULL) {
+				return NULL;
+			}
+			if (next->children && next->children->length) {
 				// TODO consider floating children as well
 				return sway_seat_get_focus_inactive(seat, next);
 			} else {