From e9e1fbc5011b8eaaaab73be21266ee1d388d38a7 Mon Sep 17 00:00:00 2001 From: mwenzkowski <29407878+mwenzkowski@users.noreply.github.com> Date: Tue, 16 Apr 2019 21:11:35 +0200 Subject: view.c: refactor view_autoconfigure() --- sway/tree/view.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/sway/tree/view.c b/sway/tree/view.c index c241b2b3..40432661 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -197,11 +197,13 @@ static bool gaps_to_edge(struct sway_view *view) { void view_autoconfigure(struct sway_view *view) { struct sway_container *con = view->container; + struct sway_workspace *ws = con->workspace; + if (container_is_scratchpad_hidden(con) && con->fullscreen_mode != FULLSCREEN_GLOBAL) { return; } - struct sway_output *output = con->workspace ? con->workspace->output : NULL; + struct sway_output *output = ws ? ws->output : NULL; if (con->fullscreen_mode == FULLSCREEN_WORKSPACE) { con->content_x = output->lx; @@ -217,27 +219,23 @@ void view_autoconfigure(struct sway_view *view) { return; } - struct sway_workspace *ws = view->container->workspace; - - 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); - con->border_top = con->border_bottom = true; con->border_left = con->border_right = true; + if (ws) { + bool smart = config->hide_edge_borders == E_SMART || + (config->hide_edge_borders == E_SMART_NO_GAPS && + !gaps_to_edge(view)); + bool hide_smart = smart && view_is_only_visible(view); + if (config->hide_edge_borders == E_BOTH - || config->hide_edge_borders == E_VERTICAL - || (smart && !other_views && no_gaps)) { + || config->hide_edge_borders == E_VERTICAL || hide_smart) { con->border_left = con->x - con->current_gaps.left != ws->x; int right_x = con->x + con->width + con->current_gaps.right; con->border_right = right_x != ws->x + ws->width; } if (config->hide_edge_borders == E_BOTH - || config->hide_edge_borders == E_HORIZONTAL - || (smart && !other_views && no_gaps)) { + || config->hide_edge_borders == E_HORIZONTAL || hide_smart) { con->border_top = con->y - con->current_gaps.top != ws->y; int bottom_y = con->y + con->height + con->current_gaps.bottom; con->border_bottom = bottom_y != ws->y + ws->height; -- cgit v1.2.3-54-g00ecf