aboutsummaryrefslogtreecommitdiff
path: root/sway/container.c
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2015-08-22 14:44:47 -0400
committerDrew DeVault <sir@cmpwn.com>2015-08-22 14:44:47 -0400
commiteac0920f49a728ad6a3809528c4757b73e4cd8af (patch)
treebed4a2b0d9a51f4354bf61012ed58bf3c6985a1f /sway/container.c
parent232940f81302ca7c07c08744ada0be0fa37dd2ff (diff)
Set x/y positions for output containers
Diffstat (limited to 'sway/container.c')
-rw-r--r--sway/container.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/sway/container.c b/sway/container.c
index 5d544934..41d21c3b 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);