[mutter/wip/tablet-protocol-v2: 41/48] backends: Turn MetaInputSettings into a singleton
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/tablet-protocol-v2: 41/48] backends: Turn MetaInputSettings into a singleton
- Date: Fri, 13 May 2016 18:10:55 +0000 (UTC)
commit 30732a548adefac97d3fa6b17d7d36a389694a74
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri May 13 13:31:52 2016 +0200
backends: Turn MetaInputSettings into a singleton
We will need to fetch information from it at certain places.
The MetaBackend still takes care of freeing it though.
src/backends/meta-backend.c | 2 +-
src/backends/meta-input-settings-private.h | 2 +-
src/backends/meta-input-settings.c | 16 +++++++++++++++-
3 files changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c
index 93c8ad3..1188504 100644
--- a/src/backends/meta-backend.c
+++ b/src/backends/meta-backend.c
@@ -314,7 +314,7 @@ meta_backend_real_post_init (MetaBackend *backend)
g_slist_free (devices);
}
- priv->input_settings = meta_input_settings_create ();
+ priv->input_settings = meta_input_settings_get ();
center_pointer (backend);
}
diff --git a/src/backends/meta-input-settings-private.h b/src/backends/meta-input-settings-private.h
index 897ebde..f0429fc 100644
--- a/src/backends/meta-input-settings-private.h
+++ b/src/backends/meta-input-settings-private.h
@@ -99,7 +99,7 @@ struct _MetaInputSettingsClass
GType meta_input_settings_get_type (void) G_GNUC_CONST;
-MetaInputSettings * meta_input_settings_create (void);
+MetaInputSettings * meta_input_settings_get (void);
GDesktopTabletMapping meta_input_settings_get_tablet_mapping (MetaInputSettings *settings,
ClutterInputDevice *device);
diff --git a/src/backends/meta-input-settings.c b/src/backends/meta-input-settings.c
index 42d799f..4695911 100644
--- a/src/backends/meta-input-settings.c
+++ b/src/backends/meta-input-settings.c
@@ -1030,7 +1030,7 @@ meta_input_settings_init (MetaInputSettings *settings)
}
}
-MetaInputSettings *
+static MetaInputSettings *
meta_input_settings_create (void)
{
#ifdef HAVE_NATIVE_BACKEND
@@ -1047,6 +1047,20 @@ meta_input_settings_create (void)
return NULL;
}
+MetaInputSettings *
+meta_input_settings_get (void)
+{
+ static MetaInputSettings *input_settings = NULL;
+
+ if (g_once_init_enter (&input_settings))
+ {
+ MetaInputSettings *settings = meta_input_settings_create ();
+ g_once_init_leave (&input_settings, settings);
+ }
+
+ return input_settings;
+}
+
GDesktopTabletMapping
meta_input_settings_get_tablet_mapping (MetaInputSettings *settings,
ClutterInputDevice *device)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]