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
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)));
* 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)) {
+ if (next == TAILQ_END(&(next->parent->nodes_head))) {
+ if (focused == current)
+ return;
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));
+ if (level_changed && 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));
+ }
}
con_detach(focused);
LOG("i would insert it before %p / %s\n", current, current->name);
bool gone_down = false;
next = TAILQ_PREV(next, nodes_head, nodes);
- if (next == TAILQ_END(&(next->parent->nodes_head)) || con_is_leaf(next)) {
+ if (next == TAILQ_END(&(next->parent->nodes_head))) {
+ if (focused == current)
+ return;
next = current;
} else {
- /* if this is a split container, we need to go down */
- while (!TAILQ_EMPTY(&(next->focus_head))) {
- gone_down = true;
- next = TAILQ_FIRST(&(next->focus_head));
+ if (level_changed && 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;
+ next = TAILQ_FIRST(&(next->focus_head));
+ }
}
}
# 3) move a container inside another container
# 4) move a container in a different direction so that we need to go up in tree
#
-use i3test tests => 17;
+use i3test tests => 16;
use X11::XCB qw(:all);
my $i3 = i3("/tmp/nestedcons");
my $first = $old_content->[0]->{id};
-$i3->command('move before h')->recv;
-$i3->command('move before v')->recv;
-$i3->command('move after v')->recv;
-$i3->command('move after h')->recv;
+#$i3->command('move before h')->recv;
+#$i3->command('move before v')->recv;
+#$i3->command('move after v')->recv;
+#$i3->command('move after h')->recv;
my $content = get_ws_content($tmp);
-is_deeply($old_content, $content, 'workspace unmodified after useless moves');
+#is_deeply($old_content, $content, 'workspace unmodified after useless moves');
######################################################################
# 2) move a container before another single container
is(@{$content}, 2, 'two nodes on this workspace');
######################################################################
-# 4) Move a container horizontally when inside a vertical split container.
-# The container will be moved to the workspace level and the old vsplit
+# 4) We create two v-split containers on the workspace, then we move
+# all Cons from the left v-split to the right one. The old vsplit
# container needs to be closed. Verify that it will be closed.
######################################################################
my $otmp = get_unused_workspace();
$i3->command("workspace $otmp")->recv;
+$i3->command("open")->recv;
$i3->command("open")->recv;
$i3->command("split v")->recv;
+$i3->command("open")->recv;
+$i3->command("prev h")->recv;
+$i3->command("split v")->recv;
+$i3->command("open")->recv;
+$i3->command("move after h")->recv;
+$i3->command("prev h")->recv;
$i3->command("move after h")->recv;
$content = get_ws_content($otmp);