From c7abb77f2217cc4d5642ef1650f7fc75e1c1a9a4 Mon Sep 17 00:00:00 2001 From: emersion Date: Tue, 12 Dec 2017 20:02:01 +0100 Subject: Listen to output layout change --- sway/tree/layout.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'sway/tree/layout.c') diff --git a/sway/tree/layout.c b/sway/tree/layout.c index cb39a361..fd17f8a5 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c @@ -7,6 +7,7 @@ #include #include #include "sway/container.h" +#include "sway/layout.h" #include "sway/output.h" #include "sway/view.h" #include "list.h" @@ -14,13 +15,27 @@ swayc_t root_container; +static void output_layout_change_notify(struct wl_listener *listener, void *data) { + struct wlr_box *box = wlr_output_layout_get_box( + root_container.sway_root->output_layout, NULL); + root_container.width = box->width; + root_container.height = box->height; +} + void init_layout(void) { root_container.id = 0; // normally assigned in new_swayc() root_container.type = C_ROOT; root_container.layout = L_NONE; root_container.name = strdup("root"); root_container.children = create_list(); - root_container.output_layout = wlr_output_layout_create(); + + root_container.sway_root = calloc(1, sizeof(*root_container.sway_root)); + root_container.sway_root->output_layout = wlr_output_layout_create(); + + root_container.sway_root->output_layout_change.notify = + output_layout_change_notify; + wl_signal_add(&root_container.sway_root->output_layout->events.change, + &root_container.sway_root->output_layout_change); } void add_child(swayc_t *parent, swayc_t *child) { -- cgit v1.2.3-70-g09d2