Add a new command 'move to workspace current'

Added a new command 'move to workspace current' which can be used
with criteria to move a window to the current workspace.
next
Pavel Löbl 2012-05-09 23:45:12 +02:00 committed by Michael Stapelberg
parent 51173baf28
commit 2afecaf355
4 changed files with 43 additions and 5 deletions

View File

@ -1293,8 +1293,9 @@ You can also switch to the next and previous workspace with the commands
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
container to workspace next+ and +move container to workspace prev+ to move a
container to the next/previous workspace.
container to workspace next+, +move container to workspace prev+ to move a
container to the next/previous workspace and +move container to workspace current+
(the last one makes sense only when used with criteria).
[[back_and_forth]]
To switch back to the previously focused workspace, use +workspace
@ -1310,6 +1311,18 @@ you can use the +move workspace to output+ command followed by the name of the
target output. You may also use +left+, +right+, +up+, +down+ instead of the
xrandr output name to move to the next output in the specified direction.
*Syntax*:
-----------------------------------
workspace <next|prev|next_on_output|prev_on_output>
workspace back_and_forth
workspace <name>
workspace number <number>
move [window|container] [to] workspace <name>
move [window|container] [to] workspace number <number>
move [window|container] [to] workspace <prev|next|current>
-----------------------------------
*Examples*:
-------------------------
bindsym mod+1 workspace 1
@ -1325,6 +1338,9 @@ bindsym mod+b workspace back_and_forth
# move the whole workspace to the next output
bindsym mod+x move workspace to output right
# move firefox to current workspace
bindsym mod+F1 [class="Firefox"] move workspace current
-------------------------
==== Named workspaces

View File

@ -190,7 +190,7 @@ state RENAME_WORKSPACE_TO:
-> call cmd_rename_workspace($old_name, $new_name)
# move <direction> [<pixels> [px]]
# move [window|container] [to] workspace <str>
# move [window|container] [to] workspace [<str>|next|prev|current]
# move [window|container] [to] output <str>
# move [window|container] [to] scratchpad
# move workspace to [output] <str>
@ -231,7 +231,7 @@ state MOVE_DIRECTION_PX:
state MOVE_WORKSPACE:
'to'
-> MOVE_WORKSPACE_TO_OUTPUT
workspace = 'next', 'prev', 'next_on_output', 'prev_on_output'
workspace = 'next', 'prev', 'next_on_output', 'prev_on_output', 'current'
-> call cmd_move_con_to_workspace($workspace)
'number'
-> MOVE_WORKSPACE_NUMBER

View File

@ -351,7 +351,7 @@ void cmd_criteria_add(I3_CMD, char *ctype, char *cvalue) {
/*
* Implementation of 'move [window|container] [to] workspace
* next|prev|next_on_output|prev_on_output'.
* next|prev|next_on_output|prev_on_output|current'.
*
*/
void cmd_move_con_to_workspace(I3_CMD, char *which) {
@ -380,6 +380,8 @@ void cmd_move_con_to_workspace(I3_CMD, char *which) {
ws = workspace_next_on_output();
else if (strcmp(which, "prev_on_output") == 0)
ws = workspace_prev_on_output();
else if (strcmp(which, "current") == 0)
ws = con_get_workspace(focused);
else {
ELOG("BUG: called with which=%s\n", which);
ysuccess(false);

View File

@ -99,6 +99,26 @@ cmd 'move workspace prev';
ok(@{get_ws_content($tmp)} == 3, 'three containers on first ws');
ok(@{get_ws_content($tmp2)} == 0, 'no containers on second ws');
###################################################################
# check if 'move workspace current' works
###################################################################
$tmp = get_unused_workspace();
$tmp2 = get_unused_workspace();
cmd "workspace $tmp";
$first = open_window(name => 'win-name');
ok(@{get_ws_content($tmp)} == 1, 'one container on first ws');
cmd "workspace $tmp2";
ok(@{get_ws_content($tmp2)} == 0, 'no containers yet');
cmd qq|[title="win-name"] move workspace $tmp2|;
ok(@{get_ws_content($tmp2)} == 1, 'one container on second ws');
cmd qq|[title="win-name"] move workspace $tmp|;
ok(@{get_ws_content($tmp2)} == 0, 'no containers on second ws');
###################################################################
# check if floating cons are moved to new workspaces properly
# (that is, if they are floating on the target ws, too)