mirror of
https://github.com/swaywm/sway.git
synced 2024-12-29 00:16:22 +01:00
Set x/y positions for output containers
This commit is contained in:
parent
232940f813
commit
eac0920f49
2 changed files with 20 additions and 8 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue