Layout correctly with several new windows

If there is more than one new window layout correctly by calculating the
default size of the new windows using the information of how many of
them there are in total.

This helps with issue #3547 but doesn't fix it in all situations. Things
now work correctly if the first layout of new windows happens after
leaving fullscreen. But if for some reason an arrange_container() gets
called while we are fullscreen the windows will still be incorrectly
sized after saved_width/saved_height get used to restore the first
window's size before going fullscreen.
master
Pedro Côrte-Real 6 years ago committed by Brian Ashworth
parent c312a10cc7
commit 1312b5bb9f

@ -18,13 +18,22 @@ static void apply_horiz_layout(list_t *children, struct wlr_box *parent) {
return;
}
// Count the number of new windows we are resizing
int new_children = 0;
for (int i = 0; i < children->length; ++i) {
struct sway_container *child = children->items[i];
if (child->width <= 0) {
new_children += 1;
}
}
// Calculate total width of children
double total_width = 0;
for (int i = 0; i < children->length; ++i) {
struct sway_container *child = children->items[i];
if (child->width <= 0) {
if (children->length > 1) {
child->width = parent->width / (children->length - 1);
if (children->length > new_children) {
child->width = parent->width / (children->length - new_children);
} else {
child->width = parent->width;
}
@ -58,13 +67,22 @@ static void apply_vert_layout(list_t *children, struct wlr_box *parent) {
return;
}
// Count the number of new windows we are resizing
int new_children = 0;
for (int i = 0; i < children->length; ++i) {
struct sway_container *child = children->items[i];
if (child->height <= 0) {
new_children += 1;
}
}
// Calculate total height of children
double total_height = 0;
for (int i = 0; i < children->length; ++i) {
struct sway_container *child = children->items[i];
if (child->height <= 0) {
if (children->length > 1) {
child->height = parent->height / (children->length - 1);
if (children->length > new_children) {
child->height = parent->height / (children->length - new_children);
} else {
child->height = parent->height;
}

Loading…
Cancel
Save