aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2021-11-30 20:55:04 +0100
committerIsaac Freund <mail@isaacfreund.com>2021-11-30 20:16:24 +0000
commitba974a4e9f17e5f75efebe312e8bd1b24ad7b06d (patch)
treef54c143a3da3922866a71a7259346a9d3be3d2d3
parentdd84c5a1ccc322c4775282bbfc781f17e4ddac3a (diff)
scene: add wlr_scene_get_scene_output
This allows getting a wlr_scene_output from a wlr_output. Since an output can only be added once to a scene-graph there's no ambiguity. This is useful for compositors using wlr_scene_attach_output_layout: the output layout integration automatically creates a scene-graph output for each wlr_output added to the layout.
-rw-r--r--include/wlr/types/wlr_scene.h7
-rw-r--r--types/scene/wlr_scene.c12
2 files changed, 19 insertions, 0 deletions
diff --git a/include/wlr/types/wlr_scene.h b/include/wlr/types/wlr_scene.h
index 622dbb28..bca0b269 100644
--- a/include/wlr/types/wlr_scene.h
+++ b/include/wlr/types/wlr_scene.h
@@ -282,6 +282,13 @@ bool wlr_scene_output_commit(struct wlr_scene_output *scene_output);
*/
void wlr_scene_output_for_each_surface(struct wlr_scene_output *scene_output,
wlr_surface_iterator_func_t iterator, void *user_data);
+/**
+ * Get a scene-graph output from a wlr_output.
+ *
+ * If the output hasn't been added to the scene-graph, returns NULL.
+ */
+struct wlr_scene_output *wlr_scene_get_scene_output(struct wlr_scene *scene,
+ struct wlr_output *output);
/**
* Attach an output layout to a scene.
diff --git a/types/scene/wlr_scene.c b/types/scene/wlr_scene.c
index 03439223..d1236fe0 100644
--- a/types/scene/wlr_scene.c
+++ b/types/scene/wlr_scene.c
@@ -828,6 +828,18 @@ void wlr_scene_output_destroy(struct wlr_scene_output *scene_output) {
free(scene_output);
}
+struct wlr_scene_output *wlr_scene_get_scene_output(struct wlr_scene *scene,
+ struct wlr_output *output) {
+ struct wlr_addon *addon =
+ wlr_addon_find(&output->addons, scene, &output_addon_impl);
+ if (addon == NULL) {
+ return NULL;
+ }
+ struct wlr_scene_output *scene_output =
+ wl_container_of(addon, scene_output, addon);
+ return scene_output;
+}
+
void wlr_scene_output_set_position(struct wlr_scene_output *scene_output,
int lx, int ly) {
if (scene_output->x == lx && scene_output->y == ly) {