From 7a2af1edf9c79935467cd690cb4c53c3f59244ea Mon Sep 17 00:00:00 2001 From: Aleksey Samoilov Date: Tue, 30 Dec 2025 22:47:08 +0400 Subject: [PATCH] Fix use-after free and race conditions in Wayland idle inhibitation --- src/wayland/meta-wayland-actor-surface.c | 2 ++ src/wayland/meta-wayland-surface.c | 15 +++++++++++++++ src/wayland/meta-wayland-surface.h | 2 ++ 3 files changed, 19 insertions(+) diff --git a/src/wayland/meta-wayland-actor-surface.c b/src/wayland/meta-wayland-actor-surface.c index 0ce5bbb6c..bf92b7c00 100644 --- a/src/wayland/meta-wayland-actor-surface.c +++ b/src/wayland/meta-wayland-actor-surface.c @@ -445,6 +445,8 @@ meta_wayland_actor_surface_reset_actor (MetaWaylandActorSurface *actor_surface) G_CALLBACK (on_actor_destroyed), actor_surface); + meta_wayland_surface_notify_actor_changed (surface); + g_signal_connect_swapped (priv->actor, "notify::allocation", G_CALLBACK (meta_wayland_surface_notify_geometry_changed), surface); diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c index 13d0f9184..38e41fadb 100644 --- a/src/wayland/meta-wayland-surface.c +++ b/src/wayland/meta-wayland-surface.c @@ -95,6 +95,7 @@ enum SURFACE_SHORTCUTS_RESTORED, SURFACE_GEOMETRY_CHANGED, SURFACE_PRE_STATE_APPLIED, + SURFACE_ACTOR_CHANGED, N_SURFACE_SIGNALS }; @@ -1677,6 +1678,14 @@ meta_wayland_surface_class_init (MetaWaylandSurfaceClass *klass) 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + + surface_signals[SURFACE_ACTOR_CHANGED] = + g_signal_new ("actor-changed", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST, + 0, NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); } static void @@ -1991,3 +2000,9 @@ meta_wayland_surface_get_height (MetaWaylandSurface *surface) return height / surface->scale; } } + +void +meta_wayland_surface_notify_actor_changed (MetaWaylandSurface *surface) +{ + g_signal_emit (surface, surface_signals[SURFACE_ACTOR_CHANGED], 0); +} diff --git a/src/wayland/meta-wayland-surface.h b/src/wayland/meta-wayland-surface.h index 7e8814c23..4a54afe78 100644 --- a/src/wayland/meta-wayland-surface.h +++ b/src/wayland/meta-wayland-surface.h @@ -335,6 +335,8 @@ void meta_wayland_surface_notify_unmapped (MetaWaylandSurface *su void meta_wayland_surface_update_outputs_recursively (MetaWaylandSurface *surface); +void meta_wayland_surface_notify_actor_changed (MetaWaylandSurface *surface); + int meta_wayland_surface_get_width (MetaWaylandSurface *surface); int meta_wayland_surface_get_height (MetaWaylandSurface *surface);