1
0
Fork 0

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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3893>
This commit is contained in:
Sebastian Wick 2024-08-29 19:39:27 +02:00 committed by Marge Bot
parent 63fa79c878
commit 7e2627f5d8
2 changed files with 16 additions and 0 deletions

View file

@ -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;

View file

@ -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,