From 5e2a1e44f55b2e3cce008256e706ef151f92880a Mon Sep 17 00:00:00 2001 From: Alexander Orzechowski Date: Sat, 15 Apr 2023 12:52:17 +0200 Subject: [PATCH] presentation_time: Introduce wlr_presentation_send_presented Sends the presentation event immediately without any buffering to a surface. --- include/wlr/types/wlr_presentation_time.h | 8 ++++++++ types/wlr_presentation_time.c | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/wlr/types/wlr_presentation_time.h b/include/wlr/types/wlr_presentation_time.h index 48bef659a..3c72fd46f 100644 --- a/include/wlr/types/wlr_presentation_time.h +++ b/include/wlr/types/wlr_presentation_time.h @@ -96,4 +96,12 @@ void wlr_presentation_surface_sampled_on_output( struct wlr_presentation *presentation, struct wlr_surface *surface, struct wlr_output *output); +/** + * Send the presentation event immediately to this surface if the surface is + * asking for presentation events. This must be called during the present handler + * of an output. + */ +void wlr_presentation_send_presented(struct wlr_presentation *presentation, + struct wlr_surface *surface, struct wlr_presentation_event *event); + #endif diff --git a/types/wlr_presentation_time.c b/types/wlr_presentation_time.c index 082b9a93d..f519e5f29 100644 --- a/types/wlr_presentation_time.c +++ b/types/wlr_presentation_time.c @@ -325,3 +325,15 @@ void wlr_presentation_surface_sampled_on_output( feedback->output_destroy.notify = feedback_handle_output_destroy; wl_signal_add(&output->events.destroy, &feedback->output_destroy); } + +void wlr_presentation_send_presented(struct wlr_presentation *presentation, + struct wlr_surface *surface, struct wlr_presentation_event *event) { + struct wlr_presentation_feedback *feedback = + wlr_presentation_surface_sampled(presentation, surface); + if (!feedback) { + return; + } + + wlr_presentation_feedback_send_presented(feedback, event); + wlr_presentation_feedback_destroy(feedback); +}