aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/node.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/tree/node.c')
-rw-r--r--sway/tree/node.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/sway/tree/node.c b/sway/tree/node.c
index 12361c75..213cf0a6 100644
--- a/sway/tree/node.c
+++ b/sway/tree/node.c
@@ -159,3 +159,32 @@ bool node_has_ancestor(struct sway_node *node, struct sway_node *ancestor) {
159 } 159 }
160 return false; 160 return false;
161} 161}
162
163void scene_node_disown_children(struct wlr_scene_tree *tree) {
164 // this function can be called as part of destruction code that will be invoked
165 // upon an allocation failure. Let's not crash on NULL due to an allocation error.
166 if (!tree) {
167 return;
168 }
169
170 struct wlr_scene_node *child, *tmp_child;
171 wl_list_for_each_safe(child, tmp_child, &tree->children, link) {
172 wlr_scene_node_reparent(child, root->staging);
173 }
174}
175
176struct wlr_scene_tree *alloc_scene_tree(struct wlr_scene_tree *parent,
177 bool *failed) {
178 // fallthrough
179 if (*failed) {
180 return NULL;
181 }
182
183 struct wlr_scene_tree *tree = wlr_scene_tree_create(parent);
184 if (!tree) {
185 sway_log(SWAY_ERROR, "Failed to allocate a scene node");
186 *failed = true;
187 }
188
189 return tree;
190}