aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2021-08-17 13:20:32 +0200
committerSimon Zeni <simon@bl4ckb0ne.ca>2021-09-08 09:50:08 -0400
commit9195b77e14a7793f622edf136cede522c8cbdb58 (patch)
tree387b1ddf2de99fe9d739145d689d005404be65ea
parent04d105760da71524c85a06f4ff7e5efba6a36088 (diff)
scene: add wlr_scene_node_coords
-rw-r--r--include/wlr/types/wlr_scene.h6
-rw-r--r--types/wlr_scene.c16
2 files changed, 22 insertions, 0 deletions
diff --git a/include/wlr/types/wlr_scene.h b/include/wlr/types/wlr_scene.h
index f2773c6b..cec54a0b 100644
--- a/include/wlr/types/wlr_scene.h
+++ b/include/wlr/types/wlr_scene.h
@@ -119,6 +119,12 @@ void wlr_scene_node_place_below(struct wlr_scene_node *node,
void wlr_scene_node_reparent(struct wlr_scene_node *node,
struct wlr_scene_node *new_parent);
/**
+ * Get the node's layout-local coordinates.
+ *
+ * True is returned if the node and all of its ancestors are enabled.
+ */
+bool wlr_scene_node_coords(struct wlr_scene_node *node, int *lx, int *ly);
+/**
* 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
* (in rendering order).
diff --git a/types/wlr_scene.c b/types/wlr_scene.c
index 4498c5f0..d38baf75 100644
--- a/types/wlr_scene.c
+++ b/types/wlr_scene.c
@@ -193,6 +193,22 @@ void wlr_scene_node_reparent(struct wlr_scene_node *node,
wl_list_insert(new_parent->state.children.prev, &node->state.link);
}
+bool wlr_scene_node_coords(struct wlr_scene_node *node,
+ int *lx_ptr, int *ly_ptr) {
+ int lx = 0, ly = 0;
+ bool enabled = true;
+ while (node != NULL) {
+ lx += node->state.x;
+ ly += node->state.y;
+ enabled = enabled && node->state.enabled;
+ node = node->parent;
+ }
+
+ *lx_ptr = lx;
+ *ly_ptr = ly;
+ return enabled;
+}
+
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) {