aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/layout.c
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2017-11-22 20:39:27 -0500
committerLibravatar Drew DeVault <sir@cmpwn.com>2017-11-22 20:39:50 -0500
commitaeda2e077f6184ecd26dc078c7b5db7f0dc54fd7 (patch)
tree0e84fc6ce2409ef5c60210efd18cb0981e3f9cf7 /sway/tree/layout.c
parentMerge pull request #1472 from martinetd/wlroots (diff)
downloadsway-aeda2e077f6184ecd26dc078c7b5db7f0dc54fd7.tar.gz
sway-aeda2e077f6184ecd26dc078c7b5db7f0dc54fd7.tar.zst
sway-aeda2e077f6184ecd26dc078c7b5db7f0dc54fd7.zip
Add workspace to outputs
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 @@
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
39enum 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
52static 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
70void sort_workspaces(swayc_t *output) {
71 list_stable_sort(output->children, sort_workspace_cmp_qsort);
72}