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

Commit

Permalink
scene: assert that node != sibling in place above/below
Browse files Browse the repository at this point in the history
Currently these functions remove the node from the scene if the sibling
argument is the same node as the node. To prevent confusion when
misusing this API, assert that the nodes are distinct and document this.
  • Loading branch information
ifreund committed Oct 13, 2021
1 parent dc22a06 commit a7148de
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/wlr/types/wlr_scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,13 @@ void wlr_scene_node_set_enabled(struct wlr_scene_node *node, bool enabled);
void wlr_scene_node_set_position(struct wlr_scene_node *node, int x, int y);
/**
* Move the node right above the specified sibling.
* Asserts that node and sibling are distinct and share the same parent.
*/
void wlr_scene_node_place_above(struct wlr_scene_node *node,
struct wlr_scene_node *sibling);
/**
* Move the node right below the specified sibling.
* Asserts that node and sibling are distinct and share the same parent.
*/
void wlr_scene_node_place_below(struct wlr_scene_node *node,
struct wlr_scene_node *sibling);
Expand Down
2 changes: 2 additions & 0 deletions types/scene/wlr_scene.c
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ void wlr_scene_node_set_position(struct wlr_scene_node *node, int x, int y) {

void wlr_scene_node_place_above(struct wlr_scene_node *node,
struct wlr_scene_node *sibling) {
assert(node != sibling);
assert(node->parent == sibling->parent);

if (node->state.link.prev == &sibling->state.link) {
Expand All @@ -455,6 +456,7 @@ 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) {
assert(node != sibling);
assert(node->parent == sibling->parent);

if (node->state.link.next == &sibling->state.link) {
Expand Down

0 comments on commit a7148de

Please sign in to comment.