mirror of
https://github.com/swaywm/sway.git
synced 2024-11-04 23:43:14 +00:00
Allow for workspace renaming during exec handling
This change adds support for renaming a workspace when `exec` command is being processed by keeping sway_workspace and pid_workspace names in sync. The change can be verified by running following command: swaymsg exec <application>; swaymsg rename workspace number 1 to 5 Fixes: #3952
This commit is contained in:
parent
cd8b4ace92
commit
200833caae
|
@ -85,4 +85,6 @@ struct sway_container *root_find_container(
|
||||||
|
|
||||||
void root_get_box(struct sway_root *root, struct wlr_box *box);
|
void root_get_box(struct sway_root *root, struct wlr_box *box);
|
||||||
|
|
||||||
|
void root_rename_pid_workspaces(const char *old_name, const char *new_name);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "sway/output.h"
|
#include "sway/output.h"
|
||||||
#include "sway/tree/container.h"
|
#include "sway/tree/container.h"
|
||||||
#include "sway/tree/workspace.h"
|
#include "sway/tree/workspace.h"
|
||||||
|
#include "sway/tree/root.h"
|
||||||
|
|
||||||
static const char expected_syntax[] =
|
static const char expected_syntax[] =
|
||||||
"Expected 'rename workspace <old_name> to <new_name>' or "
|
"Expected 'rename workspace <old_name> to <new_name>' or "
|
||||||
|
@ -89,6 +90,9 @@ struct cmd_results *cmd_rename(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
sway_log(SWAY_DEBUG, "renaming workspace '%s' to '%s'", workspace->name, new_name);
|
sway_log(SWAY_DEBUG, "renaming workspace '%s' to '%s'", workspace->name, new_name);
|
||||||
|
|
||||||
|
root_rename_pid_workspaces(workspace->name, new_name);
|
||||||
|
|
||||||
free(workspace->name);
|
free(workspace->name);
|
||||||
workspace->name = new_name;
|
workspace->name = new_name;
|
||||||
|
|
||||||
|
|
|
@ -390,3 +390,17 @@ void root_get_box(struct sway_root *root, struct wlr_box *box) {
|
||||||
box->width = root->width;
|
box->width = root->width;
|
||||||
box->height = root->height;
|
box->height = root->height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void root_rename_pid_workspaces(const char *old_name, const char *new_name) {
|
||||||
|
if (!pid_workspaces.prev && !pid_workspaces.next) {
|
||||||
|
wl_list_init(&pid_workspaces);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct pid_workspace *pw = NULL;
|
||||||
|
wl_list_for_each(pw, &pid_workspaces, link) {
|
||||||
|
if (strcmp(pw->workspace, old_name) == 0) {
|
||||||
|
free(pw->workspace);
|
||||||
|
pw->workspace = strdup(new_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue