diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-08-19 17:00:51 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-08-26 09:52:12 +1000 |
commit | 8bed4be1f387f9aa48910db1cf979cd847a9a2e3 (patch) | |
tree | 6bb0cd51d006de03535d4019d05c6787e8dd17aa /sway/tree/container.c | |
parent | Merge pull request #2512 from apreiml/workspace_move_wrap (diff) | |
download | sway-8bed4be1f387f9aa48910db1cf979cd847a9a2e3.tar.gz sway-8bed4be1f387f9aa48910db1cf979cd847a9a2e3.tar.zst sway-8bed4be1f387f9aa48910db1cf979cd847a9a2e3.zip |
Make separate gaps functions per container type
In preparation for using type safety.
Diffstat (limited to 'sway/tree/container.c')
-rw-r--r-- | sway/tree/container.c | 33 |
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) { | |||
1124 | } | 1124 | } |
1125 | } | 1125 | } |
1126 | 1126 | ||
1127 | void container_remove_gaps(struct sway_container *c) { | ||
1128 | if (!sway_assert(c->type == C_CONTAINER || c->type == C_VIEW, | ||
1129 | "Expected a container or view")) { | ||
1130 | return; | ||
1131 | } | ||
1132 | if (c->current_gaps == 0) { | ||
1133 | return; | ||
1134 | } | ||
1135 | |||
1136 | c->width += c->current_gaps * 2; | ||
1137 | c->height += c->current_gaps * 2; | ||
1138 | c->x -= c->current_gaps; | ||
1139 | c->y -= c->current_gaps; | ||
1140 | c->current_gaps = 0; | ||
1141 | } | ||
1142 | |||
1143 | void container_add_gaps(struct sway_container *c) { | ||
1144 | if (!sway_assert(c->type == C_CONTAINER || c->type == C_VIEW, | ||
1145 | "Expected a container or view")) { | ||
1146 | return; | ||
1147 | } | ||
1148 | if (c->current_gaps > 0 || c->type != C_VIEW) { | ||
1149 | return; | ||
1150 | } | ||
1151 | |||
1152 | c->current_gaps = c->has_gaps ? c->gaps_inner : config->gaps_inner; | ||
1153 | c->x += c->current_gaps; | ||
1154 | c->y += c->current_gaps; | ||
1155 | c->width -= 2 * c->current_gaps; | ||
1156 | c->height -= 2 * c->current_gaps; | ||
1157 | } | ||
1158 | |||
1127 | int container_sibling_index(const struct sway_container *child) { | 1159 | int container_sibling_index(const struct sway_container *child) { |
1128 | return list_find(child->parent->children, child); | 1160 | return list_find(child->parent->children, child); |
1129 | } | 1161 | } |
1130 | |||