diff options
author | Brian Ashworth <bosrsf04@gmail.com> | 2018-10-01 12:56:27 -0400 |
---|---|---|
committer | Brian Ashworth <bosrsf04@gmail.com> | 2018-10-01 21:19:06 -0400 |
commit | bb25194844599bb653a78633c9c09c0c0ff225ee (patch) | |
tree | a19bcbc62ff5d4ddcb822914a4f3516c7766406a /sway/tree | |
parent | b542c5413efdbbe0bbf3be0196fe566b8c6bb07f (diff) | |
download | sway-bb25194844599bb653a78633c9c09c0c0ff225ee.tar.xz |
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')
-rw-r--r-- | sway/tree/view.c | 31 |
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) { return only_view; } +static bool gaps_to_edge(struct sway_view *view) { + struct sway_container *con = view->container; + while (con) { + if (con->current_gaps > 0) { + return true; + } + con = con->parent; + } + return view->container->workspace->current_gaps > 0; +} + void view_autoconfigure(struct sway_view *view) { if (!view->container->workspace) { // Hidden in the scratchpad @@ -196,23 +207,27 @@ void view_autoconfigure(struct sway_view *view) { struct sway_workspace *ws = view->container->workspace; struct sway_container *con = view->container; - bool other_views = config->hide_edge_borders == E_SMART ? - !view_is_only_visible(view) : false; + + bool smart = config->hide_edge_borders == E_SMART || + config->hide_edge_borders == E_SMART_NO_GAPS; + bool other_views = smart && !view_is_only_visible(view); + bool no_gaps = config->hide_edge_borders != E_SMART_NO_GAPS + || !gaps_to_edge(view); view->border_top = view->border_bottom = true; view->border_left = view->border_right = true; if (config->hide_edge_borders == E_BOTH || config->hide_edge_borders == E_VERTICAL - || (config->hide_edge_borders == E_SMART && !other_views)) { - view->border_left = con->x != ws->x; - int right_x = con->x + con->width; + || (smart && !other_views && no_gaps)) { + view->border_left = con->x - con->current_gaps != ws->x; + int right_x = con->x + con->width + con->current_gaps; view->border_right = right_x != ws->x + ws->width; } if (config->hide_edge_borders == E_BOTH || config->hide_edge_borders == E_HORIZONTAL - || (config->hide_edge_borders == E_SMART && !other_views)) { - view->border_top = con->y != ws->y; - int bottom_y = con->y + con->height; + || (smart && !other_views && no_gaps)) { + view->border_top = con->y - con->current_gaps != ws->y; + int bottom_y = con->y + con->height + con->current_gaps; view->border_bottom = bottom_y != ws->y + ws->height; } |