From cd6e3182fa55dd8ab3a8a167e854a5446baf39c7 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Fri, 6 Apr 2018 12:46:33 -0400 Subject: Fix issues @orestisf1993 raised --- sway/tree/layout.c | 96 +++++++++++++++++++++++++++++------------------------- 1 file changed, 52 insertions(+), 44 deletions(-) (limited to 'sway/tree/layout.c') diff --git a/sway/tree/layout.c b/sway/tree/layout.c index 1c31b215..a0586f40 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c @@ -381,53 +381,61 @@ void container_move(struct sway_container *container, int index = index_child(container); struct sway_container *old_parent = container->parent; - switch (sibling->type) { - case C_VIEW: - if (sibling->parent == container->parent) { - wlr_log(L_DEBUG, "Swapping siblings"); - sibling->parent->children->items[index + offs] = container; - sibling->parent->children->items[index] = sibling; - arrange_windows(sibling->parent, -1, -1); - } else { - wlr_log(L_DEBUG, "Promoting to sibling of cousin"); - container_insert_child(sibling->parent, container, - index_child(sibling) + (offs > 0 ? 0 : 1)); - container->width = container->height = 0; - arrange_windows(sibling->parent, -1, -1); - arrange_windows(old_parent, -1, -1); - } - break; - case C_WORKSPACE: // Note: only in the case of moving between outputs - case C_CONTAINER: - if (is_parallel(sibling->layout, move_dir)) { - int limit = container_limit(sibling, move_dir); - wlr_log(L_DEBUG, "Reparenting container (paralell)"); - limit = limit != 0 ? limit + 1 : limit; // Convert to index - container_insert_child(sibling, container, limit); - container->width = container->height = 0; - arrange_windows(sibling, -1, -1); - arrange_windows(old_parent, -1, -1); - } else { - wlr_log(L_DEBUG, "Reparenting container (perpendicular)"); - container_remove_child(container); - struct sway_container *focus_inactive = seat_get_focus_inactive( - config->handler_context.seat, sibling); - if (focus_inactive) { - container_add_sibling(focus_inactive, container); - } else if (sibling->children->length) { - container_add_sibling(sibling->children->items[0], container); + while (sibling) { + switch (sibling->type) { + case C_VIEW: + if (sibling->parent == container->parent) { + wlr_log(L_DEBUG, "Swapping siblings"); + sibling->parent->children->items[index + offs] = container; + sibling->parent->children->items[index] = sibling; + arrange_windows(sibling->parent, -1, -1); } else { - container_add_child(sibling, container); + wlr_log(L_DEBUG, "Promoting to sibling of cousin"); + container_insert_child(sibling->parent, container, + index_child(sibling) + (offs > 0 ? 0 : 1)); + container->width = container->height = 0; + arrange_windows(sibling->parent, -1, -1); + arrange_windows(old_parent, -1, -1); } - container->width = container->height = 0; - arrange_windows(sibling, -1, -1); - arrange_windows(old_parent, -1, -1); + sibling = NULL; + break; + case C_WORKSPACE: // Note: only in the case of moving between outputs + case C_CONTAINER: + if (is_parallel(sibling->layout, move_dir)) { + int limit = container_limit(sibling, move_dir); + wlr_log(L_DEBUG, "Reparenting container (paralell)"); + limit = limit != 0 ? limit + 1 : limit; // Convert to index + container_insert_child(sibling, container, limit); + container->width = container->height = 0; + arrange_windows(sibling, -1, -1); + arrange_windows(old_parent, -1, -1); + sibling = NULL; + } else { + wlr_log(L_DEBUG, "Reparenting container (perpendicular)"); + container_remove_child(container); + struct sway_container *focus_inactive = seat_get_focus_inactive( + config->handler_context.seat, sibling); + wlr_log(L_DEBUG, "Focus inactive: %zd", focus_inactive ? + focus_inactive->id : 0); + if (focus_inactive) { + sibling = focus_inactive; + continue; + } else if (sibling->children->length) { + container_add_sibling(sibling->children->items[0], container); + } else { + container_add_child(sibling, container); + } + container->width = container->height = 0; + arrange_windows(sibling, -1, -1); + arrange_windows(old_parent, -1, -1); + sibling = NULL; + } + break; + default: + sway_assert(0, "Not expecting to see container of type %s here", + container_type_to_str(sibling->type)); + return; } - break; - default: - sway_assert(0, "Not expecting to see container of type %s here", - container_type_to_str(sibling->type)); - return; } if (old_parent) { -- cgit v1.2.3-54-g00ecf