Introduce get_existing_workspace_by_name

This commit is contained in:
Orestis Floros
2018-03-27 22:18:17 +03:00
parent 45be56be33
commit 6a2728ba79
5 changed files with 32 additions and 38 deletions

View File

@ -1955,11 +1955,9 @@ void cmd_rename_workspace(I3_CMD, const char *old_name, const char *new_name) {
LOG("Renaming current workspace to \"%s\"\n", new_name);
}
Con *output, *workspace = NULL;
Con *workspace;
if (old_name) {
TAILQ_FOREACH(output, &(croot->nodes_head), nodes)
GREP_FIRST(workspace, output_get_content(output),
!strcasecmp(child->name, old_name));
workspace = get_existing_workspace_by_name(old_name);
} else {
workspace = con_get_workspace(focused);
old_name = workspace->name;
@ -1970,10 +1968,7 @@ void cmd_rename_workspace(I3_CMD, const char *old_name, const char *new_name) {
return;
}
Con *check_dest = NULL;
TAILQ_FOREACH(output, &(croot->nodes_head), nodes)
GREP_FIRST(check_dest, output_get_content(output),
!strcasecmp(child->name, new_name));
Con *check_dest = get_existing_workspace_by_name(new_name);
/* If check_dest == workspace, the user might be changing the case of the
* workspace, or it might just be a no-op. */