aboutsummaryrefslogtreecommitdiff
path: root/sway/tree/layout.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/tree/layout.c')
-rw-r--r--sway/tree/layout.c37
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);
+}