diff options
-rw-r--r-- | sway/tree/workspace.c | 15 |
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, | |||
189 | char *workspace_next_name(const char *output_name) { | 191 | char *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 | } |