Add --no-auto-back-and-forth for moving windows.

This patch extends the previously introduced flag --no-auto-back-and-forth
to also apply to

    move window to workspace <name>
    move window to workspace number <number>

relates to #2028
This commit is contained in:
Ingo Bürk
2015-10-26 22:38:06 +01:00
parent d187214562
commit 57a7ff301f
6 changed files with 75 additions and 28 deletions

View File

@ -44,7 +44,7 @@ sub parser_calls {
# The first call has only a single command, the following ones are consolidated
# for performance.
is(parser_calls('move workspace 3'),
'cmd_move_con_to_workspace_name(3)',
'cmd_move_con_to_workspace_name(3, (null))',
'single number (move workspace 3) ok');
is(parser_calls(
@ -57,19 +57,19 @@ is(parser_calls(
'move workspace 3: foobar; ' .
'move workspace "3: foobar"; ' .
'move workspace "3: foobar, baz"; '),
"cmd_move_con_to_workspace_name(3)\n" .
"cmd_move_con_to_workspace_name(3)\n" .
"cmd_move_con_to_workspace_name(3)\n" .
"cmd_move_con_to_workspace_name(foobar)\n" .
"cmd_move_con_to_workspace_name(torrent)\n" .
"cmd_move_con_to_workspace_name(3, (null))\n" .
"cmd_move_con_to_workspace_name(3, (null))\n" .
"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_workspace_name(3: foobar)\n" .
"cmd_move_con_to_workspace_name(3: foobar)\n" .
"cmd_move_con_to_workspace_name(3: foobar, baz)",
"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))",
'move ok');
is(parser_calls('move workspace 3: foobar, nop foo'),
"cmd_move_con_to_workspace_name(3: foobar)\n" .
"cmd_move_con_to_workspace_name(3: foobar, (null))\n" .
"cmd_nop(foo)",
'multiple ops (move workspace 3: foobar, nop foo) ok');
@ -177,7 +177,7 @@ is(parser_calls('unknown_literal'),
'error for unknown literal ok');
is(parser_calls('move something to somewhere'),
"ERROR: Expected one of these tokens: 'window', 'container', 'to', 'workspace', 'output', 'mark', 'scratchpad', 'left', 'right', 'up', 'down', 'position', 'absolute'\n" .
"ERROR: Expected one of these tokens: 'window', 'container', 'to', '--no-auto-back-and-forth', 'workspace', 'output', 'mark', 'scratchpad', 'left', 'right', 'up', 'down', 'position', 'absolute'\n" .
"ERROR: Your command: move something to somewhere\n" .
"ERROR: ^^^^^^^^^^^^^^^^^^^^^^",
'error for unknown literal ok');

View File

@ -18,7 +18,7 @@
# Ticket: #2028
use i3test;
my ($first, $second, $third);
my ($first, $second, $third, $con);
$first = "1:first";
$second = "2:second";
$third = "3:third";
@ -52,6 +52,47 @@ ok(get_ws($first)->{focused}, 'first workspace is still focused');
cmd qq|workspace --no-auto-back-and-forth number "$first"|;
ok(get_ws($first)->{focused}, 'first workspace is still focused');
###############################################################################
# Moving a window to another workspace when passing --no-auto-back-and-forth
# works as if the flag wasn't set.
###############################################################################
cmd qq|workspace "$third"|;
cmd qq|workspace "$second"|;
cmd qq|workspace "$first"|;
$con = open_window;
cmd 'mark mywindow';
cmd qq|move --no-auto-back-and-forth window to workspace "$second"|;
is(@{get_ws($second)->{nodes}}, 1, 'window was moved to second workspace');
cmd qq|[con_mark=mywindow] move window to workspace "$first"|;
cmd qq|move --no-auto-back-and-forth window to workspace number "$third"|;
is(@{get_ws($third)->{nodes}}, 1, 'window was moved to third workspace');
cmd qq|[con_mark=mywindow] move window to workspace "$first"|;
cmd '[con_mark=mywindow] kill';
###############################################################################
# Moving a window to the same workspace when passing --no-auto-back-and-forth
# is a no-op.
###############################################################################
cmd qq|workspace "$second"|;
cmd qq|workspace "$first"|;
$con = open_window;
cmd 'mark mywindow';
cmd qq|move --no-auto-back-and-forth window to workspace "$first"|;
is(@{get_ws($first)->{nodes}}, 1, 'window is still on first workspace');
cmd qq|[con_mark=mywindow] move window to workspace "$first"|;
cmd qq|move --no-auto-back-and-forth window to workspace number "$first"|;
is(@{get_ws($first)->{nodes}}, 1, 'window is still on first workspace');
cmd qq|[con_mark=mywindow] move window to workspace "$first"|;
cmd '[con_mark=mywindow] kill';
###############################################################################
done_testing;