scene: add node reparent function

If nodes are arranged in a tree rather than at a single level, then it
makes sense that there should be a way to move them to a completely
different parent in addition to moving up or down among siblings.
This commit is contained in:
Devin J. Pohly 2021-08-23 14:32:59 -05:00 committed by Simon Ser
parent b18c254e5f
commit a1d462fa81
2 changed files with 19 additions and 0 deletions

View File

@ -90,6 +90,11 @@ void wlr_scene_node_place_above(struct wlr_scene_node *node,
*/
void wlr_scene_node_place_below(struct wlr_scene_node *node,
struct wlr_scene_node *sibling);
/**
* Move the node to another location in the tree.
*/
void wlr_scene_node_reparent(struct wlr_scene_node *node,
struct wlr_scene_node *new_parent);
/**
* Call `iterator` on each surface in the scene-graph, with the surface's
* position in layout coordinates. The function is called from root to leaves

View File

@ -133,6 +133,20 @@ void wlr_scene_node_place_below(struct wlr_scene_node *node,
wl_list_insert(sibling->state.link.prev, &node->state.link);
}
void wlr_scene_node_reparent(struct wlr_scene_node *node,
struct wlr_scene_node *new_parent) {
if (node->parent == new_parent) {
return;
}
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);
}
}
static void scene_node_for_each_surface(struct wlr_scene_node *node,
int lx, int ly, wlr_surface_iterator_func_t user_iterator,
void *user_data) {