summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Pedro CĂ´rte-Real <pedro@pedrocr.net>2019-07-06 12:13:05 +0100
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-07-15 23:46:27 -0400
commit44c2fafa4f561969c5987293863e9dfd63fc2ada (patch)
tree21c00c3790b825b6cab6ebd68061a4d98fc2c256
parentRework gaps code to be simpler and correct (diff)
downloadsway-44c2fafa4f561969c5987293863e9dfd63fc2ada.tar.gz
sway-44c2fafa4f561969c5987293863e9dfd63fc2ada.tar.zst
sway-44c2fafa4f561969c5987293863e9dfd63fc2ada.zip
Sanity check gaps between tiled containers
When the gaps become too large for the space available gracefully reduced them all the way to 0 if needed. Fixes #4294
-rw-r--r--include/sway/tree/node.h3
-rw-r--r--sway/commands/resize.c2
-rw-r--r--sway/tree/arrange.c10
3 files changed, 11 insertions, 4 deletions
diff --git a/include/sway/tree/node.h b/include/sway/tree/node.h
index 5b8c1909..470ee3b5 100644
--- a/include/sway/tree/node.h
+++ b/include/sway/tree/node.h
@@ -3,6 +3,9 @@
3#include <stdbool.h> 3#include <stdbool.h>
4#include "list.h" 4#include "list.h"
5 5
6#define MIN_SANE_W 100
7#define MIN_SANE_H 60
8
6struct sway_root; 9struct sway_root;
7struct sway_output; 10struct sway_output;
8struct sway_workspace; 11struct sway_workspace;
diff --git a/sway/commands/resize.c b/sway/commands/resize.c
index 28f2552e..4cefe60b 100644
--- a/sway/commands/resize.c
+++ b/sway/commands/resize.c
@@ -15,8 +15,6 @@
15#define AXIS_HORIZONTAL (WLR_EDGE_LEFT | WLR_EDGE_RIGHT) 15#define AXIS_HORIZONTAL (WLR_EDGE_LEFT | WLR_EDGE_RIGHT)
16#define AXIS_VERTICAL (WLR_EDGE_TOP | WLR_EDGE_BOTTOM) 16#define AXIS_VERTICAL (WLR_EDGE_TOP | WLR_EDGE_BOTTOM)
17 17
18static const int MIN_SANE_W = 100, MIN_SANE_H = 60;
19
20enum resize_unit { 18enum resize_unit {
21 RESIZE_UNIT_PX, 19 RESIZE_UNIT_PX,
22 RESIZE_UNIT_PPT, 20 RESIZE_UNIT_PPT,
diff --git a/sway/tree/arrange.c b/sway/tree/arrange.c
index caafb1af..696d0e1f 100644
--- a/sway/tree/arrange.c
+++ b/sway/tree/arrange.c
@@ -68,7 +68,10 @@ static void apply_horiz_layout(list_t *children, struct wlr_box *parent) {
68 } 68 }
69 temp = temp->parent; 69 temp = temp->parent;
70 } 70 }
71 double child_total_width = parent->width - inner_gap * (children->length - 1); 71 double total_gap = fmin(inner_gap * (children->length - 1),
72 fmax(0, parent->width - MIN_SANE_W * children->length));
73 double child_total_width = parent->width - total_gap;
74 inner_gap = total_gap / (children->length - 1);
72 75
73 // Resize windows 76 // Resize windows
74 sway_log(SWAY_DEBUG, "Arranging %p horizontally", parent); 77 sway_log(SWAY_DEBUG, "Arranging %p horizontally", parent);
@@ -143,7 +146,10 @@ static void apply_vert_layout(list_t *children, struct wlr_box *parent) {
143 } 146 }
144 temp = temp->parent; 147 temp = temp->parent;
145 } 148 }
146 double child_total_height = parent->height - inner_gap * (children->length - 1); 149 double total_gap = fmin(inner_gap * (children->length - 1),
150 fmax(0, parent->height - MIN_SANE_H * children->length));
151 double child_total_height = parent->height - total_gap;
152 inner_gap = total_gap / (children->length - 1);
147 153
148 // Resize windows 154 // Resize windows
149 sway_log(SWAY_DEBUG, "Arranging %p vertically", parent); 155 sway_log(SWAY_DEBUG, "Arranging %p vertically", parent);