aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevin J. Pohly <djpohly@gmail.com>2021-08-29 16:58:12 -0500
committerSimon Ser <contact@emersion.fr>2021-08-30 16:43:18 +0200
commit7ec9523ea3c5e5a4f1e7a6e17a047dae0b663db7 (patch)
tree95d5e4846fe8dc8e4341933e68f0f6a4b112c28b
parentd5263be35549a368bac601e17ca7a7e825b6e7e1 (diff)
scene: stricter assertions on reparent
For consistency with the rest of the scene-graph API, prevent detaching a subtree by giving NULL for the new parent, and don't allow ROOT nodes to be grafted into another tree.
-rw-r--r--types/wlr_scene.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/types/wlr_scene.c b/types/wlr_scene.c
index 19132d9a..ee9215d2 100644
--- a/types/wlr_scene.c
+++ b/types/wlr_scene.c
@@ -135,6 +135,8 @@ void wlr_scene_node_place_below(struct wlr_scene_node *node,
void wlr_scene_node_reparent(struct wlr_scene_node *node,
struct wlr_scene_node *new_parent) {
+ assert(node->type != WLR_SCENE_NODE_ROOT && new_parent != NULL);
+
if (node->parent == new_parent) {
return;
}
@@ -145,11 +147,8 @@ void wlr_scene_node_reparent(struct wlr_scene_node *node,
}
wl_list_remove(&node->state.link);
-
node->parent = new_parent;
- if (new_parent != NULL) {
- wl_list_insert(new_parent->state.children.prev, &node->state.link);
- }
+ wl_list_insert(new_parent->state.children.prev, &node->state.link);
}
static void scene_node_for_each_surface(struct wlr_scene_node *node,