From 45a2fad0dead2e00a41eedd3b524aacd29f00335 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Thu, 19 Apr 2018 12:53:02 +1000 Subject: [PATCH] container_get_in_direction(): Don't split this function --- sway/tree/layout.c | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/sway/tree/layout.c b/sway/tree/layout.c index 96d0c567..7ffc2484 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c @@ -883,7 +883,7 @@ static struct sway_container *sway_output_from_wlr(struct wlr_output *output) { return NULL; } -static struct sway_container *container_get_in_direction_naive( +struct sway_container *container_get_in_direction( struct sway_container *container, struct sway_seat *seat, enum movement_direction dir) { struct sway_container *parent = container->parent; @@ -936,6 +936,14 @@ static struct sway_container *container_get_in_direction_naive( if (next == NULL) { return NULL; } + struct sway_container *next_workspace = next; + if (next_workspace->type != C_WORKSPACE) { + next_workspace = container_parent(next_workspace, C_WORKSPACE); + } + sway_assert(next_workspace, "Next container has no workspace"); + if (next_workspace->sway_workspace->fullscreen) { + return next_workspace->sway_workspace->fullscreen->swayc; + } if (next->children && next->children->length) { // TODO consider floating children as well return seat_get_focus_inactive_view(seat, next); @@ -992,28 +1000,6 @@ static struct sway_container *container_get_in_direction_naive( } } -struct sway_container *container_get_in_direction( - struct sway_container *container, struct sway_seat *seat, - enum movement_direction dir) { - struct sway_container *result = container_get_in_direction_naive(container, - seat, dir); - if (!result) { - return NULL; - } - struct sway_container *old_workspace = container; - if (old_workspace->type != C_WORKSPACE) { - old_workspace = container_parent(old_workspace, C_WORKSPACE); - } - struct sway_container *new_workspace = result; - if (new_workspace->type != C_WORKSPACE) { - new_workspace = container_parent(new_workspace, C_WORKSPACE); - } - if (old_workspace != new_workspace && new_workspace->sway_workspace->fullscreen) { - result = new_workspace->sway_workspace->fullscreen->swayc; - } - return result; -} - struct sway_container *container_replace_child(struct sway_container *child, struct sway_container *new_child) { struct sway_container *parent = child->parent;