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.
This commit is contained in:
		
							parent
							
								
									d5263be355
								
							
						
					
					
						commit
						7ec9523ea3
					
				| 
						 | 
					@ -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,
 | 
					void wlr_scene_node_reparent(struct wlr_scene_node *node,
 | 
				
			||||||
		struct wlr_scene_node *new_parent) {
 | 
							struct wlr_scene_node *new_parent) {
 | 
				
			||||||
 | 
						assert(node->type != WLR_SCENE_NODE_ROOT && new_parent != NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (node->parent == new_parent) {
 | 
						if (node->parent == new_parent) {
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -145,11 +147,8 @@ void wlr_scene_node_reparent(struct wlr_scene_node *node,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	wl_list_remove(&node->state.link);
 | 
						wl_list_remove(&node->state.link);
 | 
				
			||||||
 | 
					 | 
				
			||||||
	node->parent = new_parent;
 | 
						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,
 | 
					static void scene_node_for_each_surface(struct wlr_scene_node *node,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue