Accept multiple outputs in move container|workspace to output

Fixes #4337
This commit is contained in:
Orestis Floros
2021-02-03 18:33:12 +01:00
parent f2243a7a90
commit 8ff8db3c36
8 changed files with 234 additions and 58 deletions

View File

@ -54,6 +54,7 @@ is(parser_calls(
'move workspace foobar; ' .
'move workspace torrent; ' .
'move workspace to output LVDS1; ' .
'move to output LVDS1 DVI1; ' .
'move workspace 3: foobar; ' .
'move workspace "3: foobar"; ' .
'move workspace "3: foobar, baz"; '),
@ -62,7 +63,11 @@ is(parser_calls(
"cmd_move_con_to_workspace_name(3, (null))\n" .
"cmd_move_con_to_workspace_name(foobar, (null))\n" .
"cmd_move_con_to_workspace_name(torrent, (null))\n" .
"cmd_move_workspace_to_output(LVDS1)\n" .
"cmd_move_con_to_output(LVDS1, 1)\n" .
"cmd_move_con_to_output(NULL, 1)\n" .
"cmd_move_con_to_output(LVDS1, 0)\n" .
"cmd_move_con_to_output(DVI1, 0)\n" .
"cmd_move_con_to_output(NULL, 0)\n" .
"cmd_move_con_to_workspace_name(3: foobar, (null))\n" .
"cmd_move_con_to_workspace_name(3: foobar, (null))\n" .
"cmd_move_con_to_workspace_name(3: foobar, baz, (null))",

View File

@ -41,4 +41,12 @@ is_num_children($ws_top_right, 1, 'one container on the upper right workspace');
is_num_children($ws_bottom_left, 0, 'no containers on the lower left workspace');
is_num_children($ws_bottom_right, 1, 'one container on the lower right workspace');
# Also test with multiple explicit outputs
cmd '[class="moveme"] move window to output fake-1 fake-2';
is_num_children($ws_top_left, 0, 'no containers on the upper left workspace');
is_num_children($ws_top_right, 1, 'one container on the upper right workspace');
is_num_children($ws_bottom_left, 1, 'one container on the lower left workspace');
is_num_children($ws_bottom_right, 0, 'no containers on the lower right workspace');
done_testing;

View File

@ -0,0 +1,93 @@
#!perl
# vim:ts=4:sw=4:expandtab
#
# Please read the following documents before working on tests:
# • https://build.i3wm.org/docs/testsuite.html
# (or docs/testsuite)
#
# • https://build.i3wm.org/docs/lib-i3test.html
# (alternatively: perldoc ./testcases/lib/i3test.pm)
#
# • https://build.i3wm.org/docs/ipc.html
# (or docs/ipc)
#
# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
# (unless you are already familiar with Perl)
#
# Test using multiple workspaces for 'move workspace to output …'
# Ticket: #4337
use i3test i3_config => <<EOT;
# i3 config file (v4)
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
fake-outputs 1024x768+0+0,1024x768+1024+0,1024x768+0+768,1024x768+1024+768
EOT
# Test setup: 4 outputs 2 marked windows
open_window;
cmd 'mark aa, move to workspace 1, workspace 1';
open_window;
cmd 'mark ab, move to workspace 3';
sub is_ws {
my $ws_num = shift;
my $out_num = shift;
my $msg = shift;
local $Test::Builder::Level = $Test::Builder::Level + 1;
is(get_output_for_workspace("$ws_num"), "fake-$out_num", "Workspace $ws_num -> $out_num: $msg");
}
###############################################################################
# Test using "next" special keyword
###############################################################################
is_ws(1, 0, 'sanity check');
is_ws(3, 2, 'sanity check');
for (my $i = 1; $i < 9; $i++) {
cmd '[con_mark=a] move workspace to output next';
my $out1 = $i % 4;
my $out3 = ($i + 2) % 4;
is_ws(1, $out1, 'move workspace to next');
is_ws(3, $out3, 'move workspace to next');
}
###############################################################################
# Same as above but explicitely type all the outputs
###############################################################################
is_ws(1, 0, 'sanity check');
is_ws(3, 2, 'sanity check');
for (my $i = 1; $i < 10; $i++) {
cmd '[con_mark=a] move workspace to output fake-0 fake-1 fake-2 fake-3';
my $out1 = $i % 4;
my $out3 = ($i + 2) % 4;
is_ws(1, $out1, 'cycle through explicit outputs');
is_ws(3, $out3, 'cycle through explicit outputs');
}
###############################################################################
# Use a subset of the outputs plus some non-existing outputs
###############################################################################
cmd '[con_mark=aa] move workspace to output fake-1';
cmd '[con_mark=ab] move workspace to output fake-1';
is_ws(1, 1, 'start from fake-1 which is not included in output list');
is_ws(3, 1, 'start from fake-1 which is not included in output list');
my @order = (0, 3, 2);
for (my $i = 0; $i < 10; $i++) {
cmd '[con_mark=a] move workspace to output doesnotexist fake-0 alsodoesnotexist fake-3 fake-2';
my $out = $order[$i % 3];
is_ws(1, $out, 'cycle through shuffled outputs');
is_ws(3, $out, 'cycle through shuffled outputs');
}
done_testing;