From 780b0ddbbc5c9ec3db51737e21b316d72341f91e Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sun, 28 Nov 2010 18:35:11 +0100 Subject: [PATCH] look & feel: when moving, descend if the container in target direction is a split-container --- src/tree.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/src/tree.c b/src/tree.c index 71d46362..57a2db1a 100644 --- a/src/tree.c +++ b/src/tree.c @@ -394,7 +394,6 @@ void tree_move(char way, orientation_t orientation) { Con *old_parent = parent; if (focused->type == CT_WORKSPACE) return; - bool level_changed = false; while (con_orientation(parent) != orientation) { DLOG("need to go one level further up\n"); /* If the current parent is an output, we are at a workspace @@ -433,12 +432,9 @@ void tree_move(char way, orientation_t orientation) { if (old_focused) con_focus(old_focused); - level_changed = true; - break; } parent = parent->parent; - level_changed = true; } Con *current = TAILQ_FIRST(&(parent->focus_head)); assert(current != TAILQ_END(&(parent->focus_head))); @@ -447,13 +443,14 @@ void tree_move(char way, orientation_t orientation) { Con *next = current; if (way == 'n') { LOG("i would insert it after %p / %s\n", next, next->name); - if (!level_changed) { - next = TAILQ_NEXT(next, nodes); - if (next == TAILQ_END(&(next->parent->nodes_head))) { - LOG("cannot move further to the right\n"); - return; - } + /* Have a look at the next container: If there is no next container or + * if it is a leaf node, we move the focused one left to it. However, + * for split containers, we descend into it. */ + next = TAILQ_NEXT(next, nodes); + if (next == TAILQ_END(&(next->parent->nodes_head)) || con_is_leaf(next)) { + next = current; + } else { /* if this is a split container, we need to go down */ while (!TAILQ_EMPTY(&(next->focus_head))) next = TAILQ_FIRST(&(next->focus_head)); @@ -468,13 +465,10 @@ void tree_move(char way, orientation_t orientation) { } else { LOG("i would insert it before %p / %s\n", current, current->name); bool gone_down = false; - if (!level_changed) { - next = TAILQ_PREV(next, nodes_head, nodes); - if (next == TAILQ_END(&(next->parent->nodes_head))) { - LOG("cannot move further\n"); - return; - } - + next = TAILQ_PREV(next, nodes_head, nodes); + if (next == TAILQ_END(&(next->parent->nodes_head)) || con_is_leaf(next)) { + next = current; + } else { /* if this is a split container, we need to go down */ while (!TAILQ_EMPTY(&(next->focus_head))) { gone_down = true;