aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/view.c
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-10-01 12:56:27 -0400
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-10-01 21:19:06 -0400
commitbb25194844599bb653a78633c9c09c0c0ff225ee (patch)
treea19bcbc62ff5d4ddcb822914a4f3516c7766406a /sway/tree/view.c
parentMerge pull request #2739 from RedSoxFan/fix-2653 (diff)
downloadsway-bb25194844599bb653a78633c9c09c0c0ff225ee.tar.gz
sway-bb25194844599bb653a78633c9c09c0c0ff225ee.tar.zst
sway-bb25194844599bb653a78633c9c09c0c0ff225ee.zip
Handle border options for gaps
Fixes `hide_edge_borders smart` when gaps are in use. Implements `hide_edge_borders smart_no_gaps` and `smart_borders on|no_gaps|off`. Since `smart_borders on` is equivalent to `hide_edge_borders smart` and `smart_borders no_gaps` is equivalent to `hide_edge_borders smart_no_gaps`, I opted to just save the last value set for `hide_edge_borders` and restore that on `smart_borders off`. This simplifies the conditions for setting the border.
Diffstat (limited to 'sway/tree/view.c')
-rw-r--r--sway/tree/view.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 3b271159..ca5e6ab0 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -179,6 +179,17 @@ bool view_is_only_visible(struct sway_view *view) {
179 return only_view; 179 return only_view;
180} 180}
181 181
182static bool gaps_to_edge(struct sway_view *view) {
183 struct sway_container *con = view->container;
184 while (con) {
185 if (con->current_gaps > 0) {
186 return true;
187 }
188 con = con->parent;
189 }
190 return view->container->workspace->current_gaps > 0;
191}
192
182void view_autoconfigure(struct sway_view *view) { 193void view_autoconfigure(struct sway_view *view) {
183 if (!view->container->workspace) { 194 if (!view->container->workspace) {
184 // Hidden in the scratchpad 195 // Hidden in the scratchpad
@@ -196,23 +207,27 @@ void view_autoconfigure(struct sway_view *view) {
196 207
197 struct sway_workspace *ws = view->container->workspace; 208 struct sway_workspace *ws = view->container->workspace;
198 struct sway_container *con = view->container; 209 struct sway_container *con = view->container;
199 bool other_views = config->hide_edge_borders == E_SMART ? 210
200 !view_is_only_visible(view) : false; 211 bool smart = config->hide_edge_borders == E_SMART ||
212 config->hide_edge_borders == E_SMART_NO_GAPS;
213 bool other_views = smart && !view_is_only_visible(view);
214 bool no_gaps = config->hide_edge_borders != E_SMART_NO_GAPS
215 || !gaps_to_edge(view);
201 216
202 view->border_top = view->border_bottom = true; 217 view->border_top = view->border_bottom = true;
203 view->border_left = view->border_right = true; 218 view->border_left = view->border_right = true;
204 if (config->hide_edge_borders == E_BOTH 219 if (config->hide_edge_borders == E_BOTH
205 || config->hide_edge_borders == E_VERTICAL 220 || config->hide_edge_borders == E_VERTICAL
206 || (config->hide_edge_borders == E_SMART && !other_views)) { 221 || (smart && !other_views && no_gaps)) {
207 view->border_left = con->x != ws->x; 222 view->border_left = con->x - con->current_gaps != ws->x;
208 int right_x = con->x + con->width; 223 int right_x = con->x + con->width + con->current_gaps;
209 view->border_right = right_x != ws->x + ws->width; 224 view->border_right = right_x != ws->x + ws->width;
210 } 225 }
211 if (config->hide_edge_borders == E_BOTH 226 if (config->hide_edge_borders == E_BOTH
212 || config->hide_edge_borders == E_HORIZONTAL 227 || config->hide_edge_borders == E_HORIZONTAL
213 || (config->hide_edge_borders == E_SMART && !other_views)) { 228 || (smart && !other_views && no_gaps)) {
214 view->border_top = con->y != ws->y; 229 view->border_top = con->y - con->current_gaps != ws->y;
215 int bottom_y = con->y + con->height; 230 int bottom_y = con->y + con->height + con->current_gaps;
216 view->border_bottom = bottom_y != ws->y + ws->height; 231 view->border_bottom = bottom_y != ws->y + ws->height;
217 } 232 }
218 233