diff options
Diffstat (limited to 'sway/container.c')
-rw-r--r-- | sway/container.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/sway/container.c b/sway/container.c index 8165bbad..36056ff7 100644 --- a/sway/container.c +++ b/sway/container.c | |||
@@ -1,3 +1,4 @@ | |||
1 | #include <ctype.h> | ||
1 | #include <stdlib.h> | 2 | #include <stdlib.h> |
2 | #include <stdbool.h> | 3 | #include <stdbool.h> |
3 | #include <strings.h> | 4 | #include <strings.h> |
@@ -168,7 +169,24 @@ swayc_t *new_workspace(swayc_t *output, const char *name) { | |||
168 | workspace->visible = false; | 169 | workspace->visible = false; |
169 | workspace->floating = create_list(); | 170 | workspace->floating = create_list(); |
170 | 171 | ||
171 | add_child(output, workspace); | 172 | if (isdigit(workspace->name[0])) { |
173 | // find position for numbered workspace | ||
174 | // order: ascending numbers, insert before same number | ||
175 | // numbers before unnumbered | ||
176 | int num = strtol(workspace->name, NULL, 10); | ||
177 | int i; | ||
178 | for (i = 0; i < output->children->length; ++i) { | ||
179 | char *name = ((swayc_t *)output->children->items[i])->name; | ||
180 | if (!isdigit(name[0]) || num <= strtol(name, NULL, 10)) { | ||
181 | break; | ||
182 | } | ||
183 | } | ||
184 | insert_child(output, workspace, i); | ||
185 | |||
186 | } else { | ||
187 | // append new unnumbered to the end | ||
188 | add_child(output, workspace); | ||
189 | } | ||
172 | return workspace; | 190 | return workspace; |
173 | } | 191 | } |
174 | 192 | ||