aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2018-04-06 11:52:23 -0400
committerDrew DeVault <sir@cmpwn.com>2018-04-06 11:53:10 -0400
commitb5baa78dc3abcbe14199340cdf391497ddc9ca3d (patch)
tree91547dba4693c01ec08ab3f955b69e0e9b6c53eb
parent603e0e42c577026f1c688c393989e65dc3482808 (diff)
downloadsway-b5baa78dc3abcbe14199340cdf391497ddc9ca3d.zip
sway-b5baa78dc3abcbe14199340cdf391497ddc9ca3d.tar.gz
sway-b5baa78dc3abcbe14199340cdf391497ddc9ca3d.tar.bz2
Address @emersion's comments
-rw-r--r--sway/tree/layout.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/sway/tree/layout.c b/sway/tree/layout.c
index e633acc..1c31b21 100644
--- a/sway/tree/layout.c
+++ b/sway/tree/layout.c
@@ -103,12 +103,13 @@ static int index_child(const struct sway_container *child) {
void container_insert_child(struct sway_container *parent,
struct sway_container *child, int i) {
- struct sway_container *old_parent = NULL;
+ struct sway_container *old_parent = child->parent;
+ if (old_parent) {
+ container_remove_child(child);
+ }
list_insert(parent->children, i, child);
child->parent = parent;
- if (old_parent && old_parent != parent) {
- wl_signal_emit(&child->events.reparent, old_parent);
- }
+ wl_signal_emit(&child->events.reparent, old_parent);
}
struct sway_container *container_add_sibling(struct sway_container *fixed,
@@ -123,9 +124,7 @@ struct sway_container *container_add_sibling(struct sway_container *fixed,
int i = index_child(fixed);
list_insert(parent->children, i + 1, active);
active->parent = parent;
- if (old_parent && old_parent != parent) {
- wl_signal_emit(&active->events.reparent, old_parent);
- }
+ wl_signal_emit(&active->events.reparent, old_parent);
return active->parent;
}
@@ -268,6 +267,7 @@ static void workspace_rejigger(struct sway_container *ws,
container_flatten(ws);
container_reap_empty_recursive(original_parent);
+ wl_signal_emit(&child->events.reparent, original_parent);
arrange_windows(ws, -1, -1);
}
@@ -287,6 +287,7 @@ void container_move(struct sway_container *container,
if (parent != container_flatten(parent)) {
// Special case: we were the last one in this container, so flatten it
// and leave
+ update_debug_tree();
return;
}
@@ -353,7 +354,6 @@ void container_move(struct sway_container *container,
"promoting descendant to sibling");
// Special case
struct sway_container *old_parent = container->parent;
- container_remove_child(container);
container_insert_child(current->parent, container,
index + (offs < 0 ? 0 : 1));
container->width = container->height = 0;
@@ -390,7 +390,6 @@ void container_move(struct sway_container *container,
arrange_windows(sibling->parent, -1, -1);
} else {
wlr_log(L_DEBUG, "Promoting to sibling of cousin");
- container_remove_child(container);
container_insert_child(sibling->parent, container,
index_child(sibling) + (offs > 0 ? 0 : 1));
container->width = container->height = 0;
@@ -404,7 +403,6 @@ void container_move(struct sway_container *container,
int limit = container_limit(sibling, move_dir);
wlr_log(L_DEBUG, "Reparenting container (paralell)");
limit = limit != 0 ? limit + 1 : limit; // Convert to index
- container_remove_child(container);
container_insert_child(sibling, container, limit);
container->width = container->height = 0;
arrange_windows(sibling, -1, -1);