diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-06-06 22:57:34 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-06-09 10:11:25 +1000 |
commit | bb66e6d578fdc68fb33d0fde921390d74f20bb31 (patch) | |
tree | 99d3763eee97acb870c16a762c0ee40af787c295 /sway/tree/arrange.c | |
parent | Make main properties be the pending state (diff) | |
download | sway-bb66e6d578fdc68fb33d0fde921390d74f20bb31.tar.gz sway-bb66e6d578fdc68fb33d0fde921390d74f20bb31.tar.zst sway-bb66e6d578fdc68fb33d0fde921390d74f20bb31.zip |
Refactor everything that needs to arrange windows
* The arrange_foo functions are now replaced with arrange_and_commit, or
with manually created transactions and arrange_windows x2.
* The arrange functions are now only called from the highest level
functions rather than from both high level and low level functions.
* Due to the previous point, view_set_fullscreen_raw and
view_set_fullscreen are both merged into one function again.
* Floating and fullscreen are now working with transactions.
Diffstat (limited to 'sway/tree/arrange.c')
-rw-r--r-- | sway/tree/arrange.c | 63 |
1 files changed, 33 insertions, 30 deletions
diff --git a/sway/tree/arrange.c b/sway/tree/arrange.c index cf7ce61c..e138410d 100644 --- a/sway/tree/arrange.c +++ b/sway/tree/arrange.c | |||
@@ -138,7 +138,23 @@ static void apply_tabbed_or_stacked_layout(struct sway_container *parent) { | |||
138 | } | 138 | } |
139 | } | 139 | } |
140 | 140 | ||
141 | static void _arrange_children_of(struct sway_container *parent, | 141 | static void arrange_children_of(struct sway_container *parent, |
142 | struct sway_transaction *transaction); | ||
143 | |||
144 | static void arrange_floating(struct sway_container *floating, | ||
145 | struct sway_transaction *transaction) { | ||
146 | for (int i = 0; i < floating->children->length; ++i) { | ||
147 | struct sway_container *floater = floating->children->items[i]; | ||
148 | if (floater->type == C_VIEW) { | ||
149 | view_autoconfigure(floater->sway_view); | ||
150 | } else { | ||
151 | arrange_children_of(floater, transaction); | ||
152 | } | ||
153 | transaction_add_container(transaction, floater); | ||
154 | } | ||
155 | } | ||
156 | |||
157 | static void arrange_children_of(struct sway_container *parent, | ||
142 | struct sway_transaction *transaction) { | 158 | struct sway_transaction *transaction) { |
143 | if (config->reloading) { | 159 | if (config->reloading) { |
144 | return; | 160 | return; |
@@ -162,7 +178,8 @@ static void _arrange_children_of(struct sway_container *parent, | |||
162 | apply_horiz_layout(parent); | 178 | apply_horiz_layout(parent); |
163 | break; | 179 | break; |
164 | case L_FLOATING: | 180 | case L_FLOATING: |
165 | sway_assert(false, "Didn't expect to see floating here"); | 181 | arrange_floating(parent, transaction); |
182 | break; | ||
166 | } | 183 | } |
167 | 184 | ||
168 | // Recurse into child containers | 185 | // Recurse into child containers |
@@ -171,13 +188,13 @@ static void _arrange_children_of(struct sway_container *parent, | |||
171 | if (child->type == C_VIEW) { | 188 | if (child->type == C_VIEW) { |
172 | view_autoconfigure(child->sway_view); | 189 | view_autoconfigure(child->sway_view); |
173 | } else { | 190 | } else { |
174 | _arrange_children_of(child, transaction); | 191 | arrange_children_of(child, transaction); |
175 | } | 192 | } |
176 | transaction_add_container(transaction, child); | 193 | transaction_add_container(transaction, child); |
177 | } | 194 | } |
178 | } | 195 | } |
179 | 196 | ||
180 | static void _arrange_workspace(struct sway_container *workspace, | 197 | static void arrange_workspace(struct sway_container *workspace, |
181 | struct sway_transaction *transaction) { | 198 | struct sway_transaction *transaction) { |
182 | if (config->reloading) { | 199 | if (config->reloading) { |
183 | return; | 200 | return; |
@@ -193,10 +210,11 @@ static void _arrange_workspace(struct sway_container *workspace, | |||
193 | transaction_add_container(transaction, workspace); | 210 | transaction_add_container(transaction, workspace); |
194 | wlr_log(L_DEBUG, "Arranging workspace '%s' at %f, %f", workspace->name, | 211 | wlr_log(L_DEBUG, "Arranging workspace '%s' at %f, %f", workspace->name, |
195 | workspace->x, workspace->y); | 212 | workspace->x, workspace->y); |
196 | _arrange_children_of(workspace, transaction); | 213 | arrange_floating(workspace->sway_workspace->floating, transaction); |
214 | arrange_children_of(workspace, transaction); | ||
197 | } | 215 | } |
198 | 216 | ||
199 | static void _arrange_output(struct sway_container *output, | 217 | static void arrange_output(struct sway_container *output, |
200 | struct sway_transaction *transaction) { | 218 | struct sway_transaction *transaction) { |
201 | if (config->reloading) { | 219 | if (config->reloading) { |
202 | return; | 220 | return; |
@@ -213,11 +231,11 @@ static void _arrange_output(struct sway_container *output, | |||
213 | output->name, output->x, output->y); | 231 | output->name, output->x, output->y); |
214 | for (int i = 0; i < output->children->length; ++i) { | 232 | for (int i = 0; i < output->children->length; ++i) { |
215 | struct sway_container *workspace = output->children->items[i]; | 233 | struct sway_container *workspace = output->children->items[i]; |
216 | _arrange_workspace(workspace, transaction); | 234 | arrange_workspace(workspace, transaction); |
217 | } | 235 | } |
218 | } | 236 | } |
219 | 237 | ||
220 | static void _arrange_root(struct sway_transaction *transaction) { | 238 | static void arrange_root(struct sway_transaction *transaction) { |
221 | if (config->reloading) { | 239 | if (config->reloading) { |
222 | return; | 240 | return; |
223 | } | 241 | } |
@@ -232,7 +250,7 @@ static void _arrange_root(struct sway_transaction *transaction) { | |||
232 | transaction_add_container(transaction, &root_container); | 250 | transaction_add_container(transaction, &root_container); |
233 | for (int i = 0; i < root_container.children->length; ++i) { | 251 | for (int i = 0; i < root_container.children->length; ++i) { |
234 | struct sway_container *output = root_container.children->items[i]; | 252 | struct sway_container *output = root_container.children->items[i]; |
235 | _arrange_output(output, transaction); | 253 | arrange_output(output, transaction); |
236 | } | 254 | } |
237 | } | 255 | } |
238 | 256 | ||
@@ -240,19 +258,21 @@ void arrange_windows(struct sway_container *container, | |||
240 | struct sway_transaction *transaction) { | 258 | struct sway_transaction *transaction) { |
241 | switch (container->type) { | 259 | switch (container->type) { |
242 | case C_ROOT: | 260 | case C_ROOT: |
243 | _arrange_root(transaction); | 261 | arrange_root(transaction); |
244 | break; | 262 | break; |
245 | case C_OUTPUT: | 263 | case C_OUTPUT: |
246 | _arrange_output(container, transaction); | 264 | arrange_output(container, transaction); |
247 | break; | 265 | break; |
248 | case C_WORKSPACE: | 266 | case C_WORKSPACE: |
249 | _arrange_workspace(container, transaction); | 267 | arrange_workspace(container, transaction); |
250 | break; | 268 | break; |
251 | case C_CONTAINER: | 269 | case C_CONTAINER: |
252 | _arrange_children_of(container, transaction); | 270 | arrange_children_of(container, transaction); |
253 | transaction_add_container(transaction, container); | 271 | transaction_add_container(transaction, container); |
254 | break; | 272 | break; |
255 | case C_VIEW: | 273 | case C_VIEW: |
274 | view_autoconfigure(container->sway_view); | ||
275 | transaction_add_container(transaction, container); | ||
256 | break; | 276 | break; |
257 | case C_TYPES: | 277 | case C_TYPES: |
258 | break; | 278 | break; |
@@ -265,20 +285,3 @@ void arrange_and_commit(struct sway_container *container) { | |||
265 | arrange_windows(container, transaction); | 285 | arrange_windows(container, transaction); |
266 | transaction_commit(transaction); | 286 | transaction_commit(transaction); |
267 | } | 287 | } |
268 | |||
269 | // These functions are only temporary | ||
270 | void arrange_root() { | ||
271 | arrange_and_commit(&root_container); | ||
272 | } | ||
273 | |||
274 | void arrange_output(struct sway_container *container) { | ||
275 | arrange_and_commit(container); | ||
276 | } | ||
277 | |||
278 | void arrange_workspace(struct sway_container *container) { | ||
279 | arrange_and_commit(container); | ||
280 | } | ||
281 | |||
282 | void arrange_children_of(struct sway_container *container) { | ||
283 | arrange_and_commit(container); | ||
284 | } | ||