diff options
-rw-r--r-- | sway/tree/layout.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/sway/tree/layout.c b/sway/tree/layout.c index e633acc6..1c31b215 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c | |||
@@ -103,12 +103,13 @@ static int index_child(const struct sway_container *child) { | |||
103 | 103 | ||
104 | void container_insert_child(struct sway_container *parent, | 104 | void container_insert_child(struct sway_container *parent, |
105 | struct sway_container *child, int i) { | 105 | struct sway_container *child, int i) { |
106 | struct sway_container *old_parent = NULL; | 106 | struct sway_container *old_parent = child->parent; |
107 | if (old_parent) { | ||
108 | container_remove_child(child); | ||
109 | } | ||
107 | list_insert(parent->children, i, child); | 110 | list_insert(parent->children, i, child); |
108 | child->parent = parent; | 111 | child->parent = parent; |
109 | if (old_parent && old_parent != parent) { | 112 | wl_signal_emit(&child->events.reparent, old_parent); |
110 | wl_signal_emit(&child->events.reparent, old_parent); | ||
111 | } | ||
112 | } | 113 | } |
113 | 114 | ||
114 | struct sway_container *container_add_sibling(struct sway_container *fixed, | 115 | struct sway_container *container_add_sibling(struct sway_container *fixed, |
@@ -123,9 +124,7 @@ struct sway_container *container_add_sibling(struct sway_container *fixed, | |||
123 | int i = index_child(fixed); | 124 | int i = index_child(fixed); |
124 | list_insert(parent->children, i + 1, active); | 125 | list_insert(parent->children, i + 1, active); |
125 | active->parent = parent; | 126 | active->parent = parent; |
126 | if (old_parent && old_parent != parent) { | 127 | wl_signal_emit(&active->events.reparent, old_parent); |
127 | wl_signal_emit(&active->events.reparent, old_parent); | ||
128 | } | ||
129 | return active->parent; | 128 | return active->parent; |
130 | } | 129 | } |
131 | 130 | ||
@@ -268,6 +267,7 @@ static void workspace_rejigger(struct sway_container *ws, | |||
268 | 267 | ||
269 | container_flatten(ws); | 268 | container_flatten(ws); |
270 | container_reap_empty_recursive(original_parent); | 269 | container_reap_empty_recursive(original_parent); |
270 | wl_signal_emit(&child->events.reparent, original_parent); | ||
271 | arrange_windows(ws, -1, -1); | 271 | arrange_windows(ws, -1, -1); |
272 | } | 272 | } |
273 | 273 | ||
@@ -287,6 +287,7 @@ void container_move(struct sway_container *container, | |||
287 | if (parent != container_flatten(parent)) { | 287 | if (parent != container_flatten(parent)) { |
288 | // Special case: we were the last one in this container, so flatten it | 288 | // Special case: we were the last one in this container, so flatten it |
289 | // and leave | 289 | // and leave |
290 | update_debug_tree(); | ||
290 | return; | 291 | return; |
291 | } | 292 | } |
292 | 293 | ||
@@ -353,7 +354,6 @@ void container_move(struct sway_container *container, | |||
353 | "promoting descendant to sibling"); | 354 | "promoting descendant to sibling"); |
354 | // Special case | 355 | // Special case |
355 | struct sway_container *old_parent = container->parent; | 356 | struct sway_container *old_parent = container->parent; |
356 | container_remove_child(container); | ||
357 | container_insert_child(current->parent, container, | 357 | container_insert_child(current->parent, container, |
358 | index + (offs < 0 ? 0 : 1)); | 358 | index + (offs < 0 ? 0 : 1)); |
359 | container->width = container->height = 0; | 359 | container->width = container->height = 0; |
@@ -390,7 +390,6 @@ void container_move(struct sway_container *container, | |||
390 | arrange_windows(sibling->parent, -1, -1); | 390 | arrange_windows(sibling->parent, -1, -1); |
391 | } else { | 391 | } else { |
392 | wlr_log(L_DEBUG, "Promoting to sibling of cousin"); | 392 | wlr_log(L_DEBUG, "Promoting to sibling of cousin"); |
393 | container_remove_child(container); | ||
394 | container_insert_child(sibling->parent, container, | 393 | container_insert_child(sibling->parent, container, |
395 | index_child(sibling) + (offs > 0 ? 0 : 1)); | 394 | index_child(sibling) + (offs > 0 ? 0 : 1)); |
396 | container->width = container->height = 0; | 395 | container->width = container->height = 0; |
@@ -404,7 +403,6 @@ void container_move(struct sway_container *container, | |||
404 | int limit = container_limit(sibling, move_dir); | 403 | int limit = container_limit(sibling, move_dir); |
405 | wlr_log(L_DEBUG, "Reparenting container (paralell)"); | 404 | wlr_log(L_DEBUG, "Reparenting container (paralell)"); |
406 | limit = limit != 0 ? limit + 1 : limit; // Convert to index | 405 | limit = limit != 0 ? limit + 1 : limit; // Convert to index |
407 | container_remove_child(container); | ||
408 | container_insert_child(sibling, container, limit); | 406 | container_insert_child(sibling, container, limit); |
409 | container->width = container->height = 0; | 407 | container->width = container->height = 0; |
410 | arrange_windows(sibling, -1, -1); | 408 | arrange_windows(sibling, -1, -1); |