aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/workspace.c
diff options
context:
space:
mode:
authorLibravatar minus <minus@mnus.de>2018-08-12 14:41:41 +0200
committerLibravatar minus <minus@mnus.de>2018-08-12 14:41:41 +0200
commit18e425eda63dfa274b5e4f0e773de56a3d44e569 (patch)
tree5441e8f44eef05608f59f454981951caccd96f40 /sway/tree/workspace.c
parentMerge pull request #2452 from janza/position-command-fix-args (diff)
downloadsway-18e425eda63dfa274b5e4f0e773de56a3d44e569.tar.gz
sway-18e425eda63dfa274b5e4f0e773de56a3d44e569.tar.zst
sway-18e425eda63dfa274b5e4f0e773de56a3d44e569.zip
Use assigned workspace name for output
Instead of relying on bindings being configured, primarily source new workspace names from workspace-output assignments. Fixes #2435
Diffstat (limited to 'sway/tree/workspace.c')
-rw-r--r--sway/tree/workspace.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c
index b8bec044..0177068b 100644
--- a/sway/tree/workspace.c
+++ b/sway/tree/workspace.c
@@ -120,6 +120,8 @@ static void workspace_name_from_binding(const struct sway_binding * binding,
120 name = argsep(&cmdlist, ",;"); 120 name = argsep(&cmdlist, ",;");
121 } 121 }
122 122
123 // TODO: support "move container to workspace" bindings as well
124
123 if (strcmp("workspace", cmd) == 0 && name) { 125 if (strcmp("workspace", cmd) == 0 && name) {
124 char *_target = strdup(name); 126 char *_target = strdup(name);
125 _target = do_var_replacement(_target); 127 _target = do_var_replacement(_target);
@@ -189,8 +191,8 @@ static void workspace_name_from_binding(const struct sway_binding * binding,
189char *workspace_next_name(const char *output_name) { 191char *workspace_next_name(const char *output_name) {
190 wlr_log(WLR_DEBUG, "Workspace: Generating new workspace name for output %s", 192 wlr_log(WLR_DEBUG, "Workspace: Generating new workspace name for output %s",
191 output_name); 193 output_name);
192 // Scan all workspace bindings to find the next available workspace name, 194 // Scan for available workspace names by looking through output-workspace
193 // if none are found/available then default to a number 195 // assignments primarily, falling back to bindings and numbers.
194 struct sway_mode *mode = config->current_mode; 196 struct sway_mode *mode = config->current_mode;
195 197
196 int order = INT_MAX; 198 int order = INT_MAX;
@@ -203,6 +205,15 @@ char *workspace_next_name(const char *output_name) {
203 workspace_name_from_binding(mode->keycode_bindings->items[i], 205 workspace_name_from_binding(mode->keycode_bindings->items[i],
204 output_name, &order, &target); 206 output_name, &order, &target);
205 } 207 }
208 for (int i = 0; i < config->workspace_outputs->length; ++i) {
209 // Unlike with bindings, this does not guarantee order
210 const struct workspace_output *wso = config->workspace_outputs->items[i];
211 if (strcmp(wso->output, output_name) == 0
212 && workspace_by_name(wso->workspace) == NULL) {
213 free(target);
214 target = strdup(wso->workspace);
215 }
216 }
206 if (target != NULL) { 217 if (target != NULL) {
207 return target; 218 return target;
208 } 219 }