From 415a48ac6387a62a59adb8ed1168e851509a0ce3 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sat, 29 Sep 2018 11:06:07 +1000 Subject: Make gaps implementation consistent with i3-gaps This changes our gaps implementation to behave like i3-gaps. Our previous implementation allowed you to set gaps on a per container basis. This isn't supported by i3-gaps and doesn't seem to have a practical use case. The gaps_outer and gaps_inner properties on containers are now removed as they just read the gaps_inner from the workspace. `gaps inner|outer ` no longer changes the gaps for all workspaces. It only sets defaults for new workspaces. `gaps inner|outer current|workspace|all set|plus|minus ` is now runtime only, and the workspace option is now removed. `current` now sets gaps for the current workspace as opposed to the current container. `workspace gaps inner|outer ` is now implemented. This sets defaults for a workspace. This also fixes a bug where changing the layout of a split container from linear to tabbed would cause gaps to not be applied to it until you switch to another workspace and back. --- sway/tree/container.c | 2 +- sway/tree/workspace.c | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) (limited to 'sway/tree') diff --git a/sway/tree/container.c b/sway/tree/container.c index baaa82fd..e329f835 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -1022,7 +1022,7 @@ void container_add_gaps(struct sway_container *c) { struct sway_workspace *ws = c->workspace; - c->current_gaps = ws->has_gaps ? ws->gaps_inner : config->gaps_inner; + c->current_gaps = ws->gaps_inner; c->x += c->current_gaps; c->y += c->current_gaps; c->width -= 2 * c->current_gaps; diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index d65a3e4c..9dd5c815 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c @@ -68,6 +68,20 @@ struct sway_workspace *workspace_create(struct sway_output *output, ws->output_priority = create_list(); workspace_output_add_priority(ws, output); + ws->gaps_outer = config->gaps_outer; + ws->gaps_inner = config->gaps_inner; + if (name) { + struct workspace_config *wsc = workspace_find_config(name); + if (wsc) { + if (wsc->gaps_outer != -1) { + ws->gaps_outer = wsc->gaps_outer; + } + if (wsc->gaps_inner != -1) { + ws->gaps_inner = wsc->gaps_inner; + } + } + } + output_add_workspace(output, ws); output_sort_workspaces(output); @@ -632,13 +646,13 @@ void workspace_add_gaps(struct sway_workspace *ws) { return; } - ws->current_gaps = ws->has_gaps ? ws->gaps_outer : config->gaps_outer; + ws->current_gaps = ws->gaps_outer; if (ws->layout == L_TABBED || ws->layout == L_STACKED) { // We have to add inner gaps for this, because children of tabbed and // stacked containers don't apply their own gaps - they assume the // tabbed/stacked container is using gaps. - ws->current_gaps += ws->has_gaps ? ws->gaps_inner : config->gaps_inner; + ws->current_gaps += ws->gaps_inner; } ws->x += ws->current_gaps; -- cgit v1.2.3-54-g00ecf