Introduce synonyms: 'move to workspace' and 'move container to workspace' and 'move window to workspace'
This makes the new 'move workspace to output' command much more clear
This commit is contained in:
parent
9c11ef4b23
commit
df9b338175
@ -1055,9 +1055,9 @@ specific workspace and immediately switch to that workspace, you can configure
|
||||
the following keybinding:
|
||||
|
||||
*Example*:
|
||||
-------------------------------------------
|
||||
bindsym mod+x move workspace 3; workspace 3
|
||||
-------------------------------------------
|
||||
--------------------------------------------------------
|
||||
bindsym mod+x move container to workspace 3; workspace 3
|
||||
--------------------------------------------------------
|
||||
|
||||
[[command_criteria]]
|
||||
|
||||
@ -1241,15 +1241,15 @@ bindsym mod+j move left 20 px
|
||||
|
||||
To change to a specific workspace, use the +workspace+ command, followed by the
|
||||
number or name of the workspace. To move containers to specific workspaces, use
|
||||
+move workspace+.
|
||||
+move container to workspace+.
|
||||
|
||||
You can also switch to the next and previous workspace with the commands
|
||||
+workspace next+ and +workspace prev+, which is handy, for example, if you have
|
||||
workspace 1, 3, 4 and 9 and you want to cycle through them with a single key
|
||||
combination. To restrict those to the current output, use +workspace
|
||||
next_on_output+ and +workspace prev_on_output+. Similarly, you can use +move
|
||||
workspace next+ and +move workspace prev+ to move a container to the
|
||||
next/previous workspace.
|
||||
container to workspace next+ and +move container to workspace prev+ to move a
|
||||
container to the next/previous workspace.
|
||||
|
||||
[[back_and_forth]]
|
||||
To switch back to the previously focused workspace, use +workspace
|
||||
@ -1266,8 +1266,8 @@ bindsym mod+1 workspace 1
|
||||
bindsym mod+2 workspace 2
|
||||
...
|
||||
|
||||
bindsym mod+Shift+1 move workspace 1
|
||||
bindsym mod+Shift+2 move workspace 2
|
||||
bindsym mod+Shift+1 move container to workspace 1
|
||||
bindsym mod+Shift+2 move container to workspace 2
|
||||
...
|
||||
|
||||
# switch between the current and the previously focused one
|
||||
|
@ -316,10 +316,10 @@ sub convert_command {
|
||||
if ($command =~ /^m[0-9]+/) {
|
||||
my ($number) = ($command =~ /^m([0-9]+)/);
|
||||
if (exists $workspace_names{$number}) {
|
||||
print qq|$statement $key move workspace $workspace_names{$number}\n|;
|
||||
print qq|$statement $key move container to workspace $workspace_names{$number}\n|;
|
||||
return;
|
||||
} else {
|
||||
print qq|$statement $key move workspace $number\n|;
|
||||
print qq|$statement $key move container to workspace $number\n|;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
20
i3.config
20
i3.config
@ -87,16 +87,16 @@ bindsym Mod1+9 workspace 9
|
||||
bindsym Mod1+0 workspace 10
|
||||
|
||||
# move focused container to workspace
|
||||
bindsym Mod1+Shift+1 move workspace 1
|
||||
bindsym Mod1+Shift+2 move workspace 2
|
||||
bindsym Mod1+Shift+3 move workspace 3
|
||||
bindsym Mod1+Shift+4 move workspace 4
|
||||
bindsym Mod1+Shift+5 move workspace 5
|
||||
bindsym Mod1+Shift+6 move workspace 6
|
||||
bindsym Mod1+Shift+7 move workspace 7
|
||||
bindsym Mod1+Shift+8 move workspace 8
|
||||
bindsym Mod1+Shift+9 move workspace 9
|
||||
bindsym Mod1+Shift+0 move workspace 10
|
||||
bindsym Mod1+Shift+1 move container to workspace 1
|
||||
bindsym Mod1+Shift+2 move container to workspace 2
|
||||
bindsym Mod1+Shift+3 move container to workspace 3
|
||||
bindsym Mod1+Shift+4 move container to workspace 4
|
||||
bindsym Mod1+Shift+5 move container to workspace 5
|
||||
bindsym Mod1+Shift+6 move container to workspace 6
|
||||
bindsym Mod1+Shift+7 move container to workspace 7
|
||||
bindsym Mod1+Shift+8 move container to workspace 8
|
||||
bindsym Mod1+Shift+9 move container to workspace 9
|
||||
bindsym Mod1+Shift+0 move container to workspace 10
|
||||
|
||||
# reload the configuration file
|
||||
bindsym Mod1+Shift+c reload
|
||||
|
@ -88,16 +88,16 @@ bindcode $mod+18 workspace 9
|
||||
bindcode $mod+19 workspace 10
|
||||
|
||||
# move focused container to workspace
|
||||
bindcode $mod+Shift+10 move workspace 1
|
||||
bindcode $mod+Shift+11 move workspace 2
|
||||
bindcode $mod+Shift+12 move workspace 3
|
||||
bindcode $mod+Shift+13 move workspace 4
|
||||
bindcode $mod+Shift+14 move workspace 5
|
||||
bindcode $mod+Shift+15 move workspace 6
|
||||
bindcode $mod+Shift+16 move workspace 7
|
||||
bindcode $mod+Shift+17 move workspace 8
|
||||
bindcode $mod+Shift+18 move workspace 9
|
||||
bindcode $mod+Shift+19 move workspace 10
|
||||
bindcode $mod+Shift+10 move container to workspace 1
|
||||
bindcode $mod+Shift+11 move container to workspace 2
|
||||
bindcode $mod+Shift+12 move container to workspace 3
|
||||
bindcode $mod+Shift+13 move container to workspace 4
|
||||
bindcode $mod+Shift+14 move container to workspace 5
|
||||
bindcode $mod+Shift+15 move container to workspace 6
|
||||
bindcode $mod+Shift+16 move container to workspace 7
|
||||
bindcode $mod+Shift+17 move container to workspace 8
|
||||
bindcode $mod+Shift+18 move container to workspace 9
|
||||
bindcode $mod+Shift+19 move container to workspace 10
|
||||
|
||||
# reload the configuration file
|
||||
bindcode $mod+Shift+54 reload
|
||||
|
@ -48,6 +48,9 @@ EOL (\r?\n)
|
||||
/* handle a quoted string or everything up to the next whitespace */
|
||||
%s WANT_QSTRING
|
||||
|
||||
%x MOVE
|
||||
%x MOVE_WS
|
||||
|
||||
%x EXEC
|
||||
|
||||
%x BUFFER_LINE
|
||||
@ -74,14 +77,38 @@ EOL (\r?\n)
|
||||
cmdyycolumn = 1;
|
||||
}
|
||||
|
||||
/* the next/prev/back_and_forth tokens are here to recognize them *before*
|
||||
* handling strings ('workspace' command) */
|
||||
/* The next/prev/back_and_forth tokens are here to recognize them *before*
|
||||
* handling strings ('workspace' command). While flex uses the longest
|
||||
* match, in case of a tie the order of rules becomes relevant. Since the
|
||||
* input is fully consumed (these are the last tokens), it comes to a tie.
|
||||
* */
|
||||
next { BEGIN(INITIAL); return TOK_NEXT; }
|
||||
prev { BEGIN(INITIAL); return TOK_PREV; }
|
||||
next_on_output { BEGIN(INITIAL); return TOK_NEXT_ON_OUTPUT; }
|
||||
prev_on_output { BEGIN(INITIAL); return TOK_PREV_ON_OUTPUT; }
|
||||
back_and_forth { BEGIN(INITIAL); return TOK_BACK_AND_FORTH; }
|
||||
|
||||
/* MOVE is the state after a 'move' token was processed. We need this state
|
||||
* to skip some tokens (for making the commands clearer) and to properly
|
||||
* move to the MOVE_WS state. */
|
||||
<MOVE>to { /* eat this token */ }
|
||||
<MOVE>window { /* eat this token */ }
|
||||
<MOVE>container { /* eat this token */ }
|
||||
<MOVE>workspace { yy_pop_state(); yy_push_state(MOVE_WS); yy_push_state(EAT_WHITESPACE); return TOK_WORKSPACE; }
|
||||
<MOVE>scratchpad { yy_pop_state(); return TOK_SCRATCHPAD; }
|
||||
<MOVE>up { yy_pop_state(); return TOK_UP; }
|
||||
<MOVE>down { yy_pop_state(); return TOK_DOWN; }
|
||||
<MOVE>left { yy_pop_state(); return TOK_LEFT; }
|
||||
<MOVE>right { yy_pop_state(); return TOK_RIGHT; }
|
||||
|
||||
/* MOVE_WS is the state after a 'workspace' token was processed in the MOVE
|
||||
* state. We need a separate state to deal with the fact that the old
|
||||
* 'move workspace <ws>' command needs to be supported (the new command is
|
||||
* 'move to workspace') while we also need to support
|
||||
* 'move workspace to output <output>'. */
|
||||
<MOVE_WS>to { yy_pop_state(); return TOK_TO; }
|
||||
<MOVE_WS>[^to] { yy_pop_state(); yy_push_state(WANT_STRING); yyless(0); }
|
||||
|
||||
<WANT_STRING>\"[^\"]+\" {
|
||||
BEGIN(INITIAL);
|
||||
/* strip quotes */
|
||||
@ -113,6 +140,7 @@ reload { return TOK_RELOAD; }
|
||||
restart { return TOK_RESTART; }
|
||||
kill { return TOK_KILL; }
|
||||
window { return TOK_WINDOW; }
|
||||
container { return TOK_CONTAINER; }
|
||||
client { return TOK_CLIENT; }
|
||||
fullscreen { return TOK_FULLSCREEN; }
|
||||
global { return TOK_GLOBAL; }
|
||||
@ -133,7 +161,7 @@ mode_toggle { return TOK_MODE_TOGGLE; }
|
||||
workspace { WS_STRING; return TOK_WORKSPACE; }
|
||||
output { WS_STRING; return TOK_OUTPUT; }
|
||||
focus { return TOK_FOCUS; }
|
||||
move { return TOK_MOVE; }
|
||||
move { yy_push_state(MOVE); return TOK_MOVE; }
|
||||
open { return TOK_OPEN; }
|
||||
scratchpad { return TOK_SCRATCHPAD; }
|
||||
show { return TOK_SHOW; }
|
||||
@ -152,6 +180,7 @@ grow { return TOK_GROW; }
|
||||
px { return TOK_PX; }
|
||||
or { return TOK_OR; }
|
||||
ppt { return TOK_PPT; }
|
||||
to { return TOK_TO; }
|
||||
nop { WS_STRING; return TOK_NOP; }
|
||||
append_layout { WS_STRING; return TOK_APPEND_LAYOUT; }
|
||||
mark { WS_STRING; return TOK_MARK; }
|
||||
|
@ -130,6 +130,7 @@ bool definitelyGreaterThan(float a, float b, float epsilon) {
|
||||
%token TOK_RESTART "restart"
|
||||
%token TOK_KILL "kill"
|
||||
%token TOK_WINDOW "window"
|
||||
%token TOK_CONTAINER "container"
|
||||
%token TOK_CLIENT "client"
|
||||
%token TOK_FULLSCREEN "fullscreen"
|
||||
%token TOK_GLOBAL "global"
|
||||
@ -179,6 +180,7 @@ bool definitelyGreaterThan(float a, float b, float epsilon) {
|
||||
%token TOK_NOP "nop"
|
||||
%token TOK_BACK_AND_FORTH "back_and_forth"
|
||||
%token TOK_NO_STARTUP_ID "--no-startup-id"
|
||||
%token TOK_TO "to"
|
||||
|
||||
%token TOK_CLASS "class"
|
||||
%token TOK_INSTANCE "instance"
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!perl
|
||||
# vim:ts=4:sw=4:expandtab
|
||||
#
|
||||
# Checks if the 'move workspace' command works correctly
|
||||
# Checks if the 'move [window/container] to workspace' command works correctly
|
||||
#
|
||||
use i3test;
|
||||
|
||||
@ -11,30 +11,40 @@ my $i3 = i3(get_socket_path());
|
||||
# be set to the window under the cursor
|
||||
$x->root->warp_pointer(0, 0);
|
||||
|
||||
my $tmp = get_unused_workspace();
|
||||
my $tmp2 = get_unused_workspace();
|
||||
cmd "workspace $tmp";
|
||||
sub move_workspace_test {
|
||||
my ($movecmd) = @_;
|
||||
|
||||
ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
|
||||
my $tmp = get_unused_workspace();
|
||||
my $tmp2 = get_unused_workspace();
|
||||
cmd "workspace $tmp";
|
||||
|
||||
my $first = open_empty_con($i3);
|
||||
my $second = open_empty_con($i3);
|
||||
ok(@{get_ws_content($tmp)} == 2, 'two containers on first ws');
|
||||
ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
|
||||
|
||||
cmd "workspace $tmp2";
|
||||
ok(@{get_ws_content($tmp2)} == 0, 'no containers on second ws yet');
|
||||
my $first = open_empty_con($i3);
|
||||
my $second = open_empty_con($i3);
|
||||
ok(@{get_ws_content($tmp)} == 2, 'two containers on first ws');
|
||||
|
||||
cmd "workspace $tmp";
|
||||
cmd "workspace $tmp2";
|
||||
ok(@{get_ws_content($tmp2)} == 0, 'no containers on second ws yet');
|
||||
|
||||
cmd "move workspace $tmp2";
|
||||
ok(@{get_ws_content($tmp)} == 1, 'one container on first ws anymore');
|
||||
ok(@{get_ws_content($tmp2)} == 1, 'one container on second ws');
|
||||
my ($nodes, $focus) = get_ws_content($tmp2);
|
||||
cmd "workspace $tmp";
|
||||
|
||||
is($focus->[0], $second, 'same container on different ws');
|
||||
cmd "$movecmd $tmp2";
|
||||
ok(@{get_ws_content($tmp)} == 1, 'one container on first ws anymore');
|
||||
ok(@{get_ws_content($tmp2)} == 1, 'one container on second ws');
|
||||
my ($nodes, $focus) = get_ws_content($tmp2);
|
||||
|
||||
($nodes, $focus) = get_ws_content($tmp);
|
||||
ok($nodes->[0]->{focused}, 'first container focused on first ws');
|
||||
is($focus->[0], $second, 'same container on different ws');
|
||||
|
||||
($nodes, $focus) = get_ws_content($tmp);
|
||||
ok($nodes->[0]->{focused}, 'first container focused on first ws');
|
||||
}
|
||||
|
||||
move_workspace_test('move workspace'); # supported for legacy reasons
|
||||
move_workspace_test('move to workspace');
|
||||
# Those are just synonyms and more verbose ways of saying the same thing:
|
||||
move_workspace_test('move window to workspace');
|
||||
move_workspace_test('move container to workspace');
|
||||
|
||||
###################################################################
|
||||
# check if 'move workspace next' and 'move workspace prev' work
|
||||
@ -43,12 +53,12 @@ ok($nodes->[0]->{focused}, 'first container focused on first ws');
|
||||
# Open two containers on the first workspace, one container on the second
|
||||
# workspace. Because the workspaces are named, they will be sorted by order of
|
||||
# creation.
|
||||
$tmp = get_unused_workspace();
|
||||
$tmp2 = get_unused_workspace();
|
||||
my $tmp = get_unused_workspace();
|
||||
my $tmp2 = get_unused_workspace();
|
||||
cmd "workspace $tmp";
|
||||
ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
|
||||
$first = open_empty_con($i3);
|
||||
$second = open_empty_con($i3);
|
||||
my $first = open_empty_con($i3);
|
||||
my $second = open_empty_con($i3);
|
||||
ok(@{get_ws_content($tmp)} == 2, 'two containers on first ws');
|
||||
|
||||
cmd "workspace $tmp2";
|
||||
|
@ -315,7 +315,7 @@ $output = migrate_config('bindsym Mod1+3 3');
|
||||
ok(line_exists($output, qr|^bindsym Mod1\+3 workspace 3|), 'workspace changed');
|
||||
|
||||
$output = migrate_config('bindsym Mod1+3 m3');
|
||||
ok(line_exists($output, qr|^bindsym Mod1\+3 move workspace 3|), 'move workspace changed');
|
||||
ok(line_exists($output, qr|^bindsym Mod1\+3 move container to workspace 3|), 'move workspace changed');
|
||||
|
||||
$input = <<EOT;
|
||||
workspace 3 work
|
||||
@ -323,7 +323,7 @@ $input = <<EOT;
|
||||
EOT
|
||||
$output = migrate_config($input);
|
||||
ok(!line_exists($output, qr|^workspace|), 'workspace name not present');
|
||||
ok(line_exists($output, qr|^bindsym Mod1\+3 move workspace work|), 'move to named workspace in bindings');
|
||||
ok(line_exists($output, qr|^bindsym Mod1\+3 move container to workspace work|), 'move to named workspace in bindings');
|
||||
|
||||
#####################################################################
|
||||
# check whether an i3bar call is added if the workspace bar bar was enabled
|
||||
|
Loading…
Reference in New Issue
Block a user