]> git.sur5r.net Git - i3/i3/commitdiff
look & feel: when moving, descend if the container in target direction is a split...
authorMichael Stapelberg <michael@stapelberg.de>
Sun, 28 Nov 2010 17:35:11 +0000 (18:35 +0100)
committerMichael Stapelberg <michael@stapelberg.de>
Sun, 28 Nov 2010 17:35:11 +0000 (18:35 +0100)
src/tree.c

index 71d46362c146fc94a32d68721c0e1071916930f4..57a2db1acb88e9918ccc21042fe12771264678f9 100644 (file)
@@ -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;