From 71daec9441494e5cd2985708536b513d936878a1 Mon Sep 17 00:00:00 2001 From: Rose Hudson Date: Tue, 18 Jul 2023 11:52:25 +0100 Subject: [PATCH] export-dmabuf, screencopy: schedule_frame -> needs_frame needs_frame is for backends to trigger frames for reasons that compositors couldn't see coming. schedule_frame is freaky and I want to remove it. These protocols aren't backends but in this case they're close enough, so switch to needs_frame. CC #3664 --- types/wlr_export_dmabuf_v1.c | 6 ++++-- types/wlr_screencopy_v1.c | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/types/wlr_export_dmabuf_v1.c b/types/wlr_export_dmabuf_v1.c index 138c52d1..d31f40e6 100644 --- a/types/wlr_export_dmabuf_v1.c +++ b/types/wlr_export_dmabuf_v1.c @@ -4,7 +4,6 @@ #include #include #include -#include #include #include "wlr-export-dmabuf-unstable-v1-protocol.h" @@ -160,7 +159,10 @@ static void manager_handle_capture_output(struct wl_client *client, wl_signal_add(&output->events.destroy, &frame->output_destroy); frame->output_destroy.notify = frame_output_handle_destroy; - wlr_output_schedule_frame(output); + // Request a frame because we can't assume that the current front buffer is still usable. It may + // have been released already, and we shouldn't lock it here because compositors want to render + // into the least damaged buffer. + wlr_output_update_needs_frame(output); } static void manager_handle_destroy(struct wl_client *client, diff --git a/types/wlr_screencopy_v1.c b/types/wlr_screencopy_v1.c index a29b5f27..23f78d7e 100644 --- a/types/wlr_screencopy_v1.c +++ b/types/wlr_screencopy_v1.c @@ -1,10 +1,10 @@ #include #include #include +#include #include #include #include -#include #include #include #include @@ -416,8 +416,10 @@ static void frame_handle_copy(struct wl_client *wl_client, wl_signal_add(&output->events.destroy, &frame->output_enable); frame->output_enable.notify = frame_handle_output_enable; - // Schedule a buffer commit - wlr_output_schedule_frame(output); + // Request a frame because we can't assume that the current front buffer is still usable. It may + // have been released already, and we shouldn't lock it here because compositors want to render + // into the least damaged buffer. + wlr_output_update_needs_frame(output); wlr_output_lock_attach_render(output, true); if (frame->overlay_cursor) {