From eac0920f49a728ad6a3809528c4757b73e4cd8af Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sat, 22 Aug 2015 14:44:47 -0400 Subject: [PATCH] Set x/y positions for output containers --- sway/container.c | 19 ++++++++++++++++++- sway/layout.c | 9 ++------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/sway/container.c b/sway/container.c index 5d5449348..41d21c3b2 100644 --- a/sway/container.c +++ b/sway/container.c @@ -59,7 +59,7 @@ swayc_t *new_output(wlc_handle handle) { const char *name = wlc_output_get_name(handle); sway_log(L_DEBUG, "Added output %lu:%s", handle, name); - struct output_config *oc ; + struct output_config *oc = NULL; int i; for (i = 0; i < config->output_configs->length; ++i) { oc = config->output_configs->items[i]; @@ -83,6 +83,23 @@ swayc_t *new_output(wlc_handle handle) { output->handle = handle; output->name = name ? strdup(name) : NULL; output->gaps = config->gaps_outer + config->gaps_inner / 2; + + // Find position for it + if (oc && oc->x != -1 && oc->y != -1) { + output->x = oc->x; + output->y = oc->y; + } else { + int x = 0; + for (i = 0; i < root_container.children->length; ++i) { + swayc_t *c = root_container.children->items[i]; + if (c->type == C_OUTPUT) { + if (c->width + c->x > x) { + x = c->width + c->x; + } + } + } + output->x = x; + } add_child(&root_container, output); diff --git a/sway/layout.c b/sway/layout.c index 18ecb1e75..7f3adc315 100644 --- a/sway/layout.c +++ b/sway/layout.c @@ -172,18 +172,13 @@ void arrange_windows(swayc_t *container, double width, double height) { child->x = x; child->y = y; arrange_windows(child, -1, -1); - // Removed for now because wlc works with relative positions - // Addition can be reconsidered once wlc positions are changed - // x += child->width; + x += child->width; } return; case C_OUTPUT: container->width = width; container->height = height; - // These lines make x/y negative and result in stuff glitching out - // Their addition can be reconsidered once wlc positions are changed - // x -= container->x; - // y -= container->y; + x = 0, y = 0; for (i = 0; i < container->children->length; ++i) { swayc_t *child = container->children->items[i]; child->x = x + container->gaps;