diff options
Diffstat (limited to 'sway/tree/view.c')
-rw-r--r-- | sway/tree/view.c | 73 |
1 files changed, 45 insertions, 28 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c index 9ffcf206..9c7c44e9 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -165,6 +165,34 @@ uint32_t view_configure(struct sway_view *view, double lx, double ly, int width, return 0; } +bool view_is_only_visible(struct sway_view *view) { + bool only_view = true; + struct sway_container *con = view->container; + while (con) { + enum sway_container_layout layout = container_parent_layout(con); + if (layout != L_TABBED && layout != L_STACKED) { + list_t *siblings = container_get_siblings(con); + if (siblings && siblings->length > 1) { + only_view = false; + break; + } + } + con = con->parent; + } + 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 @@ -181,39 +209,28 @@ void view_autoconfigure(struct sway_view *view) { } struct sway_workspace *ws = view->container->workspace; - - bool other_views = false; - if (config->hide_edge_borders == E_SMART) { - struct sway_container *con = view->container; - while (con) { - enum sway_container_layout layout = container_parent_layout(con); - if (layout != L_TABBED && layout != L_STACKED) { - list_t *siblings = container_get_siblings(con); - if (siblings && siblings->length > 1) { - other_views = true; - break; - } - } - con = con->parent; - } - } - struct sway_container *con = view->container; + 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; } @@ -1004,12 +1021,16 @@ bool view_is_visible(struct sway_view *view) { floater = floater->parent; } bool is_sticky = container_is_floating(floater) && floater->is_sticky; + if (!is_sticky && !workspace_is_visible(workspace)) { + return false; + } // Check view isn't in a tabbed or stacked container on an inactive tab struct sway_seat *seat = input_manager_current_seat(input_manager); struct sway_container *con = view->container; while (con) { enum sway_container_layout layout = container_parent_layout(con); - if (layout == L_TABBED || layout == L_STACKED) { + if ((layout == L_TABBED || layout == L_STACKED) + && !container_is_floating(con)) { struct sway_node *parent = con->parent ? &con->parent->node : &con->workspace->node; if (seat_get_active_tiling_child(seat, parent) != &con->node) { @@ -1023,10 +1044,6 @@ bool view_is_visible(struct sway_view *view) { !container_is_fullscreen_or_child(view->container)) { return false; } - // Check the workspace is visible - if (!is_sticky) { - return workspace_is_visible(workspace); - } return true; } |