aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
authorPedro CĂ´rte-Real <pedro@pedrocr.net>2019-07-06 12:22:41 +0100
committerBrian Ashworth <bosrsf04@gmail.com>2019-07-15 23:46:27 -0400
commit99192a92f942f120f8cd0c6037c613325677a332 (patch)
tree88a15f615ad83a25f12cd727e5f616e99cccc97d /sway
parent44c2fafa4f561969c5987293863e9dfd63fc2ada (diff)
Avoid negative outer gaps
Make sure we never let the gaps around the workspace go negative. Fixes #4304
Diffstat (limited to 'sway')
-rw-r--r--sway/tree/workspace.c27
1 files changed, 5 insertions, 22 deletions
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c
index accdf6e3..aca35529 100644
--- a/sway/tree/workspace.c
+++ b/sway/tree/workspace.c
@@ -54,21 +54,6 @@ struct sway_output *workspace_get_initial_output(const char *name) {
return root->outputs->length ? root->outputs->items[0] : root->noop_output;
}
-static void prevent_invalid_outer_gaps(struct sway_workspace *ws) {
- if (ws->gaps_outer.top < -ws->gaps_inner) {
- ws->gaps_outer.top = -ws->gaps_inner;
- }
- if (ws->gaps_outer.right < -ws->gaps_inner) {
- ws->gaps_outer.right = -ws->gaps_inner;
- }
- if (ws->gaps_outer.bottom < -ws->gaps_inner) {
- ws->gaps_outer.bottom = -ws->gaps_inner;
- }
- if (ws->gaps_outer.left < -ws->gaps_inner) {
- ws->gaps_outer.left = -ws->gaps_inner;
- }
-}
-
struct sway_workspace *workspace_create(struct sway_output *output,
const char *name) {
if (output == NULL) {
@@ -111,9 +96,6 @@ struct sway_workspace *workspace_create(struct sway_output *output,
if (wsc->gaps_inner != INT_MIN) {
ws->gaps_inner = wsc->gaps_inner;
}
- // Since default outer gaps can be smaller than the negation of
- // workspace specific inner gaps, check outer gaps again
- prevent_invalid_outer_gaps(ws);
// Add output priorities
for (int i = 0; i < wsc->outputs->length; ++i) {
@@ -718,10 +700,11 @@ void workspace_add_gaps(struct sway_workspace *ws) {
}
ws->current_gaps = ws->gaps_outer;
- ws->current_gaps.top += ws->gaps_inner;
- ws->current_gaps.right += ws->gaps_inner;
- ws->current_gaps.bottom += ws->gaps_inner;
- ws->current_gaps.left += ws->gaps_inner;
+ // Add inner gaps and make sure we don't turn out negative
+ ws->current_gaps.top = fmax(0, ws->current_gaps.top + ws->gaps_inner);
+ ws->current_gaps.right = fmax(0, ws->current_gaps.right + ws->gaps_inner);
+ 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);
ws->x += ws->current_gaps.left;
ws->y += ws->current_gaps.top;