aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 @@
#include <stdbool.h>
#include "list.h"
+#define MIN_SANE_W 100
+#define MIN_SANE_H 60
+
struct sway_root;
struct sway_output;
struct 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 @@
#define AXIS_HORIZONTAL (WLR_EDGE_LEFT | WLR_EDGE_RIGHT)
#define AXIS_VERTICAL (WLR_EDGE_TOP | WLR_EDGE_BOTTOM)
-static const int MIN_SANE_W = 100, MIN_SANE_H = 60;
-
enum resize_unit {
RESIZE_UNIT_PX,
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) {
}
temp = temp->parent;
}
- double child_total_width = parent->width - inner_gap * (children->length - 1);
+ double total_gap = fmin(inner_gap * (children->length - 1),
+ fmax(0, parent->width - MIN_SANE_W * children->length));
+ double child_total_width = parent->width - total_gap;
+ inner_gap = total_gap / (children->length - 1);
// Resize windows
sway_log(SWAY_DEBUG, "Arranging %p horizontally", parent);
@@ -143,7 +146,10 @@ static void apply_vert_layout(list_t *children, struct wlr_box *parent) {
}
temp = temp->parent;
}
- double child_total_height = parent->height - inner_gap * (children->length - 1);
+ double total_gap = fmin(inner_gap * (children->length - 1),
+ fmax(0, parent->height - MIN_SANE_H * children->length));
+ double child_total_height = parent->height - total_gap;
+ inner_gap = total_gap / (children->length - 1);
// Resize windows
sway_log(SWAY_DEBUG, "Arranging %p vertically", parent);