summaryrefslogtreecommitdiff
path: root/wlr_scene.c
diff options
context:
space:
mode:
authorIsaac Freund <[email protected]>2021-12-11 12:25:53 +0100
committerSimon Ser <[email protected]>2021-12-13 15:21:05 +0000
commitd164e76c0b89b6cff614ae82525812494f3db54c (patch)
tree713f05c43e5ab843ff9b43ea2189c36ca1e9c4a5 /wlr_scene.c
parent3e48d0979e6de643f560f766b15ed3934d79d7e0 (diff)
scene: add primary output to wlr_scene_surface
This allows compositors to avoid sending multiple frame done events to a surface that is rendered on multiple outputs at once. This may also be used in the same way for presentation feedback.
Diffstat (limited to 'wlr_scene.c')
-rw-r--r--wlr_scene.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/wlr_scene.c b/wlr_scene.c
index d2f3f4a..4269707 100644
--- a/wlr_scene.c
+++ b/wlr_scene.c
@@ -175,6 +175,9 @@ static void scene_surface_update_outputs(
.height = scene_surface->surface->current.height,
};
+ int largest_overlap = 0;
+ scene_surface->primary_output = NULL;
+
struct wlr_scene_output *scene_output;
wl_list_for_each(scene_output, &scene->outputs, link) {
struct wlr_box output_box = {
@@ -184,10 +187,16 @@ static void scene_surface_update_outputs(
wlr_output_effective_resolution(scene_output->output,
&output_box.width, &output_box.height);
- // These enter/leave functions are a noop if the event has already been
- // sent for the given output.
struct wlr_box intersection;
if (wlr_box_intersection(&intersection, &surface_box, &output_box)) {
+ int overlap = intersection.width * intersection.height;
+ if (overlap > largest_overlap) {
+ largest_overlap = overlap;
+ scene_surface->primary_output = scene_output->output;
+ }
+
+ // These enter/leave functions are a noop if the event has already been
+ // sent for the given output.
wlr_surface_send_enter(scene_surface->surface, scene_output->output);
} else {
wlr_surface_send_leave(scene_surface->surface, scene_output->output);