diff options
author | Drew DeVault <[email protected]> | 2017-12-13 20:36:06 -0500 |
---|---|---|
committer | GitHub <[email protected]> | 2017-12-13 20:36:06 -0500 |
commit | 1aab9ae3e74d15e2c346acbab2ef2def59db72eb (patch) | |
tree | 6a3479fef295dc673c6bcdaac822f44523f94d8e /sway/tree/layout.c | |
parent | ab36a5a4d73ddb026c9b1d416c1e7388d63958ea (diff) | |
parent | cba592b3d2c516cab9f4e8325037dfdf6e30cb9a (diff) |
Merge pull request #1503 from emersion/output-config
Add output config
Diffstat (limited to 'sway/tree/layout.c')
-rw-r--r-- | sway/tree/layout.c | 37 |
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 @@ #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,47 @@ swayc_t root_container; +static void output_layout_change_notify(struct wl_listener *listener, void *data) { + struct wlr_box *layout_box = wlr_output_layout_get_box( + root_container.sway_root->output_layout, NULL); + root_container.width = layout_box->width; + root_container.height = layout_box->height; + + for (int i = 0 ; i < root_container.children->length; ++i) { + swayc_t *output_container = root_container.children->items[i]; + if (output_container->type != C_OUTPUT) { + continue; + } + struct sway_output *output = output_container->sway_output; + + struct wlr_box *output_box = wlr_output_layout_get_box( + root_container.sway_root->output_layout, output->wlr_output); + if (!output_box) { + continue; + } + output_container->x = output_box->x; + output_container->y = output_box->y; + output_container->width = output_box->width; + output_container->height = output_box->height; + } + + arrange_windows(&root_container, -1, -1); +} + 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) { |