aboutsummaryrefslogtreecommitdiff
path: root/sway/tree
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2017-12-12 20:02:01 +0100
committeremersion <contact@emersion.fr>2017-12-12 20:02:01 +0100
commitc7abb77f2217cc4d5642ef1650f7fc75e1c1a9a4 (patch)
tree8118cd69c22ec2545572a8e443080907f087d401 /sway/tree
parentf3d880b0ec9eae246ef0d70dd67bed6d7488ab33 (diff)
Listen to output layout change
Diffstat (limited to 'sway/tree')
-rw-r--r--sway/tree/container.c9
-rw-r--r--sway/tree/layout.c17
2 files changed, 16 insertions, 10 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c
index e4c27d61..f70bccdc 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -26,13 +26,6 @@ void swayc_descendants_of_type(swayc_t *root, enum swayc_types type,
}
}
-static void update_root_geometry() {
- struct wlr_box *box =
- wlr_output_layout_get_box(root_container.output_layout, NULL);
- root_container.width = box->width;
- root_container.height = box->height;
-}
-
static swayc_t *new_swayc(enum swayc_types type) {
// next id starts at 1 because 0 is assigned to root_container in layout.c
static size_t next_id = 1;
@@ -94,7 +87,6 @@ swayc_t *new_output(struct sway_output *sway_output) {
sway_log(L_DEBUG, "Creating default workspace %s", ws_name);
new_workspace(output, ws_name);
free(ws_name);
- update_root_geometry();
return output;
}
@@ -195,7 +187,6 @@ swayc_t *destroy_output(swayc_t *output) {
sway_log(L_DEBUG, "OUTPUT: Destroying output '%s'", output->name);
free_swayc(output);
- update_root_geometry();
return &root_container;
}
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 <wlr/types/wlr_output.h>
#include <wlr/types/wlr_output_layout.h>
#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) {