From 9b2b9d13678ef6d5d47456a6fb11a4eba13a03bd Mon Sep 17 00:00:00 2001 From: Alexander Orzechowski Date: Sat, 24 Feb 2024 08:22:50 -0500 Subject: [PATCH] wlr_raster_from_surface: Implement surface invalidation --- types/wlr_raster.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/types/wlr_raster.c b/types/wlr_raster.c index 1cf540976..bbd495466 100644 --- a/types/wlr_raster.c +++ b/types/wlr_raster.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -507,6 +508,7 @@ struct surface_raster { struct wlr_addon addon; struct wl_listener buffer_prerelease; + struct wl_listener raster_invalidated; bool locking_buffer; }; @@ -525,6 +527,7 @@ static void surface_raster_destroy(struct surface_raster *surface_raster) { surface_raster_drop_raster(surface_raster); wl_list_remove(&surface_raster->buffer_prerelease.link); + wl_list_remove(&surface_raster->raster_invalidated.link); wlr_addon_finish(&surface_raster->addon); free(surface_raster); } @@ -555,6 +558,14 @@ static void surface_raster_handle_buffer_prerelease(struct wl_listener *listener wl_list_init(&surface_raster->buffer_prerelease.link); } +static void surface_raster_handle_raster_invalidated(struct wl_listener *listener, void *data) { + struct surface_raster *surface_raster = + wl_container_of(listener, surface_raster, raster_invalidated); + + wlr_surface_invalidation_manager_v1_send_surface_invalidation( + surface_raster->surface); +} + const struct wlr_addon_interface surface_raster_addon_impl = { .name = "wlr_raster_surface", .destroy = surface_raster_handle_addon_destroy, @@ -636,6 +647,8 @@ struct wlr_raster *wlr_raster_from_surface(struct wlr_surface *surface) { surface_raster->buffer_prerelease.notify = surface_raster_handle_buffer_prerelease; wl_list_init(&surface_raster->buffer_prerelease.link); + surface_raster->raster_invalidated.notify = surface_raster_handle_raster_invalidated; + wl_list_init(&surface_raster->raster_invalidated.link); } if (!surface->current.buffer) { @@ -652,6 +665,9 @@ struct wlr_raster *wlr_raster_from_surface(struct wlr_surface *surface) { wl_list_remove(&surface_raster->buffer_prerelease.link); wl_list_init(&surface_raster->buffer_prerelease.link); + wl_list_remove(&surface_raster->raster_invalidated.link); + wl_list_init(&surface_raster->raster_invalidated.link); + surface_raster_drop_raster(surface_raster); return NULL; @@ -694,6 +710,9 @@ struct wlr_raster *wlr_raster_from_surface(struct wlr_surface *surface) { return NULL; } + wl_list_remove(&surface_raster->raster_invalidated.link); + wl_signal_add(&raster->events.invalidated, &surface_raster->raster_invalidated); + surface_raster_drop_raster(surface_raster); surface_raster->raster = wlr_raster_lock(raster);