From: Ingo Bürk Date: Wed, 4 Mar 2015 08:06:44 +0000 (+0100) Subject: When renaming a workspace, look for assignments and move the renamed workspace to... X-Git-Tag: 4.10.1~68^2~2 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=bcc1314a2d43e0889a5f5bad5b02119cfb9f44a4;p=i3%2Fi3 When renaming a workspace, look for assignments and move the renamed workspace to the appropriate output. --- diff --git a/src/commands.c b/src/commands.c index 498c25c8..7d3c9e6e 100644 --- a/src/commands.c +++ b/src/commands.c @@ -2034,6 +2034,24 @@ void cmd_rename_workspace(I3_CMD, char *old_name, char *new_name) { Con *parent = workspace->parent; con_detach(workspace); con_attach(workspace, parent, false); + + /* Move the workspace to the correct output if it has an assignment */ + struct Workspace_Assignment *assignment = NULL; + TAILQ_FOREACH(assignment, &ws_assignments, ws_assignments) { + if (assignment->output == NULL) + continue; + if (strcmp(assignment->name, workspace->name) != 0 + && (!name_is_digits(assignment->name) || ws_name_to_number(assignment->name) != workspace->num)) { + + continue; + } + + /* Focus this workspace for now, we will restore the previous focus anyway. */ + con_focus(workspace); + cmd_move_workspace_to_output(current_match, cmd_output, assignment->output); + break; + } + /* Restore the previous focus since con_attach messes with the focus. */ con_focus(previously_focused);