wayland: Setup and use ownership chains

As elsewhere, make sure objects that need to have a ownership up to the
context, and use this ownership chain to find relevant components, such
as the backend or the Wayland compositor object instance.

wayland/data-device: Hook up data devices to seats

They are tied to a seat - make that connection in struct fields too, so
that related objects can get to the context via it.

wayland: Don't get Wayland compositor via singleton getter

This means via the ownership chain or equivalent.

xwayland: Hook up manager to Wayland compositor

Same applies to the drag-n-drop struct.

xwayland: Make X11 event handling compositor instance aware

This avoids finding it via singletons in the callee.

xwayland: Don't get Wayland compositor from singleton

xwayland: Pass manager when handling dnd event

window/xwayland: Don't get Wayland compositor from singleton

xwayland/grab-keyboard: Don't get backend from singleton

xwayland: Don't get backend from singleton

wayland: Always get the backend from the context

This means traveling up the ownership chain or equivalent when
necessary.

wayland: Hook up data devices, offers and sources to the compositor

This allows tying them to a context without going through any
singletons.

wayland: Don't get display from singleton

xwayland: Don't get display from singleton

tablet: Don't get display from singleton

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2718>
This commit is contained in:
Jonas Ådahl
2022-05-30 23:48:44 +02:00
committed by Robert Mader
parent dd2beae6a8
commit 2731f0cda4
44 changed files with 635 additions and 202 deletions

View File

@ -34,6 +34,8 @@
typedef struct _MetaWaylandDataSourcePrivate
{
MetaWaylandCompositor *compositor;
struct wl_resource *resource;
MetaWaylandDataOffer *offer;
struct wl_array mime_types;
@ -240,13 +242,15 @@ destroy_data_source (struct wl_resource *resource)
}
MetaWaylandDataSource *
meta_wayland_data_source_new (struct wl_resource *resource)
meta_wayland_data_source_new (MetaWaylandCompositor *compositor,
struct wl_resource *resource)
{
MetaWaylandDataSource *source =
g_object_new (META_TYPE_WAYLAND_DATA_SOURCE, NULL);
MetaWaylandDataSourcePrivate *priv =
meta_wayland_data_source_get_instance_private (source);
priv->compositor = compositor;
meta_wayland_data_source_set_resource (source, resource);
wl_resource_set_implementation (resource, &data_source_interface,
source, destroy_data_source);
@ -521,3 +525,12 @@ meta_wayland_data_source_has_mime_type (MetaWaylandDataSource *source,
return FALSE;
}
MetaWaylandCompositor *
meta_wayland_data_source_get_compositor (MetaWaylandDataSource *source)
{
MetaWaylandDataSourcePrivate *priv =
meta_wayland_data_source_get_instance_private (source);
return priv->compositor;
}