diff options
Diffstat (limited to 'sway/tree/layout.c')
-rw-r--r-- | sway/tree/layout.c | 76 |
1 files changed, 21 insertions, 55 deletions
diff --git a/sway/tree/layout.c b/sway/tree/layout.c index d1ad044d..14631ad4 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) { |
@@ -30,7 +30,9 @@ void layout_init(void) { | |||
30 | root_container.type = C_ROOT; | 30 | root_container.type = C_ROOT; |
31 | root_container.layout = L_NONE; | 31 | root_container.layout = L_NONE; |
32 | root_container.name = strdup("root"); | 32 | root_container.name = strdup("root"); |
33 | root_container.instructions = create_list(); | ||
33 | root_container.children = create_list(); | 34 | root_container.children = create_list(); |
35 | root_container.current.children = create_list(); | ||
34 | wl_signal_init(&root_container.events.destroy); | 36 | wl_signal_init(&root_container.events.destroy); |
35 | 37 | ||
36 | root_container.sway_root = calloc(1, sizeof(*root_container.sway_root)); | 38 | root_container.sway_root = calloc(1, sizeof(*root_container.sway_root)); |
@@ -57,18 +59,17 @@ static int index_child(const struct sway_container *child) { | |||
57 | return -1; | 59 | return -1; |
58 | } | 60 | } |
59 | 61 | ||
60 | static void container_handle_fullscreen_reparent(struct sway_container *viewcon, | 62 | static void container_handle_fullscreen_reparent(struct sway_container *con, |
61 | struct sway_container *old_parent) { | 63 | struct sway_container *old_parent) { |
62 | if (viewcon->type != C_VIEW || !viewcon->sway_view->is_fullscreen) { | 64 | if (con->type != C_VIEW || !con->sway_view->is_fullscreen) { |
63 | return; | 65 | return; |
64 | } | 66 | } |
65 | struct sway_view *view = viewcon->sway_view; | 67 | struct sway_view *view = con->sway_view; |
66 | struct sway_container *old_workspace = old_parent; | 68 | struct sway_container *old_workspace = old_parent; |
67 | if (old_workspace && old_workspace->type != C_WORKSPACE) { | 69 | if (old_workspace && old_workspace->type != C_WORKSPACE) { |
68 | old_workspace = container_parent(old_workspace, C_WORKSPACE); | 70 | old_workspace = container_parent(old_workspace, C_WORKSPACE); |
69 | } | 71 | } |
70 | struct sway_container *new_workspace = container_parent(view->swayc, | 72 | struct sway_container *new_workspace = container_parent(con, C_WORKSPACE); |
71 | C_WORKSPACE); | ||
72 | if (old_workspace == new_workspace) { | 73 | if (old_workspace == new_workspace) { |
73 | return; | 74 | return; |
74 | } | 75 | } |
@@ -79,15 +80,19 @@ static void container_handle_fullscreen_reparent(struct sway_container *viewcon, | |||
79 | 80 | ||
80 | // Mark the new workspace as fullscreen | 81 | // Mark the new workspace as fullscreen |
81 | if (new_workspace->sway_workspace->fullscreen) { | 82 | if (new_workspace->sway_workspace->fullscreen) { |
82 | view_set_fullscreen_raw( | 83 | view_set_fullscreen(new_workspace->sway_workspace->fullscreen, false); |
83 | new_workspace->sway_workspace->fullscreen, false); | ||
84 | } | 84 | } |
85 | new_workspace->sway_workspace->fullscreen = view; | 85 | new_workspace->sway_workspace->fullscreen = view; |
86 | // Resize view to new output dimensions | 86 | // Resize view to new output dimensions |
87 | struct sway_container *output = new_workspace->parent; | 87 | struct sway_container *output = new_workspace->parent; |
88 | view_configure(view, 0, 0, output->width, output->height); | 88 | view->x = output->x; |
89 | view->swayc->width = output->width; | 89 | view->y = output->y; |
90 | view->swayc->height = output->height; | 90 | view->width = output->width; |
91 | view->height = output->height; | ||
92 | con->x = output->x; | ||
93 | con->y = output->y; | ||
94 | con->width = output->width; | ||
95 | con->height = output->height; | ||
91 | } | 96 | } |
92 | 97 | ||
93 | void container_insert_child(struct sway_container *parent, | 98 | void container_insert_child(struct sway_container *parent, |
@@ -189,18 +194,7 @@ void container_move_to(struct sway_container *container, | |||
189 | } | 194 | } |
190 | container_notify_subtree_changed(old_parent); | 195 | container_notify_subtree_changed(old_parent); |
191 | container_notify_subtree_changed(new_parent); | 196 | container_notify_subtree_changed(new_parent); |
192 | if (old_parent) { | 197 | |
193 | if (old_parent->type == C_OUTPUT) { | ||
194 | arrange_output(old_parent); | ||
195 | } else { | ||
196 | arrange_children_of(old_parent); | ||
197 | } | ||
198 | } | ||
199 | if (new_parent->type == C_OUTPUT) { | ||
200 | arrange_output(new_parent); | ||
201 | } else { | ||
202 | arrange_children_of(new_parent); | ||
203 | } | ||
204 | // If view was moved to a fullscreen workspace, refocus the fullscreen view | 198 | // If view was moved to a fullscreen workspace, refocus the fullscreen view |
205 | struct sway_container *new_workspace = container; | 199 | struct sway_container *new_workspace = container; |
206 | if (new_workspace->type != C_WORKSPACE) { | 200 | if (new_workspace->type != C_WORKSPACE) { |
@@ -215,7 +209,8 @@ void container_move_to(struct sway_container *container, | |||
215 | if (focus_ws->type != C_WORKSPACE) { | 209 | if (focus_ws->type != C_WORKSPACE) { |
216 | focus_ws = container_parent(focus_ws, C_WORKSPACE); | 210 | focus_ws = container_parent(focus_ws, C_WORKSPACE); |
217 | } | 211 | } |
218 | seat_set_focus(seat, new_workspace->sway_workspace->fullscreen->swayc); | 212 | seat_set_focus(seat, |
213 | new_workspace->sway_workspace->fullscreen->swayc); | ||
219 | if (focus_ws != new_workspace) { | 214 | if (focus_ws != new_workspace) { |
220 | seat_set_focus(seat, focus); | 215 | seat_set_focus(seat, focus); |
221 | } | 216 | } |
@@ -309,7 +304,6 @@ static void workspace_rejigger(struct sway_container *ws, | |||
309 | container_reap_empty_recursive(original_parent); | 304 | container_reap_empty_recursive(original_parent); |
310 | wl_signal_emit(&child->events.reparent, original_parent); | 305 | wl_signal_emit(&child->events.reparent, original_parent); |
311 | container_create_notify(new_parent); | 306 | container_create_notify(new_parent); |
312 | arrange_workspace(ws); | ||
313 | } | 307 | } |
314 | 308 | ||
315 | static void move_out_of_tabs_stacks(struct sway_container *container, | 309 | static void move_out_of_tabs_stacks(struct sway_container *container, |
@@ -320,11 +314,6 @@ static void move_out_of_tabs_stacks(struct sway_container *container, | |||
320 | wlr_log(L_DEBUG, "Changing layout of %zd", current->parent->id); | 314 | wlr_log(L_DEBUG, "Changing layout of %zd", current->parent->id); |
321 | current->parent->layout = move_dir == | 315 | current->parent->layout = move_dir == |
322 | MOVE_LEFT || move_dir == MOVE_RIGHT ? L_HORIZ : L_VERT; | 316 | MOVE_LEFT || move_dir == MOVE_RIGHT ? L_HORIZ : L_VERT; |
323 | if (current->parent->type == C_WORKSPACE) { | ||
324 | arrange_workspace(current->parent); | ||
325 | } else { | ||
326 | arrange_children_of(current->parent); | ||
327 | } | ||
328 | return; | 317 | return; |
329 | } | 318 | } |
330 | 319 | ||
@@ -340,11 +329,6 @@ static void move_out_of_tabs_stacks(struct sway_container *container, | |||
340 | container_flatten(new_parent->parent); | 329 | container_flatten(new_parent->parent); |
341 | } | 330 | } |
342 | container_create_notify(new_parent); | 331 | container_create_notify(new_parent); |
343 | if (is_workspace) { | ||
344 | arrange_workspace(new_parent->parent); | ||
345 | } else { | ||
346 | arrange_children_of(new_parent); | ||
347 | } | ||
348 | container_notify_subtree_changed(new_parent); | 332 | container_notify_subtree_changed(new_parent); |
349 | } | 333 | } |
350 | 334 | ||
@@ -368,10 +352,7 @@ void container_move(struct sway_container *container, | |||
368 | 352 | ||
369 | struct sway_container *new_parent = container_flatten(parent); | 353 | struct sway_container *new_parent = container_flatten(parent); |
370 | if (new_parent != parent) { | 354 | if (new_parent != parent) { |
371 | // Special case: we were the last one in this container, so flatten it | 355 | // Special case: we were the last one in this container, so leave |
372 | // and leave | ||
373 | arrange_children_of(new_parent); | ||
374 | update_debug_tree(); | ||
375 | return; | 356 | return; |
376 | } | 357 | } |
377 | 358 | ||
@@ -453,12 +434,9 @@ void container_move(struct sway_container *container, | |||
453 | wlr_log(L_DEBUG, "Hit limit, " | 434 | wlr_log(L_DEBUG, "Hit limit, " |
454 | "promoting descendant to sibling"); | 435 | "promoting descendant to sibling"); |
455 | // Special case | 436 | // Special case |
456 | struct sway_container *old_parent = container->parent; | ||
457 | container_insert_child(current->parent, container, | 437 | container_insert_child(current->parent, container, |
458 | index + (offs < 0 ? 0 : 1)); | 438 | index + (offs < 0 ? 0 : 1)); |
459 | container->width = container->height = 0; | 439 | container->width = container->height = 0; |
460 | arrange_children_of(current->parent); | ||
461 | arrange_children_of(old_parent); | ||
462 | return; | 440 | return; |
463 | } | 441 | } |
464 | } else { | 442 | } else { |
@@ -492,14 +470,11 @@ void container_move(struct sway_container *container, | |||
492 | wlr_log(L_DEBUG, "Swapping siblings"); | 470 | wlr_log(L_DEBUG, "Swapping siblings"); |
493 | sibling->parent->children->items[index + offs] = container; | 471 | sibling->parent->children->items[index + offs] = container; |
494 | sibling->parent->children->items[index] = sibling; | 472 | sibling->parent->children->items[index] = sibling; |
495 | arrange_children_of(sibling->parent); | ||
496 | } else { | 473 | } else { |
497 | wlr_log(L_DEBUG, "Promoting to sibling of cousin"); | 474 | wlr_log(L_DEBUG, "Promoting to sibling of cousin"); |
498 | container_insert_child(sibling->parent, container, | 475 | container_insert_child(sibling->parent, container, |
499 | index_child(sibling) + (offs > 0 ? 0 : 1)); | 476 | index_child(sibling) + (offs > 0 ? 0 : 1)); |
500 | container->width = container->height = 0; | 477 | container->width = container->height = 0; |
501 | arrange_children_of(sibling->parent); | ||
502 | arrange_children_of(old_parent); | ||
503 | } | 478 | } |
504 | sibling = NULL; | 479 | sibling = NULL; |
505 | break; | 480 | break; |
@@ -513,8 +488,6 @@ void container_move(struct sway_container *container, | |||
513 | "(move dir: %d)", limit, move_dir); | 488 | "(move dir: %d)", limit, move_dir); |
514 | container_insert_child(sibling, container, limit); | 489 | container_insert_child(sibling, container, limit); |
515 | container->width = container->height = 0; | 490 | container->width = container->height = 0; |
516 | arrange_children_of(sibling); | ||
517 | arrange_children_of(old_parent); | ||
518 | sibling = NULL; | 491 | sibling = NULL; |
519 | } else { | 492 | } else { |
520 | wlr_log(L_DEBUG, "Reparenting container (perpendicular)"); | 493 | wlr_log(L_DEBUG, "Reparenting container (perpendicular)"); |
@@ -538,8 +511,6 @@ void container_move(struct sway_container *container, | |||
538 | container_add_child(sibling, container); | 511 | container_add_child(sibling, container); |
539 | } | 512 | } |
540 | container->width = container->height = 0; | 513 | container->width = container->height = 0; |
541 | arrange_children_of(sibling); | ||
542 | arrange_children_of(old_parent); | ||
543 | sibling = NULL; | 514 | sibling = NULL; |
544 | } | 515 | } |
545 | break; | 516 | break; |
@@ -864,7 +835,6 @@ struct sway_container *container_split(struct sway_container *child, | |||
864 | // Special case: this just behaves like splitt | 835 | // Special case: this just behaves like splitt |
865 | child->prev_layout = child->layout; | 836 | child->prev_layout = child->layout; |
866 | child->layout = layout; | 837 | child->layout = layout; |
867 | arrange_children_of(child); | ||
868 | return child; | 838 | return child; |
869 | } | 839 | } |
870 | 840 | ||
@@ -882,7 +852,7 @@ struct sway_container *container_split(struct sway_container *child, | |||
882 | 852 | ||
883 | struct sway_seat *seat = input_manager_get_default_seat(input_manager); | 853 | struct sway_seat *seat = input_manager_get_default_seat(input_manager); |
884 | bool set_focus = (seat_get_focus(seat) == child); | 854 | bool set_focus = (seat_get_focus(seat) == child); |
885 | 855 | ||
886 | add_gaps(cont); | 856 | add_gaps(cont); |
887 | 857 | ||
888 | if (child->type == C_WORKSPACE) { | 858 | if (child->type == C_WORKSPACE) { |
@@ -912,7 +882,6 @@ struct sway_container *container_split(struct sway_container *child, | |||
912 | } | 882 | } |
913 | 883 | ||
914 | container_notify_subtree_changed(cont); | 884 | container_notify_subtree_changed(cont); |
915 | arrange_children_of(cont); | ||
916 | return cont; | 885 | return cont; |
917 | } | 886 | } |
918 | 887 | ||
@@ -1050,9 +1019,6 @@ void container_swap(struct sway_container *con1, struct sway_container *con2) { | |||
1050 | prev_workspace_name = stored_prev_name; | 1019 | prev_workspace_name = stored_prev_name; |
1051 | } | 1020 | } |
1052 | 1021 | ||
1053 | arrange_children_of(con1->parent); | ||
1054 | arrange_children_of(con2->parent); | ||
1055 | |||
1056 | if (fs1 && con2->type == C_VIEW) { | 1022 | if (fs1 && con2->type == C_VIEW) { |
1057 | view_set_fullscreen(con2->sway_view, true); | 1023 | view_set_fullscreen(con2->sway_view, true); |
1058 | } | 1024 | } |