scene: add functions to place node on top/bottom

These are very common operations for compositors (including tinywl)
to perform.
master
Isaac Freund 3 years ago committed by Simon Ser
parent 2a8d385386
commit 4fae8f7be3

@ -139,6 +139,14 @@ void wlr_scene_node_place_above(struct wlr_scene_node *node,
*/ */
void wlr_scene_node_place_below(struct wlr_scene_node *node, void wlr_scene_node_place_below(struct wlr_scene_node *node,
struct wlr_scene_node *sibling); struct wlr_scene_node *sibling);
/**
* Move the node above all of its sibling nodes.
*/
void wlr_scene_node_raise_to_top(struct wlr_scene_node *node);
/**
* Move the node below all of its sibling nodes.
*/
void wlr_scene_node_lower_to_bottom(struct wlr_scene_node *node);
/** /**
* Move the node to another location in the tree. * Move the node to another location in the tree.
*/ */

@ -470,6 +470,24 @@ void wlr_scene_node_place_below(struct wlr_scene_node *node,
scene_node_damage_whole(sibling); scene_node_damage_whole(sibling);
} }
void wlr_scene_node_raise_to_top(struct wlr_scene_node *node) {
struct wlr_scene_node *current_top = wl_container_of(
node->parent->state.children.prev, current_top, state.link);
if (node == current_top) {
return;
}
wlr_scene_node_place_above(node, current_top);
}
void wlr_scene_node_lower_to_bottom(struct wlr_scene_node *node) {
struct wlr_scene_node *current_bottom = wl_container_of(
node->parent->state.children.prev, current_bottom, state.link);
if (node == current_bottom) {
return;
}
wlr_scene_node_place_below(node, current_bottom);
}
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); assert(node->type != WLR_SCENE_NODE_ROOT && new_parent != NULL);

Loading…
Cancel
Save