aboutsummaryrefslogtreecommitdiff
path: root/sway/tree/container.c
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2018-08-25 20:07:37 -0400
committerGitHub <noreply@github.com>2018-08-25 20:07:37 -0400
commit1a30c50ef40e918942f96c9a399f9bf94c1c0116 (patch)
tree6bb0cd51d006de03535d4019d05c6787e8dd17aa /sway/tree/container.c
parented147aed30d89fdd1e4493adcdf821b414eab224 (diff)
parent8bed4be1f387f9aa48910db1cf979cd847a9a2e3 (diff)
Merge pull request #2488 from RyanDwyer/separate-gaps-functions
Make separate gaps functions per container type
Diffstat (limited to 'sway/tree/container.c')
-rw-r--r--sway/tree/container.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c
index 5721c35c..f9611342 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -1124,7 +1124,38 @@ void container_discover_outputs(struct sway_container *con) {
}
}
+void container_remove_gaps(struct sway_container *c) {
+ if (!sway_assert(c->type == C_CONTAINER || c->type == C_VIEW,
+ "Expected a container or view")) {
+ return;
+ }
+ if (c->current_gaps == 0) {
+ return;
+ }
+
+ c->width += c->current_gaps * 2;
+ c->height += c->current_gaps * 2;
+ c->x -= c->current_gaps;
+ c->y -= c->current_gaps;
+ c->current_gaps = 0;
+}
+
+void container_add_gaps(struct sway_container *c) {
+ if (!sway_assert(c->type == C_CONTAINER || c->type == C_VIEW,
+ "Expected a container or view")) {
+ return;
+ }
+ if (c->current_gaps > 0 || c->type != C_VIEW) {
+ return;
+ }
+
+ c->current_gaps = c->has_gaps ? c->gaps_inner : config->gaps_inner;
+ c->x += c->current_gaps;
+ c->y += c->current_gaps;
+ c->width -= 2 * c->current_gaps;
+ c->height -= 2 * c->current_gaps;
+}
+
int container_sibling_index(const struct sway_container *child) {
return list_find(child->parent->children, child);
}
-