mirror of
https://github.com/NickHu/sway
synced 2024-12-27 21:58:11 +01:00
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
This commit is contained in:
parent
d0233af3b3
commit
44c2fafa4f
3 changed files with 11 additions and 4 deletions
|
@ -3,6 +3,9 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
|
|
||||||
|
#define MIN_SANE_W 100
|
||||||
|
#define MIN_SANE_H 60
|
||||||
|
|
||||||
struct sway_root;
|
struct sway_root;
|
||||||
struct sway_output;
|
struct sway_output;
|
||||||
struct sway_workspace;
|
struct sway_workspace;
|
||||||
|
|
|
@ -15,8 +15,6 @@
|
||||||
#define AXIS_HORIZONTAL (WLR_EDGE_LEFT | WLR_EDGE_RIGHT)
|
#define AXIS_HORIZONTAL (WLR_EDGE_LEFT | WLR_EDGE_RIGHT)
|
||||||
#define AXIS_VERTICAL (WLR_EDGE_TOP | WLR_EDGE_BOTTOM)
|
#define AXIS_VERTICAL (WLR_EDGE_TOP | WLR_EDGE_BOTTOM)
|
||||||
|
|
||||||
static const int MIN_SANE_W = 100, MIN_SANE_H = 60;
|
|
||||||
|
|
||||||
enum resize_unit {
|
enum resize_unit {
|
||||||
RESIZE_UNIT_PX,
|
RESIZE_UNIT_PX,
|
||||||
RESIZE_UNIT_PPT,
|
RESIZE_UNIT_PPT,
|
||||||
|
|
|
@ -68,7 +68,10 @@ static void apply_horiz_layout(list_t *children, struct wlr_box *parent) {
|
||||||
}
|
}
|
||||||
temp = temp->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
|
// Resize windows
|
||||||
sway_log(SWAY_DEBUG, "Arranging %p horizontally", parent);
|
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;
|
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
|
// Resize windows
|
||||||
sway_log(SWAY_DEBUG, "Arranging %p vertically", parent);
|
sway_log(SWAY_DEBUG, "Arranging %p vertically", parent);
|
||||||
|
|
Loading…
Reference in a new issue