diff options
-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) { | |||
18 | return; | 18 | return; |
19 | } | 19 | } |
20 | 20 | ||
21 | // Count the number of new windows we are resizing | ||
22 | int new_children = 0; | ||
23 | for (int i = 0; i < children->length; ++i) { | ||
24 | struct sway_container *child = children->items[i]; | ||
25 | if (child->width <= 0) { | ||
26 | new_children += 1; | ||
27 | } | ||
28 | } | ||
29 | |||
21 | // Calculate total width of children | 30 | // Calculate total width of children |
22 | double total_width = 0; | 31 | double total_width = 0; |
23 | for (int i = 0; i < children->length; ++i) { | 32 | for (int i = 0; i < children->length; ++i) { |
24 | struct sway_container *child = children->items[i]; | 33 | struct sway_container *child = children->items[i]; |
25 | if (child->width <= 0) { | 34 | if (child->width <= 0) { |
26 | if (children->length > 1) { | 35 | if (children->length > new_children) { |
27 | child->width = parent->width / (children->length - 1); | 36 | child->width = parent->width / (children->length - new_children); |
28 | } else { | 37 | } else { |
29 | child->width = parent->width; | 38 | child->width = parent->width; |
30 | } | 39 | } |
@@ -58,13 +67,22 @@ static void apply_vert_layout(list_t *children, struct wlr_box *parent) { | |||
58 | return; | 67 | return; |
59 | } | 68 | } |
60 | 69 | ||
70 | // Count the number of new windows we are resizing | ||
71 | int new_children = 0; | ||
72 | for (int i = 0; i < children->length; ++i) { | ||
73 | struct sway_container *child = children->items[i]; | ||
74 | if (child->height <= 0) { | ||
75 | new_children += 1; | ||
76 | } | ||
77 | } | ||
78 | |||
61 | // Calculate total height of children | 79 | // Calculate total height of children |
62 | double total_height = 0; | 80 | double total_height = 0; |
63 | for (int i = 0; i < children->length; ++i) { | 81 | for (int i = 0; i < children->length; ++i) { |
64 | struct sway_container *child = children->items[i]; | 82 | struct sway_container *child = children->items[i]; |
65 | if (child->height <= 0) { | 83 | if (child->height <= 0) { |
66 | if (children->length > 1) { | 84 | if (children->length > new_children) { |
67 | child->height = parent->height / (children->length - 1); | 85 | child->height = parent->height / (children->length - new_children); |
68 | } else { | 86 | } else { |
69 | child->height = parent->height; | 87 | child->height = parent->height; |
70 | } | 88 | } |