[clutter] Allow setting the default backend from the configuration file



commit e9b5eb3045d335b6ebbfc7443076754447447065
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Fri Dec 11 15:41:35 2015 +0000

    Allow setting the default backend from the configuration file
    
    We should allow a configuration file to set up the initial state of the
    global state, which also implies being able to set the backend.
    
    If the allowed backends have already been set programmatically via the
    clutter_set_windowing_backend(), though, then the application code takes
    precedence, as we assume that the application author knows better than
    us what their code supports or requires.

 clutter/clutter-backend-private.h |    2 ++
 clutter/clutter-backend.c         |    7 +++++++
 clutter/clutter-main.c            |   11 +++++++++++
 3 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/clutter/clutter-backend-private.h b/clutter/clutter-backend-private.h
index eb44941..a2b729c 100644
--- a/clutter/clutter-backend-private.h
+++ b/clutter/clutter-backend-private.h
@@ -155,6 +155,8 @@ void                    _clutter_backend_reset_cogl_framebuffer         (Clutter
 
 void                    clutter_set_allowed_drivers                     (const char             *drivers);
 
+void                    clutter_try_set_windowing_backend               (const char             *drivers);
+
 G_END_DECLS
 
 #endif /* __CLUTTER_BACKEND_PRIVATE_H__ */
diff --git a/clutter/clutter-backend.c b/clutter/clutter-backend.c
index a29976a..bce4e91 100644
--- a/clutter/clutter-backend.c
+++ b/clutter/clutter-backend.c
@@ -1527,6 +1527,13 @@ clutter_set_windowing_backend (const char *backend_type)
   allowed_backends = g_strdup (backend_type);
 }
 
+void
+clutter_try_set_windowing_backend (const char *backend_type)
+{
+  if (allowed_backends == NULL)
+    clutter_set_windowing_backend (backend_type);
+}
+
 PangoDirection
 _clutter_backend_get_keymap_direction (ClutterBackend *backend)
 {
diff --git a/clutter/clutter-main.c b/clutter/clutter-main.c
index d1cf4f0..10fcc20 100644
--- a/clutter/clutter-main.c
+++ b/clutter/clutter-main.c
@@ -223,6 +223,17 @@ clutter_config_read_from_key_file (GKeyFile *keyfile)
 
   str_value =
     g_key_file_get_string (keyfile, ENVIRONMENT_GROUP,
+                           "Backends",
+                           &key_error);
+  if (key_error != NULL)
+    g_clear_error (&key_error);
+  else
+    clutter_try_set_windowing_backend (str_value);
+
+  g_free (str_value);
+
+  str_value =
+    g_key_file_get_string (keyfile, ENVIRONMENT_GROUP,
                            "Drivers",
                            &key_error);
   if (key_error != NULL)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]