From 7e2627f5d8076be5d55c30c9cfa37c6c77dae7a7 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Thu, 29 Aug 2024 19:39:27 +0200 Subject: [PATCH] wayland: Set the WaylandCompositor as wl_clients user_data This makes it easier to get references to components in wayland callbacks where the resource is inert and thus has a user_data of NULL. Part-of: --- src/wayland/meta-wayland-private.h | 1 + src/wayland/meta-wayland.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/wayland/meta-wayland-private.h b/src/wayland/meta-wayland-private.h index e8d442c03..d65ea5ef5 100644 --- a/src/wayland/meta-wayland-private.h +++ b/src/wayland/meta-wayland-private.h @@ -88,6 +88,7 @@ struct _MetaWaylandCompositor struct wl_display *wayland_display; char *display_name; GSource *source; + struct wl_listener client_created_listener; GHashTable *outputs; GList *frame_callback_surfaces; diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c index d42cbd16c..a0d390fdc 100644 --- a/src/wayland/meta-wayland.c +++ b/src/wayland/meta-wayland.c @@ -660,6 +660,17 @@ meta_wayland_log_func (const char *fmt, g_free (str); } +static void +on_client_created (struct wl_listener *listener, + void *user_data) +{ + struct wl_client *client = user_data; + MetaWaylandCompositor *compositor = + wl_container_of (listener, compositor, client_created_listener); + + wl_client_set_user_data (client, compositor, NULL); +} + void meta_wayland_compositor_prepare_shutdown (MetaWaylandCompositor *compositor) { @@ -718,6 +729,10 @@ meta_wayland_compositor_init (MetaWaylandCompositor *compositor) if (compositor->wayland_display == NULL) g_error ("Failed to create the global wl_display"); + compositor->client_created_listener.notify = on_client_created; + wl_display_add_client_created_listener (compositor->wayland_display, + &compositor->client_created_listener); + priv->filter_manager = meta_wayland_filter_manager_new (compositor); priv->frame_callback_sources = g_hash_table_new_full (NULL, NULL, NULL,