aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/arrange.c
diff options
context:
space:
mode:
authorLibravatar Pedro CĂ´rte-Real <pedro@pedrocr.net>2019-06-23 18:28:26 +0100
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-07-14 11:13:55 -0400
commit1312b5bb9faf7ab50c3024fc4f05b58481bf318c (patch)
tree27a32291c54fbf3e84539de98bfe67bd7ee3ea29 /sway/tree/arrange.c
parentcmd_split: fix toggle split for non-split layouts (diff)
downloadsway-1312b5bb9faf7ab50c3024fc4f05b58481bf318c.tar.gz
sway-1312b5bb9faf7ab50c3024fc4f05b58481bf318c.tar.zst
sway-1312b5bb9faf7ab50c3024fc4f05b58481bf318c.zip
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/arrange.c')
-rw-r--r--sway/tree/arrange.c26
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 }