summaryrefslogtreecommitdiff
path: root/sway/tree/workspace.c
diff options
context:
space:
mode:
authorRyan Dwyer <[email protected]>2018-08-19 17:00:51 +1000
committerRyan Dwyer <[email protected]>2018-08-26 09:52:12 +1000
commit8bed4be1f387f9aa48910db1cf979cd847a9a2e3 (patch)
tree6bb0cd51d006de03535d4019d05c6787e8dd17aa /sway/tree/workspace.c
parented147aed30d89fdd1e4493adcdf821b414eab224 (diff)
Make separate gaps functions per container type
In preparation for using type safety.
Diffstat (limited to 'sway/tree/workspace.c')
-rw-r--r--sway/tree/workspace.c35
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,
container_set_dirty(workspace);
container_set_dirty(con);
}
+
+void workspace_remove_gaps(struct sway_container *ws) {
+ if (!sway_assert(ws->type == C_WORKSPACE, "Expected a workspace")) {
+ return;
+ }
+ if (ws->current_gaps == 0) {
+ return;
+ }
+
+ ws->width += ws->current_gaps * 2;
+ ws->height += ws->current_gaps * 2;
+ ws->x -= ws->current_gaps;
+ ws->y -= ws->current_gaps;
+ ws->current_gaps = 0;
+}
+
+void workspace_add_gaps(struct sway_container *ws) {
+ if (!sway_assert(ws->type == C_WORKSPACE, "Expected a workspace")) {
+ return;
+ }
+ if (ws->current_gaps > 0) {
+ return;
+ }
+ bool should_apply =
+ config->edge_gaps || (config->smart_gaps && ws->children->length > 1);
+ if (!should_apply) {
+ return;
+ }
+
+ ws->current_gaps = ws->has_gaps ? ws->gaps_inner : config->gaps_inner;
+ ws->x += ws->current_gaps;
+ ws->y += ws->current_gaps;
+ ws->width -= 2 * ws->current_gaps;
+ ws->height -= 2 * ws->current_gaps;
+}