diff options
Diffstat (limited to 'sway/tree/workspace.c')
-rw-r--r-- | sway/tree/workspace.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index 93c4b3d3..d930826e 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c | |||
@@ -665,3 +665,38 @@ void workspace_add_floating(struct sway_container *workspace, | |||
665 | container_set_dirty(workspace); | 665 | container_set_dirty(workspace); |
666 | container_set_dirty(con); | 666 | container_set_dirty(con); |
667 | } | 667 | } |
668 | |||
669 | void workspace_remove_gaps(struct sway_container *ws) { | ||
670 | if (!sway_assert(ws->type == C_WORKSPACE, "Expected a workspace")) { | ||
671 | return; | ||
672 | } | ||
673 | if (ws->current_gaps == 0) { | ||
674 | return; | ||
675 | } | ||
676 | |||
677 | ws->width += ws->current_gaps * 2; | ||
678 | ws->height += ws->current_gaps * 2; | ||
679 | ws->x -= ws->current_gaps; | ||
680 | ws->y -= ws->current_gaps; | ||
681 | ws->current_gaps = 0; | ||
682 | } | ||
683 | |||
684 | void workspace_add_gaps(struct sway_container *ws) { | ||
685 | if (!sway_assert(ws->type == C_WORKSPACE, "Expected a workspace")) { | ||
686 | return; | ||
687 | } | ||
688 | if (ws->current_gaps > 0) { | ||
689 | return; | ||
690 | } | ||
691 | bool should_apply = | ||
692 | config->edge_gaps || (config->smart_gaps && ws->children->length > 1); | ||
693 | if (!should_apply) { | ||
694 | return; | ||
695 | } | ||
696 | |||
697 | ws->current_gaps = ws->has_gaps ? ws->gaps_inner : config->gaps_inner; | ||
698 | ws->x += ws->current_gaps; | ||
699 | ws->y += ws->current_gaps; | ||
700 | ws->width -= 2 * ws->current_gaps; | ||
701 | ws->height -= 2 * ws->current_gaps; | ||
702 | } | ||