diff options
author | wil <william.barsse@gmail.com> | 2016-12-29 20:26:35 +0100 |
---|---|---|
committer | wil <william.barsse@gmail.com> | 2016-12-29 20:31:30 +0100 |
commit | a0aa8d9780c6c8b0138800e3b2c2c0053174a2c5 (patch) | |
tree | c82dec85d4f5c9dbe0b93131f56614bccaa3a227 /sway/container.c | |
parent | [fix] move next/prev behavior for vert/horiz layout (diff) | |
download | sway-a0aa8d9780c6c8b0138800e3b2c2c0053174a2c5.tar.gz sway-a0aa8d9780c6c8b0138800e3b2c2c0053174a2c5.tar.zst sway-a0aa8d9780c6c8b0138800e3b2c2c0053174a2c5.zip |
cleanup in auto layouts
- added L_AUTO_FIRST/LAST instead of using explicit layouts.
- when switching between auto layout that don't share the same major axis, invert the
width/height of their child views to preserve their relative proportions.
Diffstat (limited to 'sway/container.c')
-rw-r--r-- | sway/container.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/sway/container.c b/sway/container.c index d034115f..3bdc8b6c 100644 --- a/sway/container.c +++ b/sway/container.c | |||
@@ -962,11 +962,28 @@ swayc_t *swayc_tabbed_stacked_parent(swayc_t *con) { | |||
962 | } | 962 | } |
963 | 963 | ||
964 | swayc_t *swayc_change_layout(swayc_t *container, enum swayc_layouts layout) { | 964 | swayc_t *swayc_change_layout(swayc_t *container, enum swayc_layouts layout) { |
965 | // if layout change modifies the auto layout's major axis, swap width and height | ||
966 | // to preserve current ratios. | ||
967 | if (is_auto_layout(layout) && is_auto_layout(container->layout)) { | ||
968 | enum swayc_layouts prev_major = (container->layout == L_AUTO_LEFT || | ||
969 | container->layout == L_AUTO_RIGHT) | ||
970 | ? L_HORIZ : L_VERT; | ||
971 | enum swayc_layouts new_major = (layout == L_AUTO_LEFT || layout == L_AUTO_RIGHT) | ||
972 | ? L_HORIZ : L_VERT; | ||
973 | if (new_major != prev_major) { | ||
974 | for (int i = 0; i < container->children->length; ++i) { | ||
975 | swayc_t *child = container->children->items[i]; | ||
976 | double h = child->height; | ||
977 | child->height = child->width; | ||
978 | child->width = h; | ||
979 | } | ||
980 | } | ||
981 | } | ||
965 | if (container->type == C_WORKSPACE) { | 982 | if (container->type == C_WORKSPACE) { |
966 | container->workspace_layout = layout; | 983 | container->workspace_layout = layout; |
967 | if (layout == L_HORIZ || layout == L_VERT) { | 984 | if (layout == L_HORIZ || layout == L_VERT || is_auto_layout(layout)) { |
968 | container->layout = layout; | 985 | container->layout = layout; |
969 | } | 986 | } |
970 | } else { | 987 | } else { |
971 | container->layout = layout; | 988 | container->layout = layout; |
972 | } | 989 | } |