mirror of
https://github.com/brl/mutter.git
synced 2024-12-27 21:32:14 +00:00
wayland/idle-inhibit: Change to use GObject signals
Fixes: 388b534062
("wayland: Implement idle inhibit protocol")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3219>
This commit is contained in:
parent
45abae7ebb
commit
170ba63dbf
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user