commit 1312b5bb9faf7ab50c3024fc4f05b58481bf318c
parent c312a10cc7ace29fde9105204787c9853745a57d
Author: Pedro Côrte-Real <pedro@pedrocr.net>
Date: Sun, 23 Jun 2019 18:28:26 +0100
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.
Diffstat:
1 file changed, 22 insertions(+), 4 deletions(-)
diff --git a/sway/tree/arrange.c b/sway/tree/arrange.c
@@ -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;
}