Rewrite con_swap to work only with queue operations

Benefits are that we don't open a fake container and don't call many
complicated functions that can lead to redraws (x_push_changes calls) as
discussed in #2954.

Fixes #2810:
Windows exchange floating mode & window rects.
Swap will still not work with CT_FLOATING_CONs but this doesn't make
much sense.

Fixes #3280:
The behaviour is not very user friendly but swap behaves exactly as it
should. The rest is a tree_flatten issue. Attached pictures in #2954.
This commit is contained in:
Orestis Floros
2017-09-06 05:44:09 +03:00
parent dfe89cc4f1
commit 8e1687a317
4 changed files with 324 additions and 131 deletions

View File

@ -176,6 +176,45 @@ cmd '[id=' . $windows[2]->id . '] move to workspace ' . $ws;
cmd '[id=' . $windows[1]->id . '] move to workspace ' . $ws;
confirm_focus('\'move to workspace\' focus order when moving containers from other workspace');
######################################################################
# Swapping sibling containers correctly swaps focus order.
######################################################################
sub swap_with_ids {
my ($idx1, $idx2) = @_;
cmd '[id=' . $windows[$idx1]->id . '] swap container with id ' . $windows[$idx2]->id;
}
$ws = fresh_workspace;
$windows[2] = open_window;
$windows[0] = open_window;
$windows[3] = open_window;
$windows[1] = open_window;
# If one of the swapees is focused we deliberately preserve its focus, switch
# workspaces to move focus away from the windows.
fresh_workspace;
# 2 0 3 1 <- focus order in this direction
swap_with_ids(3, 1);
# 2 0 1 3
swap_with_ids(2, 3);
# 3 0 1 2
swap_with_ids(0, 2);
# 3 2 1 0
# Restore input focus for confirm_focus
cmd "workspace $ws";
# Also confirm swap worked
$ws = get_ws($ws);
for my $i (0 .. 3) {
my $node = $ws->{nodes}->[3 - $i];
is($node->{window}, $windows[$i]->id, "window $i in correct position after swap");
}
confirm_focus('\'swap container with id\' focus order');
######################################################################
# Test focus order with floating and tiling windows.
# See issue: 1975