Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

Commit

Permalink
scene: add functions to place node on top/bottom
Browse files Browse the repository at this point in the history
These are very common operations for compositors (including tinywl)
to perform.
  • Loading branch information
ifreund committed Oct 13, 2021
1 parent a7148de commit feae4bc
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
8 changes: 8 additions & 0 deletions include/wlr/types/wlr_scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
struct wlr_scene_node *sibling);
/**
* Move the node above all of its sibling nodes.
*/
void wlr_scene_node_place_on_top(struct wlr_scene_node *node);
/**
* Move the node below all of its sibling nodes.
*/
void wlr_scene_node_place_on_bottom(struct wlr_scene_node *node);
/**
* Move the node to another location in the tree.
*/
Expand Down
18 changes: 18 additions & 0 deletions types/scene/wlr_scene.c
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,24 @@ void wlr_scene_node_place_below(struct wlr_scene_node *node,
scene_node_damage_whole(sibling);
}

void wlr_scene_node_place_on_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_place_on_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);
Expand Down

0 comments on commit feae4bc

Please sign in to comment.