summaryrefslogtreecommitdiffstats
path: root/sway/container.c
diff options
context:
space:
mode:
authorLibravatar Zandr Martin <zandrmartin+git@gmail.com>2016-05-27 17:37:56 -0500
committerLibravatar Zandr Martin <zandrmartin+git@gmail.com>2016-05-27 17:37:56 -0500
commitc6c3a8e7586c0fe14fba2fcd3fc856765169250e (patch)
tree46446abe682a7a163c9f28da77e75e5c7360621a /sway/container.c
parentMerge pull request #673 from zandrmartin/swaylock-no-unlock-indicator (diff)
downloadsway-c6c3a8e7586c0fe14fba2fcd3fc856765169250e.tar.gz
sway-c6c3a8e7586c0fe14fba2fcd3fc856765169250e.tar.zst
sway-c6c3a8e7586c0fe14fba2fcd3fc856765169250e.zip
Implement sort_workspaces() function for outputs.
This seems to have resolved issue #669 for me.
Diffstat (limited to 'sway/container.c')
-rw-r--r--sway/container.c21
1 files changed, 4 insertions, 17 deletions
diff --git a/sway/container.c b/sway/container.c
index b49b32ee..20b7905b 100644
--- a/sway/container.c
+++ b/sway/container.c
@@ -13,6 +13,7 @@
13#include "input_state.h" 13#include "input_state.h"
14#include "log.h" 14#include "log.h"
15#include "ipc-server.h" 15#include "ipc-server.h"
16#include "output.h"
16 17
17#define ASSERT_NONNULL(PTR) \ 18#define ASSERT_NONNULL(PTR) \
18 sway_assert (PTR, #PTR "must be non-null") 19 sway_assert (PTR, #PTR "must be non-null")
@@ -180,24 +181,9 @@ swayc_t *new_workspace(swayc_t *output, const char *name) {
180 workspace->visible = false; 181 workspace->visible = false;
181 workspace->floating = create_list(); 182 workspace->floating = create_list();
182 183
183 if (isdigit(workspace->name[0])) { 184 add_child(output, workspace);
184 // find position for numbered workspace 185 sort_workspaces(output);
185 // order: ascending numbers, insert before same number
186 // numbers before unnumbered
187 int num = strtol(workspace->name, NULL, 10);
188 int i;
189 for (i = 0; i < output->children->length; ++i) {
190 char *name = ((swayc_t *)output->children->items[i])->name;
191 if (!isdigit(name[0]) || num <= strtol(name, NULL, 10)) {
192 break;
193 }
194 }
195 insert_child(output, workspace, i);
196 186
197 } else {
198 // append new unnumbered to the end
199 add_child(output, workspace);
200 }
201 return workspace; 187 return workspace;
202} 188}
203 189
@@ -353,6 +339,7 @@ swayc_t *destroy_output(swayc_t *output) {
353 remove_child(child); 339 remove_child(child);
354 add_child(root_container.children->items[p], child); 340 add_child(root_container.children->items[p], child);
355 } 341 }
342 sort_workspaces(root_container.children->items[p]);
356 update_visibility(root_container.children->items[p]); 343 update_visibility(root_container.children->items[p]);
357 arrange_windows(root_container.children->items[p], -1, -1); 344 arrange_windows(root_container.children->items[p], -1, -1);
358 } 345 }