diff options
author | Tudor Brindus <me@tbrindus.ca> | 2020-06-26 20:12:28 -0400 |
---|---|---|
committer | Brian Ashworth <bosrsf04@gmail.com> | 2020-06-27 21:05:58 -0400 |
commit | bb85b9070d05cc707146aafec56b7452441a4bd2 (patch) | |
tree | f57fc0a940187bc29556d8ca1afca488300c1cf0 /sway/tree | |
parent | input/pointer: correctly handle bindings for synthetic events (diff) | |
download | sway-bb85b9070d05cc707146aafec56b7452441a4bd2.tar.gz sway-bb85b9070d05cc707146aafec56b7452441a4bd2.tar.zst sway-bb85b9070d05cc707146aafec56b7452441a4bd2.zip |
tree/view: fix smart borders with tabbed/stacked ancestor
Fixes #5484.
Diffstat (limited to 'sway/tree')
-rw-r--r-- | sway/tree/view.c | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c index 6dccaa2e..fb397c42 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c | |||
@@ -211,6 +211,23 @@ bool view_ancestor_is_only_visible(struct sway_view *view) { | |||
211 | return only_visible; | 211 | return only_visible; |
212 | } | 212 | } |
213 | 213 | ||
214 | static bool view_is_only_visible(struct sway_view *view) { | ||
215 | struct sway_container *con = view->container; | ||
216 | while (con) { | ||
217 | enum sway_container_layout layout = container_parent_layout(con); | ||
218 | if (layout != L_TABBED && layout != L_STACKED) { | ||
219 | list_t *siblings = container_get_siblings(con); | ||
220 | if (siblings && siblings->length > 1) { | ||
221 | return false; | ||
222 | } | ||
223 | } | ||
224 | |||
225 | con = con->parent; | ||
226 | } | ||
227 | |||
228 | return true; | ||
229 | } | ||
230 | |||
214 | static bool gaps_to_edge(struct sway_view *view) { | 231 | static bool gaps_to_edge(struct sway_view *view) { |
215 | struct side_gaps gaps = view->container->workspace->current_gaps; | 232 | struct side_gaps gaps = view->container->workspace->current_gaps; |
216 | return gaps.top > 0 || gaps.right > 0 || gaps.bottom > 0 || gaps.left > 0; | 233 | return gaps.top > 0 || gaps.right > 0 || gaps.bottom > 0 || gaps.left > 0; |
@@ -245,25 +262,31 @@ void view_autoconfigure(struct sway_view *view) { | |||
245 | double y_offset = 0; | 262 | double y_offset = 0; |
246 | 263 | ||
247 | if (!container_is_floating(con) && ws) { | 264 | if (!container_is_floating(con) && ws) { |
248 | |||
249 | bool smart = config->hide_edge_borders_smart == ESMART_ON || | ||
250 | (config->hide_edge_borders_smart == ESMART_NO_GAPS && | ||
251 | !gaps_to_edge(view)); | ||
252 | bool hide_smart = smart && view_ancestor_is_only_visible(view); | ||
253 | |||
254 | if (config->hide_edge_borders == E_BOTH | 265 | if (config->hide_edge_borders == E_BOTH |
255 | || config->hide_edge_borders == E_VERTICAL || hide_smart) { | 266 | || config->hide_edge_borders == E_VERTICAL) { |
256 | con->border_left = con->x != ws->x; | 267 | con->border_left = con->x != ws->x; |
257 | int right_x = con->x + con->width; | 268 | int right_x = con->x + con->width; |
258 | con->border_right = right_x != ws->x + ws->width; | 269 | con->border_right = right_x != ws->x + ws->width; |
259 | } | 270 | } |
271 | |||
260 | if (config->hide_edge_borders == E_BOTH | 272 | if (config->hide_edge_borders == E_BOTH |
261 | || config->hide_edge_borders == E_HORIZONTAL || hide_smart) { | 273 | || config->hide_edge_borders == E_HORIZONTAL) { |
262 | con->border_top = con->y != ws->y; | 274 | con->border_top = con->y != ws->y; |
263 | int bottom_y = con->y + con->height; | 275 | int bottom_y = con->y + con->height; |
264 | con->border_bottom = bottom_y != ws->y + ws->height; | 276 | con->border_bottom = bottom_y != ws->y + ws->height; |
265 | } | 277 | } |
266 | 278 | ||
279 | bool smart = config->hide_edge_borders_smart == ESMART_ON || | ||
280 | (config->hide_edge_borders_smart == ESMART_NO_GAPS && | ||
281 | !gaps_to_edge(view)); | ||
282 | if (smart) { | ||
283 | bool show_border = !view_is_only_visible(view); | ||
284 | con->border_left &= show_border; | ||
285 | con->border_right &= show_border; | ||
286 | con->border_top &= show_border; | ||
287 | con->border_bottom &= show_border; | ||
288 | } | ||
289 | |||
267 | // In a tabbed or stacked container, the container's y is the top of the | 290 | // In a tabbed or stacked container, the container's y is the top of the |
268 | // title area. We have to offset the surface y by the height of the title, | 291 | // title area. We have to offset the surface y by the height of the title, |
269 | // bar, and disable any top border because we'll always have the title bar. | 292 | // bar, and disable any top border because we'll always have the title bar. |