diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c index 2fbedcb5f..d9fc63ce3 100644 --- a/src/backends/meta-backend.c +++ b/src/backends/meta-backend.c @@ -316,7 +316,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 1b3e13fde..d8b8976c5 100644 --- a/src/backends/meta-input-settings-private.h +++ b/src/backends/meta-input-settings-private.h @@ -101,7 +101,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 450678204..e6279f37f 100644 --- a/src/backends/meta-input-settings.c +++ b/src/backends/meta-input-settings.c @@ -1043,7 +1043,7 @@ meta_input_settings_init (MetaInputSettings *settings) } } -MetaInputSettings * +static MetaInputSettings * meta_input_settings_create (void) { #ifdef HAVE_NATIVE_BACKEND @@ -1060,6 +1060,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)