From bcc1314a2d43e0889a5f5bad5b02119cfb9f44a4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ingo=20B=C3=BCrk?= Date: Wed, 4 Mar 2015 09:06:44 +0100 Subject: [PATCH] When renaming a workspace, look for assignments and move the renamed workspace to the appropriate output. --- src/commands.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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); -- 2.39.5