diff options
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 @@ | |||
1 | #define _POSIX_C_SOURCE 200809L | 1 | #define _POSIX_C_SOURCE 200809L |
2 | #include <ctype.h> | ||
2 | #include <stdbool.h> | 3 | #include <stdbool.h> |
4 | #include <stdlib.h> | ||
3 | #include <string.h> | 5 | #include <string.h> |
4 | #include <wlr/types/wlr_output_layout.h> | 6 | #include <wlr/types/wlr_output_layout.h> |
5 | #include "sway/container.h" | 7 | #include "sway/container.h" |
@@ -33,3 +35,38 @@ void add_child(swayc_t *parent, swayc_t *child) { | |||
33 | } | 35 | } |
34 | */ | 36 | */ |
35 | } | 37 | } |
38 | |||
39 | enum swayc_layouts default_layout(swayc_t *output) { | ||
40 | /* TODO WLR | ||
41 | if (config->default_layout != L_NONE) { | ||
42 | //return config->default_layout; | ||
43 | } else if (config->default_orientation != L_NONE) { | ||
44 | return config->default_orientation; | ||
45 | } else */if (output->width >= output->height) { | ||
46 | return L_HORIZ; | ||
47 | } else { | ||
48 | return L_VERT; | ||
49 | } | ||
50 | } | ||
51 | |||
52 | static int sort_workspace_cmp_qsort(const void *_a, const void *_b) { | ||
53 | swayc_t *a = *(void **)_a; | ||
54 | swayc_t *b = *(void **)_b; | ||
55 | int retval = 0; | ||
56 | |||
57 | if (isdigit(a->name[0]) && isdigit(b->name[0])) { | ||
58 | int a_num = strtol(a->name, NULL, 10); | ||
59 | int b_num = strtol(b->name, NULL, 10); | ||
60 | retval = (a_num < b_num) ? -1 : (a_num > b_num); | ||
61 | } else if (isdigit(a->name[0])) { | ||
62 | retval = -1; | ||
63 | } else if (isdigit(b->name[0])) { | ||
64 | retval = 1; | ||
65 | } | ||
66 | |||
67 | return retval; | ||
68 | } | ||
69 | |||
70 | void sort_workspaces(swayc_t *output) { | ||
71 | list_stable_sort(output->children, sort_workspace_cmp_qsort); | ||
72 | } | ||