aboutsummaryrefslogtreecommitdiffstats
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, 36 insertions, 1 deletions
diff --git a/sway/tree/layout.c b/sway/tree/layout.c
index cb39a361..4bcf0e2f 100644
--- a/sway/tree/layout.c
+++ b/sway/tree/layout.c
@@ -7,6 +7,7 @@
7#include <wlr/types/wlr_output.h> 7#include <wlr/types/wlr_output.h>
8#include <wlr/types/wlr_output_layout.h> 8#include <wlr/types/wlr_output_layout.h>
9#include "sway/container.h" 9#include "sway/container.h"
10#include "sway/layout.h"
10#include "sway/output.h" 11#include "sway/output.h"
11#include "sway/view.h" 12#include "sway/view.h"
12#include "list.h" 13#include "list.h"
@@ -14,13 +15,47 @@
14 15
15swayc_t root_container; 16swayc_t root_container;
16 17
18static void output_layout_change_notify(struct wl_listener *listener, void *data) {
19 struct wlr_box *layout_box = wlr_output_layout_get_box(
20 root_container.sway_root->output_layout, NULL);
21 root_container.width = layout_box->width;
22 root_container.height = layout_box->height;
23
24 for (int i = 0 ; i < root_container.children->length; ++i) {
25 swayc_t *output_container = root_container.children->items[i];
26 if (output_container->type != C_OUTPUT) {
27 continue;
28 }
29 struct sway_output *output = output_container->sway_output;
30
31 struct wlr_box *output_box = wlr_output_layout_get_box(
32 root_container.sway_root->output_layout, output->wlr_output);
33 if (!output_box) {
34 continue;
35 }
36 output_container->x = output_box->x;
37 output_container->y = output_box->y;
38 output_container->width = output_box->width;
39 output_container->height = output_box->height;
40 }
41
42 arrange_windows(&root_container, -1, -1);
43}
44
17void init_layout(void) { 45void init_layout(void) {
18 root_container.id = 0; // normally assigned in new_swayc() 46 root_container.id = 0; // normally assigned in new_swayc()
19 root_container.type = C_ROOT; 47 root_container.type = C_ROOT;
20 root_container.layout = L_NONE; 48 root_container.layout = L_NONE;
21 root_container.name = strdup("root"); 49 root_container.name = strdup("root");
22 root_container.children = create_list(); 50 root_container.children = create_list();
23 root_container.output_layout = wlr_output_layout_create(); 51
52 root_container.sway_root = calloc(1, sizeof(*root_container.sway_root));
53 root_container.sway_root->output_layout = wlr_output_layout_create();
54
55 root_container.sway_root->output_layout_change.notify =
56 output_layout_change_notify;
57 wl_signal_add(&root_container.sway_root->output_layout->events.change,
58 &root_container.sway_root->output_layout_change);
24} 59}
25 60
26void add_child(swayc_t *parent, swayc_t *child) { 61void add_child(swayc_t *parent, swayc_t *child) {