diff options
author | Drew DeVault <sir@cmpwn.com> | 2017-11-22 20:39:27 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2017-11-22 20:39:50 -0500 |
commit | aeda2e077f6184ecd26dc078c7b5db7f0dc54fd7 (patch) | |
tree | 0e84fc6ce2409ef5c60210efd18cb0981e3f9cf7 /sway/tree/layout.c | |
parent | 68036018c8a19f1ec3536e8111899fe280aad38d (diff) |
Add workspace to outputs
Diffstat (limited to 'sway/tree/layout.c')
-rw-r--r-- | sway/tree/layout.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/sway/tree/layout.c b/sway/tree/layout.c index 06200bbf..5a70c570 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c @@ -1,5 +1,7 @@ #define _POSIX_C_SOURCE 200809L +#include <ctype.h> #include <stdbool.h> +#include <stdlib.h> #include <string.h> #include <wlr/types/wlr_output_layout.h> #include "sway/container.h" @@ -33,3 +35,38 @@ void add_child(swayc_t *parent, swayc_t *child) { } */ } + +enum swayc_layouts default_layout(swayc_t *output) { + /* TODO WLR + if (config->default_layout != L_NONE) { + //return config->default_layout; + } else if (config->default_orientation != L_NONE) { + return config->default_orientation; + } else */if (output->width >= output->height) { + return L_HORIZ; + } else { + return L_VERT; + } +} + +static int sort_workspace_cmp_qsort(const void *_a, const void *_b) { + swayc_t *a = *(void **)_a; + swayc_t *b = *(void **)_b; + int retval = 0; + + if (isdigit(a->name[0]) && isdigit(b->name[0])) { + int a_num = strtol(a->name, NULL, 10); + int b_num = strtol(b->name, NULL, 10); + retval = (a_num < b_num) ? -1 : (a_num > b_num); + } else if (isdigit(a->name[0])) { + retval = -1; + } else if (isdigit(b->name[0])) { + retval = 1; + } + + return retval; +} + +void sort_workspaces(swayc_t *output) { + list_stable_sort(output->children, sort_workspace_cmp_qsort); +} |