diff options
author | Isaac Freund <[email protected]> | 2021-10-13 16:11:54 +0200 |
---|---|---|
committer | Simon Ser <[email protected]> | 2021-10-14 21:10:03 +0200 |
commit | aa739b6a833370263d721ec89a7fa203e19f690d (patch) | |
tree | a2b623835edf98712cdc6de821be82464e29f4d7 | |
parent | a4ea63f084e292e7bca884605fb0607ffd9b454f (diff) |
scene: add functions to place node on top/bottom
These are very common operations for compositors (including tinywl)
to perform.
-rw-r--r-- | wlr_scene.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/wlr_scene.c b/wlr_scene.c index 2dc2924..be44bcc 100644 --- a/wlr_scene.c +++ b/wlr_scene.c @@ -470,6 +470,24 @@ void wlr_scene_node_place_below(struct wlr_scene_node *node, 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, struct wlr_scene_node *new_parent) { assert(node->type != WLR_SCENE_NODE_ROOT && new_parent != NULL); |