diff options
Diffstat (limited to 'sway/tree')
-rw-r--r-- | sway/tree/arrange.c | 63 | ||||
-rw-r--r-- | sway/tree/container.c | 10 | ||||
-rw-r--r-- | sway/tree/layout.c | 71 | ||||
-rw-r--r-- | sway/tree/view.c | 49 | ||||
-rw-r--r-- | sway/tree/workspace.c | 2 |
5 files changed, 74 insertions, 121 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 | } | ||
diff --git a/sway/tree/container.c b/sway/tree/container.c index e6956f5c..d312eb60 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -204,6 +204,7 @@ static struct sway_container *container_workspace_destroy( | |||
204 | container_move_to(floating->children->items[i], | 204 | container_move_to(floating->children->items[i], |
205 | new_workspace->sway_workspace->floating); | 205 | new_workspace->sway_workspace->floating); |
206 | } | 206 | } |
207 | arrange_and_commit(new_workspace); | ||
207 | } | 208 | } |
208 | 209 | ||
209 | struct sway_workspace *sway_workspace = workspace->sway_workspace; | 210 | struct sway_workspace *sway_workspace = workspace->sway_workspace; |
@@ -264,10 +265,10 @@ static struct sway_container *container_output_destroy( | |||
264 | } | 265 | } |
265 | 266 | ||
266 | container_sort_workspaces(new_output); | 267 | container_sort_workspaces(new_output); |
267 | arrange_output(new_output); | ||
268 | } | 268 | } |
269 | } | 269 | } |
270 | } | 270 | } |
271 | arrange_and_commit(&root_container); | ||
271 | 272 | ||
272 | wl_list_remove(&output->sway_output->mode.link); | 273 | wl_list_remove(&output->sway_output->mode.link); |
273 | wl_list_remove(&output->sway_output->transform.link); | 274 | wl_list_remove(&output->sway_output->transform.link); |
@@ -924,13 +925,12 @@ void container_set_floating(struct sway_container *container, bool enable) { | |||
924 | 925 | ||
925 | struct sway_container *workspace = container_parent(container, C_WORKSPACE); | 926 | struct sway_container *workspace = container_parent(container, C_WORKSPACE); |
926 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 927 | struct sway_seat *seat = input_manager_current_seat(input_manager); |
927 | container_damage_whole(container); | ||
928 | 928 | ||
929 | if (enable) { | 929 | if (enable) { |
930 | container_remove_child(container); | 930 | container_remove_child(container); |
931 | container_add_child(workspace->sway_workspace->floating, container); | 931 | container_add_child(workspace->sway_workspace->floating, container); |
932 | if (container->type == C_VIEW) { | 932 | if (container->type == C_VIEW) { |
933 | view_autoconfigure(container->sway_view); | 933 | view_init_floating(container->sway_view); |
934 | } | 934 | } |
935 | seat_set_focus(seat, seat_get_focus_inactive(seat, container)); | 935 | seat_set_focus(seat, seat_get_focus_inactive(seat, container)); |
936 | container_reap_empty_recursive(workspace); | 936 | container_reap_empty_recursive(workspace); |
@@ -943,8 +943,8 @@ void container_set_floating(struct sway_container *container, bool enable) { | |||
943 | container->is_sticky = false; | 943 | container->is_sticky = false; |
944 | container_reap_empty_recursive(workspace->sway_workspace->floating); | 944 | container_reap_empty_recursive(workspace->sway_workspace->floating); |
945 | } | 945 | } |
946 | arrange_workspace(workspace); | 946 | |
947 | container_damage_whole(container); | 947 | ipc_event_window(container, "floating"); |
948 | } | 948 | } |
949 | 949 | ||
950 | void container_set_geometry_from_floating_view(struct sway_container *con) { | 950 | void container_set_geometry_from_floating_view(struct sway_container *con) { |
diff --git a/sway/tree/layout.c b/sway/tree/layout.c index 6d4cd088..65b61495 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c | |||
@@ -22,7 +22,7 @@ struct sway_container root_container; | |||
22 | 22 | ||
23 | static void output_layout_handle_change(struct wl_listener *listener, | 23 | static void output_layout_handle_change(struct wl_listener *listener, |
24 | void *data) { | 24 | void *data) { |
25 | arrange_root(); | 25 | arrange_and_commit(&root_container); |
26 | } | 26 | } |
27 | 27 | ||
28 | void layout_init(void) { | 28 | void layout_init(void) { |
@@ -56,18 +56,17 @@ static int index_child(const struct sway_container *child) { | |||
56 | return -1; | 56 | return -1; |
57 | } | 57 | } |
58 | 58 | ||
59 | static void container_handle_fullscreen_reparent(struct sway_container *viewcon, | 59 | static void container_handle_fullscreen_reparent(struct sway_container *con, |
60 | struct sway_container *old_parent) { | 60 | struct sway_container *old_parent) { |
61 | if (viewcon->type != C_VIEW || !viewcon->sway_view->is_fullscreen) { | 61 | if (con->type != C_VIEW || !con->sway_view->is_fullscreen) { |
62 | return; | 62 | return; |
63 | } | 63 | } |
64 | struct sway_view *view = viewcon->sway_view; | 64 | struct sway_view *view = con->sway_view; |
65 | struct sway_container *old_workspace = old_parent; | 65 | struct sway_container *old_workspace = old_parent; |
66 | if (old_workspace && old_workspace->type != C_WORKSPACE) { | 66 | if (old_workspace && old_workspace->type != C_WORKSPACE) { |
67 | old_workspace = container_parent(old_workspace, C_WORKSPACE); | 67 | old_workspace = container_parent(old_workspace, C_WORKSPACE); |
68 | } | 68 | } |
69 | struct sway_container *new_workspace = container_parent(view->swayc, | 69 | struct sway_container *new_workspace = container_parent(con, C_WORKSPACE); |
70 | C_WORKSPACE); | ||
71 | if (old_workspace == new_workspace) { | 70 | if (old_workspace == new_workspace) { |
72 | return; | 71 | return; |
73 | } | 72 | } |
@@ -78,15 +77,19 @@ static void container_handle_fullscreen_reparent(struct sway_container *viewcon, | |||
78 | 77 | ||
79 | // Mark the new workspace as fullscreen | 78 | // Mark the new workspace as fullscreen |
80 | if (new_workspace->sway_workspace->fullscreen) { | 79 | if (new_workspace->sway_workspace->fullscreen) { |
81 | view_set_fullscreen_raw( | 80 | view_set_fullscreen(new_workspace->sway_workspace->fullscreen, false); |
82 | new_workspace->sway_workspace->fullscreen, false); | ||
83 | } | 81 | } |
84 | new_workspace->sway_workspace->fullscreen = view; | 82 | new_workspace->sway_workspace->fullscreen = view; |
85 | // Resize view to new output dimensions | 83 | // Resize view to new output dimensions |
86 | struct sway_container *output = new_workspace->parent; | 84 | struct sway_container *output = new_workspace->parent; |
87 | view_configure(view, 0, 0, output->width, output->height); | 85 | view->x = output->x; |
88 | view->swayc->width = output->width; | 86 | view->y = output->y; |
89 | view->swayc->height = output->height; | 87 | view->width = output->width; |
88 | view->height = output->height; | ||
89 | con->x = output->x; | ||
90 | con->y = output->y; | ||
91 | con->width = output->width; | ||
92 | con->height = output->height; | ||
90 | } | 93 | } |
91 | 94 | ||
92 | void container_insert_child(struct sway_container *parent, | 95 | void container_insert_child(struct sway_container *parent, |
@@ -188,18 +191,7 @@ void container_move_to(struct sway_container *container, | |||
188 | } | 191 | } |
189 | container_notify_subtree_changed(old_parent); | 192 | container_notify_subtree_changed(old_parent); |
190 | container_notify_subtree_changed(new_parent); | 193 | container_notify_subtree_changed(new_parent); |
191 | if (old_parent) { | 194 | |
192 | if (old_parent->type == C_OUTPUT) { | ||
193 | arrange_output(old_parent); | ||
194 | } else { | ||
195 | arrange_children_of(old_parent); | ||
196 | } | ||
197 | } | ||
198 | if (new_parent->type == C_OUTPUT) { | ||
199 | arrange_output(new_parent); | ||
200 | } else { | ||
201 | arrange_children_of(new_parent); | ||
202 | } | ||
203 | // If view was moved to a fullscreen workspace, refocus the fullscreen view | 195 | // If view was moved to a fullscreen workspace, refocus the fullscreen view |
204 | struct sway_container *new_workspace = container; | 196 | struct sway_container *new_workspace = container; |
205 | if (new_workspace->type != C_WORKSPACE) { | 197 | if (new_workspace->type != C_WORKSPACE) { |
@@ -214,7 +206,8 @@ void container_move_to(struct sway_container *container, | |||
214 | if (focus_ws->type != C_WORKSPACE) { | 206 | if (focus_ws->type != C_WORKSPACE) { |
215 | focus_ws = container_parent(focus_ws, C_WORKSPACE); | 207 | focus_ws = container_parent(focus_ws, C_WORKSPACE); |
216 | } | 208 | } |
217 | seat_set_focus(seat, new_workspace->sway_workspace->fullscreen->swayc); | 209 | seat_set_focus(seat, |
210 | new_workspace->sway_workspace->fullscreen->swayc); | ||
218 | if (focus_ws != new_workspace) { | 211 | if (focus_ws != new_workspace) { |
219 | seat_set_focus(seat, focus); | 212 | seat_set_focus(seat, focus); |
220 | } | 213 | } |
@@ -308,7 +301,6 @@ static void workspace_rejigger(struct sway_container *ws, | |||
308 | container_reap_empty_recursive(original_parent); | 301 | container_reap_empty_recursive(original_parent); |
309 | wl_signal_emit(&child->events.reparent, original_parent); | 302 | wl_signal_emit(&child->events.reparent, original_parent); |
310 | container_create_notify(new_parent); | 303 | container_create_notify(new_parent); |
311 | arrange_workspace(ws); | ||
312 | } | 304 | } |
313 | 305 | ||
314 | static void move_out_of_tabs_stacks(struct sway_container *container, | 306 | static void move_out_of_tabs_stacks(struct sway_container *container, |
@@ -319,11 +311,6 @@ static void move_out_of_tabs_stacks(struct sway_container *container, | |||
319 | wlr_log(L_DEBUG, "Changing layout of %zd", current->parent->id); | 311 | wlr_log(L_DEBUG, "Changing layout of %zd", current->parent->id); |
320 | current->parent->layout = move_dir == | 312 | current->parent->layout = move_dir == |
321 | MOVE_LEFT || move_dir == MOVE_RIGHT ? L_HORIZ : L_VERT; | 313 | MOVE_LEFT || move_dir == MOVE_RIGHT ? L_HORIZ : L_VERT; |
322 | if (current->parent->type == C_WORKSPACE) { | ||
323 | arrange_workspace(current->parent); | ||
324 | } else { | ||
325 | arrange_children_of(current->parent); | ||
326 | } | ||
327 | return; | 314 | return; |
328 | } | 315 | } |
329 | 316 | ||
@@ -339,11 +326,6 @@ static void move_out_of_tabs_stacks(struct sway_container *container, | |||
339 | container_flatten(new_parent->parent); | 326 | container_flatten(new_parent->parent); |
340 | } | 327 | } |
341 | container_create_notify(new_parent); | 328 | container_create_notify(new_parent); |
342 | if (is_workspace) { | ||
343 | arrange_workspace(new_parent->parent); | ||
344 | } else { | ||
345 | arrange_children_of(new_parent); | ||
346 | } | ||
347 | container_notify_subtree_changed(new_parent); | 329 | container_notify_subtree_changed(new_parent); |
348 | } | 330 | } |
349 | 331 | ||
@@ -367,10 +349,7 @@ void container_move(struct sway_container *container, | |||
367 | 349 | ||
368 | struct sway_container *new_parent = container_flatten(parent); | 350 | struct sway_container *new_parent = container_flatten(parent); |
369 | if (new_parent != parent) { | 351 | if (new_parent != parent) { |
370 | // Special case: we were the last one in this container, so flatten it | 352 | // Special case: we were the last one in this container, so leave |
371 | // and leave | ||
372 | arrange_children_of(new_parent); | ||
373 | update_debug_tree(); | ||
374 | return; | 353 | return; |
375 | } | 354 | } |
376 | 355 | ||
@@ -452,12 +431,9 @@ void container_move(struct sway_container *container, | |||
452 | wlr_log(L_DEBUG, "Hit limit, " | 431 | wlr_log(L_DEBUG, "Hit limit, " |
453 | "promoting descendant to sibling"); | 432 | "promoting descendant to sibling"); |
454 | // Special case | 433 | // Special case |
455 | struct sway_container *old_parent = container->parent; | ||
456 | container_insert_child(current->parent, container, | 434 | container_insert_child(current->parent, container, |
457 | index + (offs < 0 ? 0 : 1)); | 435 | index + (offs < 0 ? 0 : 1)); |
458 | container->width = container->height = 0; | 436 | container->width = container->height = 0; |
459 | arrange_children_of(current->parent); | ||
460 | arrange_children_of(old_parent); | ||
461 | return; | 437 | return; |
462 | } | 438 | } |
463 | } else { | 439 | } else { |
@@ -491,14 +467,11 @@ void container_move(struct sway_container *container, | |||
491 | wlr_log(L_DEBUG, "Swapping siblings"); | 467 | wlr_log(L_DEBUG, "Swapping siblings"); |
492 | sibling->parent->children->items[index + offs] = container; | 468 | sibling->parent->children->items[index + offs] = container; |
493 | sibling->parent->children->items[index] = sibling; | 469 | sibling->parent->children->items[index] = sibling; |
494 | arrange_children_of(sibling->parent); | ||
495 | } else { | 470 | } else { |
496 | wlr_log(L_DEBUG, "Promoting to sibling of cousin"); | 471 | wlr_log(L_DEBUG, "Promoting to sibling of cousin"); |
497 | container_insert_child(sibling->parent, container, | 472 | container_insert_child(sibling->parent, container, |
498 | index_child(sibling) + (offs > 0 ? 0 : 1)); | 473 | index_child(sibling) + (offs > 0 ? 0 : 1)); |
499 | container->width = container->height = 0; | 474 | container->width = container->height = 0; |
500 | arrange_children_of(sibling->parent); | ||
501 | arrange_children_of(old_parent); | ||
502 | } | 475 | } |
503 | sibling = NULL; | 476 | sibling = NULL; |
504 | break; | 477 | break; |
@@ -512,8 +485,6 @@ void container_move(struct sway_container *container, | |||
512 | "(move dir: %d)", limit, move_dir); | 485 | "(move dir: %d)", limit, move_dir); |
513 | container_insert_child(sibling, container, limit); | 486 | container_insert_child(sibling, container, limit); |
514 | container->width = container->height = 0; | 487 | container->width = container->height = 0; |
515 | arrange_children_of(sibling); | ||
516 | arrange_children_of(old_parent); | ||
517 | sibling = NULL; | 488 | sibling = NULL; |
518 | } else { | 489 | } else { |
519 | wlr_log(L_DEBUG, "Reparenting container (perpendicular)"); | 490 | wlr_log(L_DEBUG, "Reparenting container (perpendicular)"); |
@@ -537,8 +508,6 @@ void container_move(struct sway_container *container, | |||
537 | container_add_child(sibling, container); | 508 | container_add_child(sibling, container); |
538 | } | 509 | } |
539 | container->width = container->height = 0; | 510 | container->width = container->height = 0; |
540 | arrange_children_of(sibling); | ||
541 | arrange_children_of(old_parent); | ||
542 | sibling = NULL; | 511 | sibling = NULL; |
543 | } | 512 | } |
544 | break; | 513 | break; |
@@ -863,7 +832,6 @@ struct sway_container *container_split(struct sway_container *child, | |||
863 | // Special case: this just behaves like splitt | 832 | // Special case: this just behaves like splitt |
864 | child->prev_layout = child->layout; | 833 | child->prev_layout = child->layout; |
865 | child->layout = layout; | 834 | child->layout = layout; |
866 | arrange_children_of(child); | ||
867 | return child; | 835 | return child; |
868 | } | 836 | } |
869 | 837 | ||
@@ -1044,9 +1012,6 @@ void container_swap(struct sway_container *con1, struct sway_container *con2) { | |||
1044 | prev_workspace_name = stored_prev_name; | 1012 | prev_workspace_name = stored_prev_name; |
1045 | } | 1013 | } |
1046 | 1014 | ||
1047 | arrange_children_of(con1->parent); | ||
1048 | arrange_children_of(con2->parent); | ||
1049 | |||
1050 | if (fs1 && con2->type == C_VIEW) { | 1015 | if (fs1 && con2->type == C_VIEW) { |
1051 | view_set_fullscreen(con2->sway_view, true); | 1016 | view_set_fullscreen(con2->sway_view, true); |
1052 | } | 1017 | } |
diff --git a/sway/tree/view.c b/sway/tree/view.c index dbf803c6..658a94e8 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c | |||
@@ -135,22 +135,22 @@ uint32_t view_configure(struct sway_view *view, double lx, double ly, int width, | |||
135 | return 0; | 135 | return 0; |
136 | } | 136 | } |
137 | 137 | ||
138 | static void view_autoconfigure_floating(struct sway_view *view) { | 138 | void view_init_floating(struct sway_view *view) { |
139 | struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE); | 139 | struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE); |
140 | int max_width = ws->width * 0.6666; | 140 | int max_width = ws->width * 0.6666; |
141 | int max_height = ws->height * 0.6666; | 141 | int max_height = ws->height * 0.6666; |
142 | int width = | 142 | view->width = |
143 | view->natural_width > max_width ? max_width : view->natural_width; | 143 | view->natural_width > max_width ? max_width : view->natural_width; |
144 | int height = | 144 | view->height = |
145 | view->natural_height > max_height ? max_height : view->natural_height; | 145 | view->natural_height > max_height ? max_height : view->natural_height; |
146 | int lx = ws->x + (ws->width - width) / 2; | 146 | view->x = ws->x + (ws->width - view->width) / 2; |
147 | int ly = ws->y + (ws->height - height) / 2; | 147 | view->y = ws->y + (ws->height - view->height) / 2; |
148 | 148 | ||
149 | // If the view's border is B_NONE then these properties are ignored. | 149 | // If the view's border is B_NONE then these properties are ignored. |
150 | view->border_top = view->border_bottom = true; | 150 | view->border_top = view->border_bottom = true; |
151 | view->border_left = view->border_right = true; | 151 | view->border_left = view->border_right = true; |
152 | 152 | ||
153 | view_configure(view, lx, ly, width, height); | 153 | container_set_geometry_from_floating_view(view->swayc); |
154 | } | 154 | } |
155 | 155 | ||
156 | void view_autoconfigure(struct sway_view *view) { | 156 | void view_autoconfigure(struct sway_view *view) { |
@@ -162,12 +162,14 @@ void view_autoconfigure(struct sway_view *view) { | |||
162 | struct sway_container *output = container_parent(view->swayc, C_OUTPUT); | 162 | struct sway_container *output = container_parent(view->swayc, C_OUTPUT); |
163 | 163 | ||
164 | if (view->is_fullscreen) { | 164 | if (view->is_fullscreen) { |
165 | view_configure(view, output->x, output->y, output->width, output->height); | 165 | view->x = output->x; |
166 | view->y = output->y; | ||
167 | view->width = output->width; | ||
168 | view->height = output->height; | ||
166 | return; | 169 | return; |
167 | } | 170 | } |
168 | 171 | ||
169 | if (container_is_floating(view->swayc)) { | 172 | if (container_is_floating(view->swayc)) { |
170 | view_autoconfigure_floating(view); | ||
171 | return; | 173 | return; |
172 | } | 174 | } |
173 | 175 | ||
@@ -268,8 +270,7 @@ void view_set_activated(struct sway_view *view, bool activated) { | |||
268 | } | 270 | } |
269 | } | 271 | } |
270 | 272 | ||
271 | // Set fullscreen, but without IPC events or arranging windows. | 273 | void view_set_fullscreen(struct sway_view *view, bool fullscreen) { |
272 | void view_set_fullscreen_raw(struct sway_view *view, bool fullscreen) { | ||
273 | if (view->is_fullscreen == fullscreen) { | 274 | if (view->is_fullscreen == fullscreen) { |
274 | return; | 275 | return; |
275 | } | 276 | } |
@@ -315,26 +316,17 @@ void view_set_fullscreen_raw(struct sway_view *view, bool fullscreen) { | |||
315 | } else { | 316 | } else { |
316 | workspace->sway_workspace->fullscreen = NULL; | 317 | workspace->sway_workspace->fullscreen = NULL; |
317 | if (container_is_floating(view->swayc)) { | 318 | if (container_is_floating(view->swayc)) { |
318 | view_configure(view, view->saved_x, view->saved_y, | 319 | view->x = view->saved_x; |
319 | view->saved_width, view->saved_height); | 320 | view->y = view->saved_y; |
321 | view->width = view->saved_width; | ||
322 | view->height = view->saved_height; | ||
323 | container_set_geometry_from_floating_view(view->swayc); | ||
320 | } else { | 324 | } else { |
321 | view->swayc->width = view->swayc->saved_width; | 325 | view->swayc->width = view->swayc->saved_width; |
322 | view->swayc->height = view->swayc->saved_height; | 326 | view->swayc->height = view->swayc->saved_height; |
323 | } | 327 | } |
324 | } | 328 | } |
325 | } | ||
326 | |||
327 | void view_set_fullscreen(struct sway_view *view, bool fullscreen) { | ||
328 | if (view->is_fullscreen == fullscreen) { | ||
329 | return; | ||
330 | } | ||
331 | 329 | ||
332 | view_set_fullscreen_raw(view, fullscreen); | ||
333 | |||
334 | struct sway_container *workspace = | ||
335 | container_parent(view->swayc, C_WORKSPACE); | ||
336 | arrange_workspace(workspace); | ||
337 | output_damage_whole(workspace->parent->sway_output); | ||
338 | ipc_event_window(view->swayc, "fullscreen_mode"); | 330 | ipc_event_window(view->swayc, "fullscreen_mode"); |
339 | } | 331 | } |
340 | 332 | ||
@@ -517,8 +509,6 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) { | |||
517 | 509 | ||
518 | if (view->impl->wants_floating && view->impl->wants_floating(view)) { | 510 | if (view->impl->wants_floating && view->impl->wants_floating(view)) { |
519 | container_set_floating(view->swayc, true); | 511 | container_set_floating(view->swayc, true); |
520 | } else { | ||
521 | arrange_children_of(cont->parent); | ||
522 | } | 512 | } |
523 | 513 | ||
524 | input_manager_set_focus(input_manager, cont); | 514 | input_manager_set_focus(input_manager, cont); |
@@ -530,7 +520,6 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) { | |||
530 | container_notify_subtree_changed(view->swayc->parent); | 520 | container_notify_subtree_changed(view->swayc->parent); |
531 | view_execute_criteria(view); | 521 | view_execute_criteria(view); |
532 | 522 | ||
533 | container_damage_whole(cont); | ||
534 | view_handle_container_reparent(&view->container_reparent, NULL); | 523 | view_handle_container_reparent(&view->container_reparent, NULL); |
535 | } | 524 | } |
536 | 525 | ||
@@ -561,11 +550,7 @@ void view_unmap(struct sway_view *view) { | |||
561 | view->title_format = NULL; | 550 | view->title_format = NULL; |
562 | } | 551 | } |
563 | 552 | ||
564 | if (parent->type == C_OUTPUT) { | 553 | arrange_and_commit(parent); |
565 | arrange_output(parent); | ||
566 | } else { | ||
567 | arrange_children_of(parent); | ||
568 | } | ||
569 | } | 554 | } |
570 | 555 | ||
571 | void view_update_position(struct sway_view *view, double lx, double ly) { | 556 | void view_update_position(struct sway_view *view, double lx, double ly) { |
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index 9ba210fd..ead752ad 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c | |||
@@ -425,7 +425,7 @@ bool workspace_switch(struct sway_container *workspace) { | |||
425 | } | 425 | } |
426 | seat_set_focus(seat, next); | 426 | seat_set_focus(seat, next); |
427 | struct sway_container *output = container_parent(workspace, C_OUTPUT); | 427 | struct sway_container *output = container_parent(workspace, C_OUTPUT); |
428 | arrange_output(output); | 428 | arrange_and_commit(output); |
429 | return true; | 429 | return true; |
430 | } | 430 | } |
431 | 431 | ||