diff options
Diffstat (limited to 'sway/tree/node.c')
-rw-r--r-- | sway/tree/node.c | 29 |
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) { } return false; } + +void scene_node_disown_children(struct wlr_scene_tree *tree) { + // this function can be called as part of destruction code that will be invoked + // upon an allocation failure. Let's not crash on NULL due to an allocation error. + if (!tree) { + return; + } + + struct wlr_scene_node *child, *tmp_child; + wl_list_for_each_safe(child, tmp_child, &tree->children, link) { + wlr_scene_node_reparent(child, root->staging); + } +} + +struct wlr_scene_tree *alloc_scene_tree(struct wlr_scene_tree *parent, + bool *failed) { + // fallthrough + if (*failed) { + return NULL; + } + + struct wlr_scene_tree *tree = wlr_scene_tree_create(parent); + if (!tree) { + sway_log(SWAY_ERROR, "Failed to allocate a scene node"); + *failed = true; + } + + return tree; +} |