Set x/y positions for output containers

This commit is contained in:
Drew DeVault 2015-08-22 14:44:47 -04:00
parent 232940f813
commit eac0920f49
2 changed files with 20 additions and 8 deletions

View file

@ -59,7 +59,7 @@ swayc_t *new_output(wlc_handle handle) {
const char *name = wlc_output_get_name(handle); const char *name = wlc_output_get_name(handle);
sway_log(L_DEBUG, "Added output %lu:%s", handle, name); sway_log(L_DEBUG, "Added output %lu:%s", handle, name);
struct output_config *oc ; struct output_config *oc = NULL;
int i; int i;
for (i = 0; i < config->output_configs->length; ++i) { for (i = 0; i < config->output_configs->length; ++i) {
oc = config->output_configs->items[i]; oc = config->output_configs->items[i];
@ -84,6 +84,23 @@ swayc_t *new_output(wlc_handle handle) {
output->name = name ? strdup(name) : NULL; output->name = name ? strdup(name) : NULL;
output->gaps = config->gaps_outer + config->gaps_inner / 2; 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); add_child(&root_container, output);
// Create workspace // Create workspace

View file

@ -172,18 +172,13 @@ void arrange_windows(swayc_t *container, double width, double height) {
child->x = x; child->x = x;
child->y = y; child->y = y;
arrange_windows(child, -1, -1); arrange_windows(child, -1, -1);
// Removed for now because wlc works with relative positions x += child->width;
// Addition can be reconsidered once wlc positions are changed
// x += child->width;
} }
return; return;
case C_OUTPUT: case C_OUTPUT:
container->width = width; container->width = width;
container->height = height; container->height = height;
// These lines make x/y negative and result in stuff glitching out x = 0, y = 0;
// Their addition can be reconsidered once wlc positions are changed
// x -= container->x;
// y -= container->y;
for (i = 0; i < container->children->length; ++i) { for (i = 0; i < container->children->length; ++i) {
swayc_t *child = container->children->items[i]; swayc_t *child = container->children->items[i];
child->x = x + container->gaps; child->x = x + container->gaps;