aboutsummaryrefslogtreecommitdiff
path: root/sway/tree/layout.c
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2018-04-04 21:32:31 -0400
committerDrew DeVault <sir@cmpwn.com>2018-04-05 00:03:20 -0400
commitf77986338fc4186d003908012685c12d718ed647 (patch)
treef8b1ec4af069ab2123453d713251dcd7c51767d1 /sway/tree/layout.c
parent21aedf15052df4e7f8ee72922fa0e214d690facc (diff)
Implement resize command
Diffstat (limited to 'sway/tree/layout.c')
-rw-r--r--sway/tree/layout.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/sway/tree/layout.c b/sway/tree/layout.c
index 5abdbc32..7e2c61ed 100644
--- a/sway/tree/layout.c
+++ b/sway/tree/layout.c
@@ -729,3 +729,24 @@ struct sway_container *container_split(struct sway_container *child,
return cont;
}
+
+void container_recursive_resize(struct sway_container *container,
+ double amount, enum resize_edge edge) {
+ bool layout_match = true;
+ wlr_log(L_DEBUG, "Resizing %p with amount: %f", container, amount);
+ if (edge == RESIZE_EDGE_LEFT || edge == RESIZE_EDGE_RIGHT) {
+ container->width += amount;
+ layout_match = container->layout == L_HORIZ;
+ } else if (edge == RESIZE_EDGE_TOP || edge == RESIZE_EDGE_BOTTOM) {
+ container->height += amount;
+ layout_match = container->layout == L_VERT;
+ }
+ if (container->children) {
+ for (int i = 0; i < container->children->length; i++) {
+ struct sway_container *child = container->children->items[i];
+ double amt = layout_match ?
+ amount / container->children->length : amount;
+ container_recursive_resize(child, amt, edge);
+ }
+ }
+}