From 170ba63dbf2da3a6c6893bead5f4abbbd1d466ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Mon, 28 Aug 2023 11:52:12 +0200 Subject: [PATCH] wayland/idle-inhibit: Change to use GObject signals Fixes: 388b534062 ("wayland: Implement idle inhibit protocol") Part-of: --- src/wayland/meta-wayland-idle-inhibit.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/wayland/meta-wayland-idle-inhibit.c b/src/wayland/meta-wayland-idle-inhibit.c index fcaeac3d7..cc19508e0 100644 --- a/src/wayland/meta-wayland-idle-inhibit.c +++ b/src/wayland/meta-wayland-idle-inhibit.c @@ -37,7 +37,7 @@ struct _MetaWaylandIdleInhibitor uint32_t cookie; gulong is_obscured_changed_handler; gboolean idle_inhibited; - struct wl_listener surface_destroy_listener; + gulong surface_destroy_handler_id; GCancellable *cancellable; }; @@ -188,18 +188,20 @@ idle_inhibitor_destructor (struct wl_resource *resource) uninhibit_completed, NULL); } + if (inhibitor->surface) - wl_list_remove (&inhibitor->surface_destroy_listener.link); + { + g_clear_signal_handler (&inhibitor->surface_destroy_handler_id, + inhibitor->surface); + } + g_free (inhibitor); } static void -inhibitor_surface_destroyed (struct wl_listener *listener, - void *data) +on_surface_destroyed (MetaWaylandSurface *surface, + MetaWaylandIdleInhibitor *inhibitor) { - MetaWaylandIdleInhibitor *inhibitor = wl_container_of (listener, - inhibitor, - surface_destroy_listener); inhibitor->surface = NULL; } @@ -247,9 +249,10 @@ idle_inhibit_manager_create_inhibitor (struct wl_client *client, inhibitor, idle_inhibitor_destructor); - inhibitor->surface_destroy_listener.notify = inhibitor_surface_destroyed; - wl_resource_add_destroy_listener (surface->resource, - &inhibitor->surface_destroy_listener); + inhibitor->surface_destroy_handler_id = + g_signal_connect (surface, "destroy", + G_CALLBACK (on_surface_destroyed), + inhibitor); }