aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/layout.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/tree/layout.c')
-rw-r--r--sway/tree/layout.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/sway/tree/layout.c b/sway/tree/layout.c
index 38e14d00..2b710403 100644
--- a/sway/tree/layout.c
+++ b/sway/tree/layout.c
@@ -20,14 +20,7 @@
20#include "log.h" 20#include "log.h"
21 21
22static int index_child(const struct sway_container *child) { 22static int index_child(const struct sway_container *child) {
23 struct sway_container *parent = child->parent; 23 return list_find(child->parent->children, child);
24 for (int i = 0; i < parent->children->length; ++i) {
25 if (parent->children->items[i] == child) {
26 return i;
27 }
28 }
29 // This happens if the child is a floating container
30 return -1;
31} 24}
32 25
33static void container_handle_fullscreen_reparent(struct sway_container *con, 26static void container_handle_fullscreen_reparent(struct sway_container *con,
@@ -125,11 +118,9 @@ struct sway_container *container_remove_child(struct sway_container *child) {
125 } 118 }
126 119
127 struct sway_container *parent = child->parent; 120 struct sway_container *parent = child->parent;
128 for (int i = 0; i < parent->children->length; ++i) { 121 int index = index_child(child);
129 if (parent->children->items[i] == child) { 122 if (index != -1) {
130 list_del(parent->children, i); 123 list_del(parent->children, index);
131 break;
132 }
133 } 124 }
134 child->parent = NULL; 125 child->parent = NULL;
135 container_notify_subtree_changed(parent); 126 container_notify_subtree_changed(parent);