diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-04-05 00:17:47 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-05 00:17:47 -0400 |
commit | 9e89daf21353d3739d84ed25ae99aab82704df97 (patch) | |
tree | d7e3d910fc6646515c7869f5177a8c26cb6e35ca /sway/tree | |
parent | Merge pull request #1736 from acrisci/ipc-container-type (diff) | |
parent | Implement resize command (diff) | |
download | sway-9e89daf21353d3739d84ed25ae99aab82704df97.tar.gz sway-9e89daf21353d3739d84ed25ae99aab82704df97.tar.zst sway-9e89daf21353d3739d84ed25ae99aab82704df97.zip |
Merge pull request #1734 from swaywm/resize-cmd
Implement resize command
Diffstat (limited to 'sway/tree')
-rw-r--r-- | sway/tree/layout.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/sway/tree/layout.c b/sway/tree/layout.c index 1769609b..65fd5d4a 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c | |||
@@ -729,3 +729,24 @@ struct sway_container *container_split(struct sway_container *child, | |||
729 | 729 | ||
730 | return cont; | 730 | return cont; |
731 | } | 731 | } |
732 | |||
733 | void container_recursive_resize(struct sway_container *container, | ||
734 | double amount, enum resize_edge edge) { | ||
735 | bool layout_match = true; | ||
736 | wlr_log(L_DEBUG, "Resizing %p with amount: %f", container, amount); | ||
737 | if (edge == RESIZE_EDGE_LEFT || edge == RESIZE_EDGE_RIGHT) { | ||
738 | container->width += amount; | ||
739 | layout_match = container->layout == L_HORIZ; | ||
740 | } else if (edge == RESIZE_EDGE_TOP || edge == RESIZE_EDGE_BOTTOM) { | ||
741 | container->height += amount; | ||
742 | layout_match = container->layout == L_VERT; | ||
743 | } | ||
744 | if (container->children) { | ||
745 | for (int i = 0; i < container->children->length; i++) { | ||
746 | struct sway_container *child = container->children->items[i]; | ||
747 | double amt = layout_match ? | ||
748 | amount / container->children->length : amount; | ||
749 | container_recursive_resize(child, amt, edge); | ||
750 | } | ||
751 | } | ||
752 | } | ||