diff options
author | Pedro CĂ´rte-Real <pedro@pedrocr.net> | 2019-06-23 18:28:26 +0100 |
---|---|---|
committer | Brian Ashworth <bosrsf04@gmail.com> | 2019-07-14 11:13:55 -0400 |
commit | 1312b5bb9faf7ab50c3024fc4f05b58481bf318c (patch) | |
tree | 27a32291c54fbf3e84539de98bfe67bd7ee3ea29 /sway/tree | |
parent | c312a10cc7ace29fde9105204787c9853745a57d (diff) |
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 (limited to 'sway/tree')
-rw-r--r-- | sway/tree/arrange.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/sway/tree/arrange.c b/sway/tree/arrange.c index 8583c53e..fc5d49ed 100644 --- 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; } |