mirror of
https://github.com/swaywm/sway.git
synced 2024-12-30 17:06:40 +01:00
Sanity check gaps on the outside of the workspace
Avoid gaps that are too large around the workspace that you end up without any usable space for children. Fixes #4308
This commit is contained in:
parent
99192a92f9
commit
95c444de33
1 changed files with 19 additions and 0 deletions
|
@ -706,6 +706,25 @@ void workspace_add_gaps(struct sway_workspace *ws) {
|
|||
ws->current_gaps.bottom = fmax(0, ws->current_gaps.bottom + ws->gaps_inner);
|
||||
ws->current_gaps.left = fmax(0, ws->current_gaps.left + ws->gaps_inner);
|
||||
|
||||
// Now that we have the total gaps calculated we may need to clamp them in
|
||||
// case they've made the available area too small
|
||||
if (ws->width - ws->current_gaps.left - ws->current_gaps.right < MIN_SANE_W
|
||||
&& ws->current_gaps.left + ws->current_gaps.right > 0) {
|
||||
int total_gap = fmax(0, ws->width - MIN_SANE_W);
|
||||
double left_gap_frac = ((double)ws->current_gaps.left /
|
||||
((double)ws->current_gaps.left + (double)ws->current_gaps.right));
|
||||
ws->current_gaps.left = left_gap_frac * total_gap;
|
||||
ws->current_gaps.right = total_gap - ws->current_gaps.left;
|
||||
}
|
||||
if (ws->height - ws->current_gaps.top - ws->current_gaps.bottom < MIN_SANE_H
|
||||
&& ws->current_gaps.top + ws->current_gaps.bottom > 0) {
|
||||
int total_gap = fmax(0, ws->height - MIN_SANE_H);
|
||||
double top_gap_frac = ((double) ws->current_gaps.top /
|
||||
((double)ws->current_gaps.top + (double)ws->current_gaps.bottom));
|
||||
ws->current_gaps.top = top_gap_frac * total_gap;
|
||||
ws->current_gaps.bottom = total_gap - ws->current_gaps.top;
|
||||
}
|
||||
|
||||
ws->x += ws->current_gaps.left;
|
||||
ws->y += ws->current_gaps.top;
|
||||
ws->width -= ws->current_gaps.left + ws->current_gaps.right;
|
||||
|
|
Loading…
Reference in a new issue