diff options
author | Drew DeVault <[email protected]> | 2016-05-28 11:08:57 -0400 |
---|---|---|
committer | Drew DeVault <[email protected]> | 2016-05-28 11:08:57 -0400 |
commit | a0315dc849aacd6e20cf57cb0cbb9ea1d91dce79 (patch) | |
tree | d43477a8ead345a7ca3d2f40c4335ec44352ec65 /sway/container.c | |
parent | 907283d23094d406ffafca77c75569b2d9de9aaa (diff) | |
parent | 7df38ce9dade4708fb658bab88eb5eb4824d3556 (diff) |
Merge pull request #675 from zandrmartin/add-workspace-sorting
Implement sort_workspaces() function for outputs.
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); } |