summaryrefslogtreecommitdiffstats
path: root/sway/commands/rename.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands/rename.c')
-rw-r--r--sway/commands/rename.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/sway/commands/rename.c b/sway/commands/rename.c
index 21d2aa64..d982f941 100644
--- a/sway/commands/rename.c
+++ b/sway/commands/rename.c
@@ -25,14 +25,11 @@ struct cmd_results *cmd_rename(int argc, char **argv) {
25 } 25 }
26 26
27 int argn = 1; 27 int argn = 1;
28 struct sway_container *workspace; 28 struct sway_workspace *workspace = NULL;
29 29
30 if (strcasecmp(argv[1], "to") == 0) { 30 if (strcasecmp(argv[1], "to") == 0) {
31 // 'rename workspace to new_name' 31 // 'rename workspace to new_name'
32 workspace = config->handler_context.current_container; 32 workspace = config->handler_context.workspace;
33 if (workspace->type != C_WORKSPACE) {
34 workspace = container_parent(workspace, C_WORKSPACE);
35 }
36 } else if (strcasecmp(argv[1], "number") == 0) { 33 } else if (strcasecmp(argv[1], "number") == 0) {
37 // 'rename workspace number x to new_name' 34 // 'rename workspace number x to new_name'
38 if (!isdigit(argv[2][0])) { 35 if (!isdigit(argv[2][0])) {
@@ -78,7 +75,7 @@ struct cmd_results *cmd_rename(int argc, char **argv) {
78 return cmd_results_new(CMD_INVALID, "rename", 75 return cmd_results_new(CMD_INVALID, "rename",
79 "Cannot use special workspace name '%s'", argv[argn]); 76 "Cannot use special workspace name '%s'", argv[argn]);
80 } 77 }
81 struct sway_container *tmp_workspace = workspace_by_name(new_name); 78 struct sway_workspace *tmp_workspace = workspace_by_name(new_name);
82 if (tmp_workspace) { 79 if (tmp_workspace) {
83 free(new_name); 80 free(new_name);
84 return cmd_results_new(CMD_INVALID, "rename", 81 return cmd_results_new(CMD_INVALID, "rename",
@@ -89,7 +86,7 @@ struct cmd_results *cmd_rename(int argc, char **argv) {
89 free(workspace->name); 86 free(workspace->name);
90 workspace->name = new_name; 87 workspace->name = new_name;
91 88
92 output_sort_workspaces(workspace->parent); 89 output_sort_workspaces(workspace->output);
93 ipc_event_workspace(NULL, workspace, "rename"); 90 ipc_event_workspace(NULL, workspace, "rename");
94 91
95 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 92 return cmd_results_new(CMD_SUCCESS, NULL, NULL);