diff options
-rw-r--r-- | include/sway/tree/root.h | 2 | ||||
-rw-r--r-- | sway/commands/rename.c | 4 | ||||
-rw-r--r-- | sway/tree/root.c | 14 |
3 files changed, 20 insertions, 0 deletions
diff --git a/include/sway/tree/root.h b/include/sway/tree/root.h index 9f6cd3bb..c4f84207 100644 --- a/include/sway/tree/root.h +++ b/include/sway/tree/root.h | |||
@@ -85,4 +85,6 @@ struct sway_container *root_find_container( | |||
85 | 85 | ||
86 | void root_get_box(struct sway_root *root, struct wlr_box *box); | 86 | void root_get_box(struct sway_root *root, struct wlr_box *box); |
87 | 87 | ||
88 | void root_rename_pid_workspaces(const char *old_name, const char *new_name); | ||
89 | |||
88 | #endif | 90 | #endif |
diff --git a/sway/commands/rename.c b/sway/commands/rename.c index 88377b09..3b855fdf 100644 --- a/sway/commands/rename.c +++ b/sway/commands/rename.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include "sway/output.h" | 9 | #include "sway/output.h" |
10 | #include "sway/tree/container.h" | 10 | #include "sway/tree/container.h" |
11 | #include "sway/tree/workspace.h" | 11 | #include "sway/tree/workspace.h" |
12 | #include "sway/tree/root.h" | ||
12 | 13 | ||
13 | static const char expected_syntax[] = | 14 | static const char expected_syntax[] = |
14 | "Expected 'rename workspace <old_name> to <new_name>' or " | 15 | "Expected 'rename workspace <old_name> to <new_name>' or " |
@@ -89,6 +90,9 @@ struct cmd_results *cmd_rename(int argc, char **argv) { | |||
89 | } | 90 | } |
90 | 91 | ||
91 | sway_log(SWAY_DEBUG, "renaming workspace '%s' to '%s'", workspace->name, new_name); | 92 | sway_log(SWAY_DEBUG, "renaming workspace '%s' to '%s'", workspace->name, new_name); |
93 | |||
94 | root_rename_pid_workspaces(workspace->name, new_name); | ||
95 | |||
92 | free(workspace->name); | 96 | free(workspace->name); |
93 | workspace->name = new_name; | 97 | workspace->name = new_name; |
94 | 98 | ||
diff --git a/sway/tree/root.c b/sway/tree/root.c index 0744192b..5dde9f22 100644 --- a/sway/tree/root.c +++ b/sway/tree/root.c | |||
@@ -390,3 +390,17 @@ void root_get_box(struct sway_root *root, struct wlr_box *box) { | |||
390 | box->width = root->width; | 390 | box->width = root->width; |
391 | box->height = root->height; | 391 | box->height = root->height; |
392 | } | 392 | } |
393 | |||
394 | void root_rename_pid_workspaces(const char *old_name, const char *new_name) { | ||
395 | if (!pid_workspaces.prev && !pid_workspaces.next) { | ||
396 | wl_list_init(&pid_workspaces); | ||
397 | } | ||
398 | |||
399 | struct pid_workspace *pw = NULL; | ||
400 | wl_list_for_each(pw, &pid_workspaces, link) { | ||
401 | if (strcmp(pw->workspace, old_name) == 0) { | ||
402 | free(pw->workspace); | ||
403 | pw->workspace = strdup(new_name); | ||
404 | } | ||
405 | } | ||
406 | } | ||