diff options
author | Zandr Martin <[email protected]> | 2016-05-27 17:37:56 -0500 |
---|---|---|
committer | Zandr Martin <[email protected]> | 2016-05-27 17:37:56 -0500 |
commit | c6c3a8e7586c0fe14fba2fcd3fc856765169250e (patch) | |
tree | 46446abe682a7a163c9f28da77e75e5c7360621a /sway/container.c | |
parent | 907283d23094d406ffafca77c75569b2d9de9aaa (diff) |
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.c | 21 |
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 @@ #include "input_state.h" #include "log.h" #include "ipc-server.h" +#include "output.h" #define ASSERT_NONNULL(PTR) \ sway_assert (PTR, #PTR "must be non-null") @@ -180,24 +181,9 @@ swayc_t *new_workspace(swayc_t *output, const char *name) { workspace->visible = false; workspace->floating = create_list(); - if (isdigit(workspace->name[0])) { - // find position for numbered workspace - // order: ascending numbers, insert before same number - // numbers before unnumbered - int num = strtol(workspace->name, NULL, 10); - int i; - for (i = 0; i < output->children->length; ++i) { - char *name = ((swayc_t *)output->children->items[i])->name; - if (!isdigit(name[0]) || num <= strtol(name, NULL, 10)) { - break; - } - } - insert_child(output, workspace, i); + add_child(output, workspace); + sort_workspaces(output); - } else { - // append new unnumbered to the end - add_child(output, workspace); - } return workspace; } @@ -353,6 +339,7 @@ swayc_t *destroy_output(swayc_t *output) { remove_child(child); add_child(root_container.children->items[p], child); } + sort_workspaces(root_container.children->items[p]); update_visibility(root_container.children->items[p]); arrange_windows(root_container.children->items[p], -1, -1); } |