From: Pavel Löbl Date: Wed, 9 May 2012 21:45:12 +0000 (+0200) Subject: Add a new command 'move to workspace current' X-Git-Tag: 4.3~213 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=2afecaf35532c19f5d51440942c66572b8ab5653;p=i3%2Fi3 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. --- diff --git a/docs/userguide b/docs/userguide index 41452793..37ddf4f8 100644 --- a/docs/userguide +++ b/docs/userguide @@ -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 +workspace back_and_forth +workspace +workspace number + +move [window|container] [to] workspace +move [window|container] [to] workspace number +move [window|container] [to] workspace +----------------------------------- + *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 diff --git a/parser-specs/commands.spec b/parser-specs/commands.spec index 684fd23e..100e5f4e 100644 --- a/parser-specs/commands.spec +++ b/parser-specs/commands.spec @@ -190,7 +190,7 @@ state RENAME_WORKSPACE_TO: -> call cmd_rename_workspace($old_name, $new_name) # move [ [px]] -# move [window|container] [to] workspace +# move [window|container] [to] workspace [|next|prev|current] # move [window|container] [to] output # move [window|container] [to] scratchpad # move workspace to [output] @@ -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 diff --git a/src/commands.c b/src/commands.c index 17d700c4..6f0d0c5e 100644 --- a/src/commands.c +++ b/src/commands.c @@ -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); diff --git a/testcases/t/132-move-workspace.t b/testcases/t/132-move-workspace.t index 3f00428c..79753cd7 100644 --- a/testcases/t/132-move-workspace.t +++ b/testcases/t/132-move-workspace.t @@ -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)