aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar mwenzkowski <29407878+mwenzkowski@users.noreply.github.com>2019-04-16 21:11:35 +0200
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-04-16 17:05:49 -0400
commite9e1fbc5011b8eaaaab73be21266ee1d388d38a7 (patch)
treeb20709cd963d967ac725e3d3688ad58f9465f198
parentAdd documentation for rename workspace (diff)
downloadsway-e9e1fbc5011b8eaaaab73be21266ee1d388d38a7.tar.gz
sway-e9e1fbc5011b8eaaaab73be21266ee1d388d38a7.tar.zst
sway-e9e1fbc5011b8eaaaab73be21266ee1d388d38a7.zip
view.c: refactor view_autoconfigure()
-rw-r--r--sway/tree/view.c24
1 files 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) {
197 197
198void view_autoconfigure(struct sway_view *view) { 198void view_autoconfigure(struct sway_view *view) {
199 struct sway_container *con = view->container; 199 struct sway_container *con = view->container;
200 struct sway_workspace *ws = con->workspace;
201
200 if (container_is_scratchpad_hidden(con) && 202 if (container_is_scratchpad_hidden(con) &&
201 con->fullscreen_mode != FULLSCREEN_GLOBAL) { 203 con->fullscreen_mode != FULLSCREEN_GLOBAL) {
202 return; 204 return;
203 } 205 }
204 struct sway_output *output = con->workspace ? con->workspace->output : NULL; 206 struct sway_output *output = ws ? ws->output : NULL;
205 207
206 if (con->fullscreen_mode == FULLSCREEN_WORKSPACE) { 208 if (con->fullscreen_mode == FULLSCREEN_WORKSPACE) {
207 con->content_x = output->lx; 209 con->content_x = output->lx;
@@ -217,27 +219,23 @@ void view_autoconfigure(struct sway_view *view) {
217 return; 219 return;
218 } 220 }
219 221
220 struct sway_workspace *ws = view->container->workspace;
221
222 bool smart = config->hide_edge_borders == E_SMART ||
223 config->hide_edge_borders == E_SMART_NO_GAPS;
224 bool other_views = smart && !view_is_only_visible(view);
225 bool no_gaps = config->hide_edge_borders != E_SMART_NO_GAPS
226 || !gaps_to_edge(view);
227
228 con->border_top = con->border_bottom = true; 222 con->border_top = con->border_bottom = true;
229 con->border_left = con->border_right = true; 223 con->border_left = con->border_right = true;
224
230 if (ws) { 225 if (ws) {
226 bool smart = config->hide_edge_borders == E_SMART ||
227 (config->hide_edge_borders == E_SMART_NO_GAPS &&
228 !gaps_to_edge(view));
229 bool hide_smart = smart && view_is_only_visible(view);
230
231 if (config->hide_edge_borders == E_BOTH 231 if (config->hide_edge_borders == E_BOTH
232 || config->hide_edge_borders == E_VERTICAL 232 || config->hide_edge_borders == E_VERTICAL || hide_smart) {
233 || (smart && !other_views && no_gaps)) {
234 con->border_left = con->x - con->current_gaps.left != ws->x; 233 con->border_left = con->x - con->current_gaps.left != ws->x;
235 int right_x = con->x + con->width + con->current_gaps.right; 234 int right_x = con->x + con->width + con->current_gaps.right;
236 con->border_right = right_x != ws->x + ws->width; 235 con->border_right = right_x != ws->x + ws->width;
237 } 236 }
238 if (config->hide_edge_borders == E_BOTH 237 if (config->hide_edge_borders == E_BOTH
239 || config->hide_edge_borders == E_HORIZONTAL 238 || config->hide_edge_borders == E_HORIZONTAL || hide_smart) {
240 || (smart && !other_views && no_gaps)) {
241 con->border_top = con->y - con->current_gaps.top != ws->y; 239 con->border_top = con->y - con->current_gaps.top != ws->y;
242 int bottom_y = con->y + con->height + con->current_gaps.bottom; 240 int bottom_y = con->y + con->height + con->current_gaps.bottom;
243 con->border_bottom = bottom_y != ws->y + ws->height; 241 con->border_bottom = bottom_y != ws->y + ws->height;