aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/node.c
diff options
context:
space:
mode:
authorLibravatar Alexander Orzechowski <alex@ozal.ski>2024-01-18 10:00:45 -0500
committerLibravatar Kirill Primak <vyivel@eclair.cafe>2024-01-18 18:36:54 +0300
commit1eb16d136774c8fb3c9085df45156264f0db8814 (patch)
tree9c348ab37edae50b76a388d7e8d8dcd011cea33b /sway/tree/node.c
parentview: init function should return a success bool (diff)
downloadsway-1eb16d136774c8fb3c9085df45156264f0db8814.tar.gz
sway-1eb16d136774c8fb3c9085df45156264f0db8814.tar.zst
sway-1eb16d136774c8fb3c9085df45156264f0db8814.zip
scene_graph: Maintain `wlr_scene_node`s for the sway tree.
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}