aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/workspace.c
diff options
context:
space:
mode:
authorLibravatar Pedro CĂ´rte-Real <pedro@pedrocr.net>2019-07-06 12:22:41 +0100
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-07-15 23:46:27 -0400
commit99192a92f942f120f8cd0c6037c613325677a332 (patch)
tree88a15f615ad83a25f12cd727e5f616e99cccc97d /sway/tree/workspace.c
parentSanity check gaps between tiled containers (diff)
downloadsway-99192a92f942f120f8cd0c6037c613325677a332.tar.gz
sway-99192a92f942f120f8cd0c6037c613325677a332.tar.zst
sway-99192a92f942f120f8cd0c6037c613325677a332.zip
Avoid negative outer gaps
Make sure we never let the gaps around the workspace go negative. Fixes #4304
Diffstat (limited to 'sway/tree/workspace.c')
-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) {
54 return root->outputs->length ? root->outputs->items[0] : root->noop_output; 54 return root->outputs->length ? root->outputs->items[0] : root->noop_output;
55} 55}
56 56
57static void prevent_invalid_outer_gaps(struct sway_workspace *ws) {
58 if (ws->gaps_outer.top < -ws->gaps_inner) {
59 ws->gaps_outer.top = -ws->gaps_inner;
60 }
61 if (ws->gaps_outer.right < -ws->gaps_inner) {
62 ws->gaps_outer.right = -ws->gaps_inner;
63 }
64 if (ws->gaps_outer.bottom < -ws->gaps_inner) {
65 ws->gaps_outer.bottom = -ws->gaps_inner;
66 }
67 if (ws->gaps_outer.left < -ws->gaps_inner) {
68 ws->gaps_outer.left = -ws->gaps_inner;
69 }
70}
71
72struct sway_workspace *workspace_create(struct sway_output *output, 57struct sway_workspace *workspace_create(struct sway_output *output,
73 const char *name) { 58 const char *name) {
74 if (output == NULL) { 59 if (output == NULL) {
@@ -111,9 +96,6 @@ struct sway_workspace *workspace_create(struct sway_output *output,
111 if (wsc->gaps_inner != INT_MIN) { 96 if (wsc->gaps_inner != INT_MIN) {
112 ws->gaps_inner = wsc->gaps_inner; 97 ws->gaps_inner = wsc->gaps_inner;
113 } 98 }
114 // Since default outer gaps can be smaller than the negation of
115 // workspace specific inner gaps, check outer gaps again
116 prevent_invalid_outer_gaps(ws);
117 99
118 // Add output priorities 100 // Add output priorities
119 for (int i = 0; i < wsc->outputs->length; ++i) { 101 for (int i = 0; i < wsc->outputs->length; ++i) {
@@ -718,10 +700,11 @@ void workspace_add_gaps(struct sway_workspace *ws) {
718 } 700 }
719 701
720 ws->current_gaps = ws->gaps_outer; 702 ws->current_gaps = ws->gaps_outer;
721 ws->current_gaps.top += ws->gaps_inner; 703 // Add inner gaps and make sure we don't turn out negative
722 ws->current_gaps.right += ws->gaps_inner; 704 ws->current_gaps.top = fmax(0, ws->current_gaps.top + ws->gaps_inner);
723 ws->current_gaps.bottom += ws->gaps_inner; 705 ws->current_gaps.right = fmax(0, ws->current_gaps.right + ws->gaps_inner);
724 ws->current_gaps.left += ws->gaps_inner; 706 ws->current_gaps.bottom = fmax(0, ws->current_gaps.bottom + ws->gaps_inner);
707 ws->current_gaps.left = fmax(0, ws->current_gaps.left + ws->gaps_inner);
725 708
726 ws->x += ws->current_gaps.left; 709 ws->x += ws->current_gaps.left;
727 ws->y += ws->current_gaps.top; 710 ws->y += ws->current_gaps.top;