backend: Set up and use ownership chains
This means objects have an owner, where the chain eventually always leads to a MetaContext. This also means that all objects can find their way to other object instances via the chain, instead of scattered global singletons. This is a squashed commit originally containing the following: cursor-tracker: Don't get backend from singleton idle-manager: Don't get backend from singleton input-device: Pass pointer to backend during construction The backend is needed during construction to get the wacom database. input-mapper: Pass backend when constructing monitor: Don't get backend from singleton monitor-manager: Get backend directly from monitor manager remote: Get backend from manager class For the remote desktop and screen cast implementations, replace getting the backend from singletons with getting it via the manager classes. launcher: Pass backend during construction device-pool: Pass backend during construction Instead of passing the (maybe null) launcher, pass the backend, and get the launcher from there. That way we always have a way to some known context from the device pool. drm-buffer/gbm: Get backend via device pool cursor-renderer: Get backend directly from renderer input-device: Get backend getter input-settings: Add backend construct property and getter input-settings/x11: Don't get backend from singleton renderer: Get backend from renderer itself seat-impl: Add backend getter seat/native: Get backend from instance struct stage-impl: Get backend from stage impl itself x11/xkb-a11y: Don't get backend from singleton backend/x11/nested: Don't get Wayland compositor from singleton crtc: Add backend property Adding a link to the GPU isn't enough; the virtual CRTCs of virtual monitors doesn't have one. cursor-tracker: Don't get display from singleton remote: Don't get display from singleton seat: Don't get display from singleton backend/x11: Don't get display from singleton Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2718>
This commit is contained in:
@ -26,6 +26,8 @@ typedef struct _MetaInputDevicePrivate MetaInputDevicePrivate;
|
||||
|
||||
struct _MetaInputDevicePrivate
|
||||
{
|
||||
MetaBackend *backend;
|
||||
|
||||
#ifdef HAVE_LIBWACOM
|
||||
WacomDevice *wacom_device;
|
||||
#else
|
||||
@ -38,6 +40,7 @@ enum
|
||||
{
|
||||
PROP_0,
|
||||
|
||||
PROP_BACKEND,
|
||||
PROP_WACOM_DEVICE,
|
||||
|
||||
N_PROPS
|
||||
@ -69,7 +72,7 @@ meta_input_device_constructed (GObject *object)
|
||||
#ifdef HAVE_LIBWACOM
|
||||
input_device = META_INPUT_DEVICE (object);
|
||||
priv = meta_input_device_get_instance_private (input_device);
|
||||
wacom_db = meta_backend_get_wacom_database (meta_get_backend ());
|
||||
wacom_db = meta_backend_get_wacom_database (priv->backend);
|
||||
node = clutter_input_device_get_device_node (CLUTTER_INPUT_DEVICE (input_device));
|
||||
priv->wacom_device = libwacom_new_from_path (wacom_db, node,
|
||||
WFALLBACK_NONE, NULL);
|
||||
@ -90,6 +93,26 @@ meta_input_device_finalize (GObject *object)
|
||||
G_OBJECT_CLASS (meta_input_device_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_input_device_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
MetaInputDevicePrivate *priv;
|
||||
|
||||
priv = meta_input_device_get_instance_private (META_INPUT_DEVICE (object));
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_BACKEND:
|
||||
priv->backend = g_value_get_object (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
meta_input_device_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
@ -117,8 +140,17 @@ meta_input_device_class_init (MetaInputDeviceClass *klass)
|
||||
|
||||
object_class->constructed = meta_input_device_constructed;
|
||||
object_class->finalize = meta_input_device_finalize;
|
||||
object_class->set_property = meta_input_device_set_property;
|
||||
object_class->get_property = meta_input_device_get_property;
|
||||
|
||||
props[PROP_BACKEND] =
|
||||
g_param_spec_object ("backend",
|
||||
"backend",
|
||||
"MetaBackend",
|
||||
META_TYPE_BACKEND,
|
||||
G_PARAM_WRITABLE |
|
||||
G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
props[PROP_WACOM_DEVICE] =
|
||||
g_param_spec_pointer ("wacom-device",
|
||||
"Wacom device",
|
||||
@ -140,3 +172,12 @@ meta_input_device_get_wacom_device (MetaInputDevice *input_device)
|
||||
return priv->wacom_device;
|
||||
}
|
||||
#endif /* HAVE_LIBWACOM */
|
||||
|
||||
MetaBackend *
|
||||
meta_input_device_get_backend (MetaInputDevice *input_device)
|
||||
{
|
||||
MetaInputDevicePrivate *priv =
|
||||
meta_input_device_get_instance_private (input_device);
|
||||
|
||||
return priv->backend;
|
||||
}
|
||||
|
Reference in New Issue
Block a user