backends: Straighten MetaInputSettings creation

We have "create" and "get" methods, and a "create" vmethod. Make it all
"get" so the backend implementations can keep their own reference without
completely lying.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
This commit is contained in:
Carlos Garnacho 2020-11-19 16:00:12 +01:00 committed by Marge Bot
parent e0444a3d35
commit 7547891a76
5 changed files with 35 additions and 39 deletions

View File

@ -69,7 +69,7 @@ struct _MetaBackendClass
MetaCursorTracker * (* create_cursor_tracker) (MetaBackend *backend);
MetaRenderer * (* create_renderer) (MetaBackend *backend,
GError **error);
MetaInputSettings * (* create_input_settings) (MetaBackend *backend);
MetaInputSettings * (* get_input_settings) (MetaBackend *backend);
gboolean (* grab_device) (MetaBackend *backend,
int device_id,

View File

@ -122,7 +122,6 @@ struct _MetaBackendPrivate
MetaMonitorManager *monitor_manager;
MetaOrientationManager *orientation_manager;
MetaCursorTracker *cursor_tracker;
MetaInputSettings *input_settings;
MetaInputMapper *input_mapper;
MetaRenderer *renderer;
#ifdef HAVE_EGL
@ -202,7 +201,6 @@ meta_backend_finalize (GObject *object)
g_clear_object (&priv->current_device);
g_clear_object (&priv->monitor_manager);
g_clear_object (&priv->orientation_manager);
g_clear_object (&priv->input_settings);
#ifdef HAVE_REMOTE_DESKTOP
g_clear_object (&priv->remote_desktop);
g_clear_object (&priv->screen_cast);
@ -521,21 +519,12 @@ create_device_monitors (MetaBackend *backend,
g_list_free (devices);
}
static MetaInputSettings *
meta_backend_create_input_settings (MetaBackend *backend)
{
return META_BACKEND_GET_CLASS (backend)->create_input_settings (backend);
}
static void
input_mapper_device_mapped_cb (MetaInputMapper *mapper,
ClutterInputDevice *device,
float matrix[6],
MetaBackend *backend)
MetaInputSettings *input_settings)
{
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
MetaInputSettings *input_settings = priv->input_settings;
meta_input_settings_set_device_matrix (input_settings, device, matrix);
}
@ -543,11 +532,8 @@ static void
input_mapper_device_enabled_cb (MetaInputMapper *mapper,
ClutterInputDevice *device,
gboolean enabled,
MetaBackend *backend)
MetaInputSettings *input_settings)
{
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
MetaInputSettings *input_settings = priv->input_settings;
meta_input_settings_set_device_enabled (input_settings, device, enabled);
}
@ -555,11 +541,8 @@ static void
input_mapper_device_aspect_ratio_cb (MetaInputMapper *mapper,
ClutterInputDevice *device,
double aspect_ratio,
MetaBackend *backend)
MetaInputSettings *input_settings)
{
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
MetaInputSettings *input_settings = priv->input_settings;
meta_input_settings_set_device_aspect_ratio (input_settings, device, aspect_ratio);
}
@ -576,6 +559,7 @@ meta_backend_real_post_init (MetaBackend *backend)
{
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
ClutterSeat *seat = clutter_backend_get_default_seat (priv->clutter_backend);
MetaInputSettings *input_settings;
priv->stage = meta_stage_new (backend);
clutter_actor_realize (priv->stage);
@ -599,15 +583,22 @@ meta_backend_real_post_init (MetaBackend *backend)
G_CALLBACK (on_device_removed), backend,
G_CONNECT_AFTER);
priv->input_settings = meta_backend_create_input_settings (backend);
priv->input_mapper = meta_input_mapper_new ();
g_signal_connect (priv->input_mapper, "device-mapped",
G_CALLBACK (input_mapper_device_mapped_cb), backend);
g_signal_connect (priv->input_mapper, "device-enabled",
G_CALLBACK (input_mapper_device_enabled_cb), backend);
g_signal_connect (priv->input_mapper, "device-aspect-ratio",
G_CALLBACK (input_mapper_device_aspect_ratio_cb), backend);
input_settings = meta_backend_get_input_settings (backend);
if (input_settings)
{
g_signal_connect (priv->input_mapper, "device-mapped",
G_CALLBACK (input_mapper_device_mapped_cb),
input_settings);
g_signal_connect (priv->input_mapper, "device-enabled",
G_CALLBACK (input_mapper_device_enabled_cb),
input_settings);
g_signal_connect (priv->input_mapper, "device-aspect-ratio",
G_CALLBACK (input_mapper_device_aspect_ratio_cb),
input_settings);
}
#ifdef HAVE_REMOTE_DESKTOP
priv->dbus_session_watcher = g_object_new (META_TYPE_DBUS_SESSION_WATCHER, NULL);
@ -1521,9 +1512,7 @@ meta_backend_get_input_mapper (MetaBackend *backend)
MetaInputSettings *
meta_backend_get_input_settings (MetaBackend *backend)
{
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
return priv->input_settings;
return META_BACKEND_GET_CLASS (backend)->get_input_settings (backend);
}
/**

View File

@ -259,7 +259,7 @@ meta_backend_native_create_renderer (MetaBackend *backend,
}
static MetaInputSettings *
meta_backend_native_create_input_settings (MetaBackend *backend)
meta_backend_native_get_input_settings (MetaBackend *backend)
{
MetaBackendNative *backend_native = META_BACKEND_NATIVE (backend);
@ -555,7 +555,7 @@ meta_backend_native_class_init (MetaBackendNativeClass *klass)
backend_class->create_monitor_manager = meta_backend_native_create_monitor_manager;
backend_class->get_cursor_renderer = meta_backend_native_get_cursor_renderer;
backend_class->create_renderer = meta_backend_native_create_renderer;
backend_class->create_input_settings = meta_backend_native_create_input_settings;
backend_class->get_input_settings = meta_backend_native_get_input_settings;
backend_class->get_current_logical_monitor = meta_backend_native_get_current_logical_monitor;

View File

@ -46,6 +46,8 @@ struct _MetaBackendX11Cm
char *keymap_variants;
char *keymap_options;
int locked_group;
MetaInputSettings *input_settings;
};
G_DEFINE_TYPE (MetaBackendX11Cm, meta_backend_x11_cm, META_TYPE_BACKEND_X11)
@ -87,8 +89,11 @@ meta_backend_x11_cm_post_init (MetaBackend *backend)
{
MetaBackendClass *parent_backend_class =
META_BACKEND_CLASS (meta_backend_x11_cm_parent_class);
MetaBackendX11Cm *x11_cm = META_BACKEND_X11_CM (backend);
ClutterSeat *seat;
x11_cm->input_settings = g_object_new (META_TYPE_INPUT_SETTINGS_X11, NULL);
parent_backend_class->post_init (backend);
seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
@ -143,9 +148,11 @@ meta_backend_x11_cm_create_cursor_tracker (MetaBackend *backend)
}
static MetaInputSettings *
meta_backend_x11_cm_create_input_settings (MetaBackend *backend)
meta_backend_x11_cm_get_input_settings (MetaBackend *backend)
{
return g_object_new (META_TYPE_INPUT_SETTINGS_X11, NULL);
MetaBackendX11Cm *x11_cm = META_BACKEND_X11_CM (backend);
return x11_cm->input_settings;
}
static void
@ -457,7 +464,7 @@ meta_backend_x11_cm_class_init (MetaBackendX11CmClass *klass)
backend_class->create_monitor_manager = meta_backend_x11_cm_create_monitor_manager;
backend_class->get_cursor_renderer = meta_backend_x11_cm_get_cursor_renderer;
backend_class->create_cursor_tracker = meta_backend_x11_cm_create_cursor_tracker;
backend_class->create_input_settings = meta_backend_x11_cm_create_input_settings;
backend_class->get_input_settings = meta_backend_x11_cm_get_input_settings;
backend_class->update_screen_size = meta_backend_x11_cm_update_screen_size;
backend_class->select_stage_events = meta_backend_x11_cm_select_stage_events;
backend_class->lock_layout_group = meta_backend_x11_cm_lock_layout_group;

View File

@ -84,7 +84,7 @@ meta_backend_x11_nested_get_cursor_renderer (MetaBackend *backend,
}
static MetaInputSettings *
meta_backend_x11_nested_create_input_settings (MetaBackend *backend)
meta_backend_x11_nested_get_input_settings (MetaBackend *backend)
{
return NULL;
}
@ -289,7 +289,7 @@ meta_backend_x11_nested_class_init (MetaBackendX11NestedClass *klass)
backend_class->create_renderer = meta_backend_x11_nested_create_renderer;
backend_class->create_monitor_manager = meta_backend_x11_nested_create_monitor_manager;
backend_class->get_cursor_renderer = meta_backend_x11_nested_get_cursor_renderer;
backend_class->create_input_settings = meta_backend_x11_nested_create_input_settings;
backend_class->get_input_settings = meta_backend_x11_nested_get_input_settings;
backend_class->update_screen_size = meta_backend_x11_nested_update_screen_size;
backend_class->select_stage_events = meta_backend_x11_nested_select_stage_events;
backend_class->lock_layout_group = meta_backend_x11_nested_lock_layout_group;