Blame SOURCES/add-driver-selection-api.patch

d9b8ab
From 5c8f7cc3af63cc98a05efec47649f6ab74ca17a0 Mon Sep 17 00:00:00 2001
d9b8ab
From: Adel Gadllah <adel.gadllah@gmail.com>
d9b8ab
Date: Sun, 26 Jul 2015 11:29:10 +0200
d9b8ab
Subject: [PATCH 1/7] backend: Check for a known set of drivers
d9b8ab
d9b8ab
We want to use the Cogl GL3 driver, if possible, and then go through a
d9b8ab
known list of Cogl drivers, before giving up and using COGL_DRIVER_ANY.
d9b8ab
d9b8ab
Based on original patch from Emmanuele Bassi.
d9b8ab
d9b8ab
We have to create and tear down the whole context when trying
d9b8ab
out the drivers though because the extension checks do not happen
d9b8ab
until cogl_context_init.
d9b8ab
d9b8ab
https://bugzilla.gnome.org/show_bug.cgi?id=742678
d9b8ab
---
d9b8ab
 clutter/clutter-backend.c | 69 ++++++++++++++++++++++++++++++++++++++---------
d9b8ab
 1 file changed, 56 insertions(+), 13 deletions(-)
d9b8ab
d9b8ab
diff --git a/clutter/clutter-backend.c b/clutter/clutter-backend.c
d9b8ab
index d255eee..0a4ae1a 100644
d9b8ab
--- a/clutter/clutter-backend.c
d9b8ab
+++ b/clutter/clutter-backend.c
d9b8ab
@@ -257,8 +257,9 @@ clutter_backend_real_font_changed (ClutterBackend *backend)
d9b8ab
 }
d9b8ab
 
d9b8ab
 static gboolean
d9b8ab
-clutter_backend_real_create_context (ClutterBackend  *backend,
d9b8ab
-                                     GError         **error)
d9b8ab
+clutter_backend_do_real_create_context (ClutterBackend  *backend,
d9b8ab
+                                        CoglDriver       driver_id,
d9b8ab
+                                        GError         **error)
d9b8ab
 {
d9b8ab
   ClutterBackendClass *klass;
d9b8ab
   CoglSwapChain *swap_chain;
d9b8ab
@@ -290,6 +291,7 @@ clutter_backend_real_create_context (ClutterBackend  *backend,
d9b8ab
 #endif
d9b8ab
 
d9b8ab
   CLUTTER_NOTE (BACKEND, "Connecting the renderer");
d9b8ab
+  cogl_renderer_set_driver (backend->cogl_renderer, driver_id);
d9b8ab
   if (!cogl_renderer_connect (backend->cogl_renderer, &internal_error))
d9b8ab
     goto error;
d9b8ab
 
d9b8ab
@@ -346,10 +348,6 @@ clutter_backend_real_create_context (ClutterBackend  *backend,
d9b8ab
   if (backend->cogl_context == NULL)
d9b8ab
     goto error;
d9b8ab
 
d9b8ab
-  backend->cogl_source = cogl_glib_source_new (backend->cogl_context,
d9b8ab
-                                               G_PRIORITY_DEFAULT);
d9b8ab
-  g_source_attach (backend->cogl_source, NULL);
d9b8ab
-
d9b8ab
   /* the display owns the renderer and the swap chain */
d9b8ab
   cogl_object_unref (backend->cogl_renderer);
d9b8ab
   cogl_object_unref (swap_chain);
d9b8ab
@@ -372,16 +370,61 @@ error:
d9b8ab
   if (swap_chain != NULL)
d9b8ab
     cogl_object_unref (swap_chain);
d9b8ab
 
d9b8ab
-  if (internal_error != NULL)
d9b8ab
-    g_propagate_error (error, internal_error);
d9b8ab
-  else
d9b8ab
-    g_set_error_literal (error, CLUTTER_INIT_ERROR,
d9b8ab
-                         CLUTTER_INIT_ERROR_BACKEND,
d9b8ab
-                         _("Unable to initialize the Clutter backend"));
d9b8ab
-
d9b8ab
   return FALSE;
d9b8ab
 }
d9b8ab
 
d9b8ab
+static gboolean
d9b8ab
+clutter_backend_real_create_context (ClutterBackend  *backend,
d9b8ab
+                                     GError         **error)
d9b8ab
+{
d9b8ab
+  static const struct {
d9b8ab
+    const char *driver_name;
d9b8ab
+    CoglDriver driver_id;
d9b8ab
+  } known_drivers[] = {
d9b8ab
+    { "GL3", COGL_DRIVER_GL3 },
d9b8ab
+    { "GL (Legacy)", COGL_DRIVER_GL },
d9b8ab
+    { "GLES 2.0", COGL_DRIVER_GLES2 },
d9b8ab
+    { "ANY", COGL_DRIVER_ANY },
d9b8ab
+  };
d9b8ab
+
d9b8ab
+  GError *internal_error = NULL;
d9b8ab
+  int i;
d9b8ab
+
d9b8ab
+  for (i = 0; i < G_N_ELEMENTS (known_drivers); i++)
d9b8ab
+    {
d9b8ab
+      CLUTTER_NOTE (BACKEND, "Checking for the %s driver", known_drivers[i].driver_name);
d9b8ab
+
d9b8ab
+      if (clutter_backend_do_real_create_context (backend, known_drivers[i].driver_id, &internal_error))
d9b8ab
+        break;
d9b8ab
+
d9b8ab
+      if (internal_error)
d9b8ab
+        {
d9b8ab
+          CLUTTER_NOTE (BACKEND, "Unable to use the %s driver: %s",
d9b8ab
+                        known_drivers[i].driver_name,
d9b8ab
+                        internal_error->message);
d9b8ab
+          g_clear_error (&internal_error);
d9b8ab
+        }
d9b8ab
+    }
d9b8ab
+
d9b8ab
+  if (backend->cogl_context == NULL)
d9b8ab
+    {
d9b8ab
+      if (internal_error != NULL)
d9b8ab
+        g_propagate_error (error, internal_error);
d9b8ab
+      else
d9b8ab
+        g_set_error_literal (error, CLUTTER_INIT_ERROR,
d9b8ab
+                             CLUTTER_INIT_ERROR_BACKEND,
d9b8ab
+                            _("Unable to initialize the Clutter backend"));
d9b8ab
+
d9b8ab
+      return FALSE;
d9b8ab
+    }
d9b8ab
+
d9b8ab
+  backend->cogl_source = cogl_glib_source_new (backend->cogl_context,
d9b8ab
+                                               G_PRIORITY_DEFAULT);
d9b8ab
+  g_source_attach (backend->cogl_source, NULL);
d9b8ab
+
d9b8ab
+  return TRUE;
d9b8ab
+}
d9b8ab
+
d9b8ab
 static void
d9b8ab
 clutter_backend_real_ensure_context (ClutterBackend *backend,
d9b8ab
                                      ClutterStage   *stage)
d9b8ab
-- 
d9b8ab
2.7.4
d9b8ab
d9b8ab
d9b8ab
From 6b9281ac7da725a1861a6418c24fcb6371d3c72b Mon Sep 17 00:00:00 2001
d9b8ab
From: Emmanuele Bassi <ebassi@gnome.org>
d9b8ab
Date: Wed, 9 Dec 2015 12:45:12 +0000
d9b8ab
Subject: [PATCH 2/7] backend: Allow overriding the Cogl drivers chain
d9b8ab
d9b8ab
We have an hardcoded list of drivers we have to go through when creating
d9b8ab
a Cogl context. Some platforms may expose those drivers, but not be the
d9b8ab
preferred ones.
d9b8ab
d9b8ab
In order to allow users and system integrators to override the list of
d9b8ab
drivers, we should crib the same approach used by GDK, and have an
d9b8ab
environment variable with a list of drivers to try.
d9b8ab
d9b8ab
The new environment variable is called `CLUTTER_DRIVER` and accepts a
d9b8ab
comma-separated list of driver names, which will be tested in sequence
d9b8ab
until one succeeds. There's also an additional '*' token which is used
d9b8ab
to ask Clutter to fall back to the internally defined preferred list of
d9b8ab
drivers.
d9b8ab
d9b8ab
https://bugzilla.gnome.org/show_bug.cgi?id=742678
d9b8ab
---
d9b8ab
 clutter/clutter-backend.c                 | 79 ++++++++++++++++++++++---------
d9b8ab
 doc/reference/clutter/running-clutter.xml | 55 +++++++++++++++++++++
d9b8ab
 2 files changed, 111 insertions(+), 23 deletions(-)
d9b8ab
d9b8ab
diff --git a/clutter/clutter-backend.c b/clutter/clutter-backend.c
d9b8ab
index 0a4ae1a..9ee3659 100644
d9b8ab
--- a/clutter/clutter-backend.c
d9b8ab
+++ b/clutter/clutter-backend.c
d9b8ab
@@ -373,39 +373,73 @@ error:
d9b8ab
   return FALSE;
d9b8ab
 }
d9b8ab
 
d9b8ab
+static const struct {
d9b8ab
+  const char *driver_name;
d9b8ab
+  const char *driver_desc;
d9b8ab
+  CoglDriver driver_id;
d9b8ab
+} all_known_drivers[] = {
d9b8ab
+  { "gl3", "OpenGL 3.2 core profile", COGL_DRIVER_GL3 },
d9b8ab
+  { "gl", "OpenGL legacy profile", COGL_DRIVER_GL },
d9b8ab
+  { "gles2", "OpenGL ES 2.0", COGL_DRIVER_GLES2 },
d9b8ab
+  { "any", "Default Cogl driver", COGL_DRIVER_ANY },
d9b8ab
+};
d9b8ab
+
d9b8ab
+static char *allowed_drivers;
d9b8ab
+
d9b8ab
 static gboolean
d9b8ab
 clutter_backend_real_create_context (ClutterBackend  *backend,
d9b8ab
                                      GError         **error)
d9b8ab
 {
d9b8ab
-  static const struct {
d9b8ab
-    const char *driver_name;
d9b8ab
-    CoglDriver driver_id;
d9b8ab
-  } known_drivers[] = {
d9b8ab
-    { "GL3", COGL_DRIVER_GL3 },
d9b8ab
-    { "GL (Legacy)", COGL_DRIVER_GL },
d9b8ab
-    { "GLES 2.0", COGL_DRIVER_GLES2 },
d9b8ab
-    { "ANY", COGL_DRIVER_ANY },
d9b8ab
-  };
d9b8ab
-
d9b8ab
   GError *internal_error = NULL;
d9b8ab
+  const char *drivers_list;
d9b8ab
+  char **known_drivers;
d9b8ab
+  gboolean allow_any;
d9b8ab
   int i;
d9b8ab
 
d9b8ab
-  for (i = 0; i < G_N_ELEMENTS (known_drivers); i++)
d9b8ab
-    {
d9b8ab
-      CLUTTER_NOTE (BACKEND, "Checking for the %s driver", known_drivers[i].driver_name);
d9b8ab
+  if (allowed_drivers == NULL)
d9b8ab
+    allowed_drivers = "*";
d9b8ab
+
d9b8ab
+  allow_any = strstr (allowed_drivers, "*") != NULL;
d9b8ab
+
d9b8ab
+  drivers_list = g_getenv ("CLUTTER_DRIVER");
d9b8ab
+  if (drivers_list == NULL)
d9b8ab
+    drivers_list = allowed_drivers;
d9b8ab
 
d9b8ab
-      if (clutter_backend_do_real_create_context (backend, known_drivers[i].driver_id, &internal_error))
d9b8ab
-        break;
d9b8ab
+  known_drivers = g_strsplit (drivers_list, ",", 0);
d9b8ab
 
d9b8ab
-      if (internal_error)
d9b8ab
+  for (i = 0; backend->cogl_context == NULL && known_drivers[i] != NULL; i++)
d9b8ab
+    {
d9b8ab
+      const char *driver_name = known_drivers[i];
d9b8ab
+      gboolean is_any = g_str_equal (driver_name, "*");
d9b8ab
+      int j;
d9b8ab
+
d9b8ab
+      for (j = 0; j < G_N_ELEMENTS (all_known_drivers); j++)
d9b8ab
         {
d9b8ab
-          CLUTTER_NOTE (BACKEND, "Unable to use the %s driver: %s",
d9b8ab
-                        known_drivers[i].driver_name,
d9b8ab
-                        internal_error->message);
d9b8ab
-          g_clear_error (&internal_error);
d9b8ab
+          if (!allow_any && !is_any && !strstr (driver_name, all_known_drivers[j].driver_name))
d9b8ab
+            continue;
d9b8ab
+
d9b8ab
+          if ((allow_any && is_any) ||
d9b8ab
+              (is_any && strstr (allowed_drivers, all_known_drivers[j].driver_name)) ||
d9b8ab
+              g_str_equal (all_known_drivers[j].driver_name, driver_name))
d9b8ab
+            {
d9b8ab
+              CLUTTER_NOTE (BACKEND, "Checking for the %s driver", all_known_drivers[j].driver_desc);
d9b8ab
+
d9b8ab
+              if (clutter_backend_do_real_create_context (backend, all_known_drivers[j].driver_id, &internal_error))
d9b8ab
+                break;
d9b8ab
+
d9b8ab
+              if (internal_error)
d9b8ab
+                {
d9b8ab
+                  CLUTTER_NOTE (BACKEND, "Unable to use the %s driver: %s",
d9b8ab
+                                all_known_drivers[j].driver_desc,
d9b8ab
+                                internal_error->message);
d9b8ab
+                  g_clear_error (&internal_error);
d9b8ab
+                }
d9b8ab
+            }
d9b8ab
         }
d9b8ab
     }
d9b8ab
 
d9b8ab
+  g_strfreev (known_drivers);
d9b8ab
+
d9b8ab
   if (backend->cogl_context == NULL)
d9b8ab
     {
d9b8ab
       if (internal_error != NULL)
d9b8ab
@@ -413,13 +447,12 @@ clutter_backend_real_create_context (ClutterBackend  *backend,
d9b8ab
       else
d9b8ab
         g_set_error_literal (error, CLUTTER_INIT_ERROR,
d9b8ab
                              CLUTTER_INIT_ERROR_BACKEND,
d9b8ab
-                            _("Unable to initialize the Clutter backend"));
d9b8ab
+                            _("Unable to initialize the Clutter backend: no available drivers found."));
d9b8ab
 
d9b8ab
       return FALSE;
d9b8ab
     }
d9b8ab
 
d9b8ab
-  backend->cogl_source = cogl_glib_source_new (backend->cogl_context,
d9b8ab
-                                               G_PRIORITY_DEFAULT);
d9b8ab
+  backend->cogl_source = cogl_glib_source_new (backend->cogl_context, G_PRIORITY_DEFAULT);
d9b8ab
   g_source_attach (backend->cogl_source, NULL);
d9b8ab
 
d9b8ab
   return TRUE;
d9b8ab
diff --git a/doc/reference/clutter/running-clutter.xml b/doc/reference/clutter/running-clutter.xml
d9b8ab
index 9d1dc63..2d782b3 100644
d9b8ab
--- a/doc/reference/clutter/running-clutter.xml
d9b8ab
+++ b/doc/reference/clutter/running-clutter.xml
d9b8ab
@@ -27,6 +27,61 @@
d9b8ab
 
d9b8ab
       <variablelist>
d9b8ab
         <varlistentry>
d9b8ab
+          <term>CLUTTER_BACKEND</term>
d9b8ab
+          <listitem>
d9b8ab
+            <para>Changes the windowing system backend used by Clutter.
d9b8ab
+            The allowed values for this environment variable depend on
d9b8ab
+            the configuration options used when compiling Clutter. The
d9b8ab
+            available values are:</para>
d9b8ab
+            <itemizedlist>
d9b8ab
+              <listitem><simpara>x11, for the X11 backend</simpara></listitem>
d9b8ab
+              <listitem><simpara>wayland, for the Wayland backend</simpara></listitem>
d9b8ab
+              <listitem><simpara>win32, for the Windows backend</simpara></listitem>
d9b8ab
+              <listitem><simpara>osx, for the MacOS X backend</simpara></listitem>
d9b8ab
+              <listitem><simpara>gsk, for the GDK backend</simpara></listitem>
d9b8ab
+              <listitem><simpara>eglnative, for the EGL/KMS backend</simpara></listitem>
d9b8ab
+              <listitem><simpara>cex100, for the CEx100 backend</simpara></listitem>
d9b8ab
+            </itemizedlist>
d9b8ab
+            <para>All of the above options except for the <varname>eglnative</varname>
d9b8ab
+            and <varname>cex100</varname> backends also have an input backend.</para>
d9b8ab
+          </listitem>
d9b8ab
+        </varlistentry>
d9b8ab
+        <varlistentry>
d9b8ab
+          <term>CLUTTER_INPUT_BACKEND</term>
d9b8ab
+          <listitem>
d9b8ab
+            <para>Changes the input backend used by Clutter.
d9b8ab
+            The allowed values for this environment variable depend on
d9b8ab
+            the configuration options used when compiling Clutter. The
d9b8ab
+            available values are:</para>
d9b8ab
+            <itemizedlist>
d9b8ab
+              <listitem><simpara>tslib</simpara></listitem>
d9b8ab
+              <listitem><simpara>evdev</simpara></listitem>
d9b8ab
+              <listitem><simpara>null</simpara></listitem>
d9b8ab
+            </itemizedlist>
d9b8ab
+            <para>This environment variable is only useful for setting the input
d9b8ab
+            backend when using a windowing system backend that does not have an
d9b8ab
+            input API, like the <varname>eglnative</varname> or the <varname>cex100</varname>
d9b8ab
+            windowing system backends.</para>
d9b8ab
+          </listitem>
d9b8ab
+        </varlistentry>
d9b8ab
+        <varlistentry>
d9b8ab
+          <term>CLUTTER_DRIVER</term>
d9b8ab
+          <listitem>
d9b8ab
+            <para>Changes the GL driver used when initializing Clutter.
d9b8ab
+            The allowed values for this environment variable are:</para>
d9b8ab
+            <itemizedlist>
d9b8ab
+              <listitem><simpara>gl3, for the GL driver using a 3.2+ core profile</simpara></listitem>
d9b8ab
+              <listitem><simpara>gl, for the GL driver using a legacy profile</simpara></listitem>
d9b8ab
+              <listitem><simpara>gles2, for the GLES 2.0 driver</simpara></listitem>
d9b8ab
+              <listitem><simpara>any, for the default chosen by Cogl</simpara></listitem>
d9b8ab
+            </itemizedlist>
d9b8ab
+            <para>The special '*' value can be used to ask Clutter to use the
d9b8ab
+            default list of drivers, e.g. 'CLUTTER_DRIVER=gles2,*' will ask Clutter
d9b8ab
+            to try the GLES 2.0 driver first, and then fall back to the default list
d9b8ab
+            of Cogl drivers.</para>
d9b8ab
+          </listitem>
d9b8ab
+        </varlistentry>
d9b8ab
+        <varlistentry>
d9b8ab
           <term>CLUTTER_SCALE</term>
d9b8ab
           <listitem>
d9b8ab
             <para>Forces the window scaling factor to that value
d9b8ab
-- 
d9b8ab
2.7.4
d9b8ab
d9b8ab
d9b8ab
From e012c6823f2619d7ce85fb14a773c84b22a5b9fe Mon Sep 17 00:00:00 2001
d9b8ab
From: Emmanuele Bassi <ebassi@gnome.org>
d9b8ab
Date: Wed, 9 Dec 2015 14:26:28 +0000
d9b8ab
Subject: [PATCH 3/7] Add a configuration option for deciding the Cogl drivers
d9b8ab
 to use
d9b8ab
d9b8ab
Using environment variables only is not convenient for all platforms,
d9b8ab
and in some cases it's beneficial to decide the default driver when
d9b8ab
building Clutter. Cogl already has a similar configuration switch, and
d9b8ab
since Clutter is overriding the default Cogl behaviour, it should offer
d9b8ab
the same mechanism.
d9b8ab
d9b8ab
https://bugzilla.gnome.org/show_bug.cgi?id=742678
d9b8ab
---
d9b8ab
 clutter/clutter-backend.c | 2 +-
d9b8ab
 configure.ac              | 9 +++++++++
d9b8ab
 2 files changed, 10 insertions(+), 1 deletion(-)
d9b8ab
d9b8ab
diff --git a/clutter/clutter-backend.c b/clutter/clutter-backend.c
d9b8ab
index 9ee3659..3faae3a 100644
d9b8ab
--- a/clutter/clutter-backend.c
d9b8ab
+++ b/clutter/clutter-backend.c
d9b8ab
@@ -397,7 +397,7 @@ clutter_backend_real_create_context (ClutterBackend  *backend,
d9b8ab
   int i;
d9b8ab
 
d9b8ab
   if (allowed_drivers == NULL)
d9b8ab
-    allowed_drivers = "*";
d9b8ab
+    allowed_drivers = CLUTTER_DRIVERS;
d9b8ab
 
d9b8ab
   allow_any = strstr (allowed_drivers, "*") != NULL;
d9b8ab
 
d9b8ab
diff --git a/configure.ac b/configure.ac
d9b8ab
index 0a62633..fe7e085 100644
d9b8ab
--- a/configure.ac
d9b8ab
+++ b/configure.ac
d9b8ab
@@ -534,6 +534,13 @@ dnl other tools such as glib-mkenums and gir-scanner don't end up
d9b8ab
 dnl using the define also.
d9b8ab
 AC_DEFINE([COGL_ENABLE_EXPERIMENTAL_2_0_API], [1], [Can use Cogl 2.0 API internally])
d9b8ab
 
d9b8ab
+AC_ARG_WITH([default-drivers],
d9b8ab
+            [AS_HELP_STRING([--with-default-drivers=DRIVER], [Comma-separated list of Cogl drivers to use])],
d9b8ab
+            [clutter_drivers=$withval],
d9b8ab
+            [clutter_drivers="*"])
d9b8ab
+
d9b8ab
+AC_DEFINE_UNQUOTED([CLUTTER_DRIVERS], ["$clutter_drivers"], [List of Cogl drivers])
d9b8ab
+
d9b8ab
 dnl strip leading spaces
d9b8ab
 CLUTTER_BACKENDS=${CLUTTER_BACKENDS#* }
d9b8ab
 AC_SUBST(CLUTTER_BACKENDS)
d9b8ab
@@ -1274,6 +1281,8 @@ else
d9b8ab
 echo "        Input backends: ${CLUTTER_INPUT_BACKENDS} (WARNING: Experimental backends enabled)"
d9b8ab
 fi
d9b8ab
 
d9b8ab
+echo "        Cogl drivers: $clutter_drivers"
d9b8ab
+
d9b8ab
 if test "x$SUPPORT_X11" = "x1"; then
d9b8ab
 echo ""
d9b8ab
 echo "     - X11 backend options:"
d9b8ab
-- 
d9b8ab
2.7.4
d9b8ab
d9b8ab
d9b8ab
From 486a1a8a0ddc40c7782c0b0508768b3d8baa12db Mon Sep 17 00:00:00 2001
d9b8ab
From: Emmanuele Bassi <ebassi@gnome.org>
d9b8ab
Date: Thu, 10 Dec 2015 16:52:45 +0000
d9b8ab
Subject: [PATCH 4/7] Allow overriding the list of Cogl drivers via
d9b8ab
 configuration file
d9b8ab
d9b8ab
Clutter has a configuration file that can be used to override
d9b8ab
various settings, including the ones from environment variables.
d9b8ab
---
d9b8ab
 clutter/clutter-backend-private.h |  2 ++
d9b8ab
 clutter/clutter-backend.c         |  8 +++++++-
d9b8ab
 clutter/clutter-main.c            | 11 +++++++++++
d9b8ab
 3 files changed, 20 insertions(+), 1 deletion(-)
d9b8ab
d9b8ab
diff --git a/clutter/clutter-backend-private.h b/clutter/clutter-backend-private.h
d9b8ab
index a9e7ae2..801548b 100644
d9b8ab
--- a/clutter/clutter-backend-private.h
d9b8ab
+++ b/clutter/clutter-backend-private.h
d9b8ab
@@ -142,6 +142,8 @@ gint32                  _clutter_backend_get_units_serial               (Clutter
d9b8ab
 
d9b8ab
 PangoDirection          _clutter_backend_get_keymap_direction           (ClutterBackend         *backend);
d9b8ab
 
d9b8ab
+void                    clutter_set_allowed_drivers                     (const char             *drivers);
d9b8ab
+
d9b8ab
 G_END_DECLS
d9b8ab
 
d9b8ab
 #endif /* __CLUTTER_BACKEND_PRIVATE_H__ */
d9b8ab
diff --git a/clutter/clutter-backend.c b/clutter/clutter-backend.c
d9b8ab
index 3faae3a..34c088d 100644
d9b8ab
--- a/clutter/clutter-backend.c
d9b8ab
+++ b/clutter/clutter-backend.c
d9b8ab
@@ -384,7 +384,7 @@ static const struct {
d9b8ab
   { "any", "Default Cogl driver", COGL_DRIVER_ANY },
d9b8ab
 };
d9b8ab
 
d9b8ab
-static char *allowed_drivers;
d9b8ab
+static const char *allowed_drivers;
d9b8ab
 
d9b8ab
 static gboolean
d9b8ab
 clutter_backend_real_create_context (ClutterBackend  *backend,
d9b8ab
@@ -1492,3 +1492,9 @@ _clutter_backend_get_keymap_direction (ClutterBackend *backend)
d9b8ab
 
d9b8ab
   return PANGO_DIRECTION_NEUTRAL;
d9b8ab
 }
d9b8ab
+
d9b8ab
+void
d9b8ab
+clutter_set_allowed_drivers (const char *drivers)
d9b8ab
+{
d9b8ab
+  allowed_drivers = g_strdup (drivers);
d9b8ab
+}
d9b8ab
diff --git a/clutter/clutter-main.c b/clutter/clutter-main.c
d9b8ab
index 444ceba..11d5150 100644
d9b8ab
--- a/clutter/clutter-main.c
d9b8ab
+++ b/clutter/clutter-main.c
d9b8ab
@@ -229,6 +229,17 @@ clutter_config_read_from_key_file (GKeyFile *keyfile)
d9b8ab
   if (!g_key_file_has_group (keyfile, ENVIRONMENT_GROUP))
d9b8ab
     return;
d9b8ab
 
d9b8ab
+  str_value =
d9b8ab
+    g_key_file_get_string (keyfile, ENVIRONMENT_GROUP,
d9b8ab
+                           "Drivers",
d9b8ab
+                           &key_error);
d9b8ab
+  if (key_error != NULL)
d9b8ab
+    g_clear_error (&key_error);
d9b8ab
+  else
d9b8ab
+    clutter_set_allowed_drivers (str_value);
d9b8ab
+
d9b8ab
+  g_free (str_value);
d9b8ab
+
d9b8ab
   bool_value =
d9b8ab
     g_key_file_get_boolean (keyfile, ENVIRONMENT_GROUP,
d9b8ab
                             "ShowFps",
d9b8ab
-- 
d9b8ab
2.7.4
d9b8ab
d9b8ab
d9b8ab
From f09847882c87b94225d14c058a34bb7faedacd09 Mon Sep 17 00:00:00 2001
d9b8ab
From: Rui Matos <tiagomatos@gmail.com>
d9b8ab
Date: Thu, 11 Aug 2016 15:35:59 +0200
d9b8ab
Subject: [PATCH 5/7] Make clutter_set_allowed_drivers() public
d9b8ab
d9b8ab
We'll need to call it from mutter.
d9b8ab
---
d9b8ab
 clutter/clutter-backend-private.h | 2 --
d9b8ab
 clutter/clutter-backend.h         | 3 +++
d9b8ab
 2 files changed, 3 insertions(+), 2 deletions(-)
d9b8ab
d9b8ab
diff --git a/clutter/clutter-backend-private.h b/clutter/clutter-backend-private.h
d9b8ab
index 801548b..a9e7ae2 100644
d9b8ab
--- a/clutter/clutter-backend-private.h
d9b8ab
+++ b/clutter/clutter-backend-private.h
d9b8ab
@@ -142,8 +142,6 @@ gint32                  _clutter_backend_get_units_serial               (Clutter
d9b8ab
 
d9b8ab
 PangoDirection          _clutter_backend_get_keymap_direction           (ClutterBackend         *backend);
d9b8ab
 
d9b8ab
-void                    clutter_set_allowed_drivers                     (const char             *drivers);
d9b8ab
-
d9b8ab
 G_END_DECLS
d9b8ab
 
d9b8ab
 #endif /* __CLUTTER_BACKEND_PRIVATE_H__ */
d9b8ab
diff --git a/clutter/clutter-backend.h b/clutter/clutter-backend.h
d9b8ab
index e14d5d2..c7dfc24 100644
d9b8ab
--- a/clutter/clutter-backend.h
d9b8ab
+++ b/clutter/clutter-backend.h
d9b8ab
@@ -78,6 +78,9 @@ CLUTTER_AVAILABLE_IN_1_8
d9b8ab
 CoglContext *                   clutter_backend_get_cogl_context        (ClutterBackend             *backend);
d9b8ab
 #endif
d9b8ab
 
d9b8ab
+CLUTTER_AVAILABLE_IN_ALL
d9b8ab
+void                    clutter_set_allowed_drivers                     (const char             *drivers);
d9b8ab
+
d9b8ab
 G_END_DECLS
d9b8ab
 
d9b8ab
 #endif /* __CLUTTER_BACKEND_H__ */
d9b8ab
-- 
d9b8ab
2.7.4
d9b8ab
d9b8ab
d9b8ab
From aa79960d2e79141f0caaa27a48468ed67acd30b2 Mon Sep 17 00:00:00 2001
d9b8ab
From: Rui Matos <tiagomatos@gmail.com>
d9b8ab
Date: Thu, 11 Aug 2016 15:50:30 +0200
d9b8ab
Subject: [PATCH 6/7] backend: Revert to using the gl driver by default instead
d9b8ab
 of gl3
d9b8ab
d9b8ab
Some applications (e.g. totem) don't work well (or at all) with the
d9b8ab
gl3 driver without modifications and it's safer to keep clutter
d9b8ab
behaving the same as it did when RHEL 7 launched so let's switch the
d9b8ab
default driver back to gl.
d9b8ab
---
d9b8ab
 clutter/clutter-backend.c | 2 +-
d9b8ab
 1 file changed, 1 insertion(+), 1 deletion(-)
d9b8ab
d9b8ab
diff --git a/clutter/clutter-backend.c b/clutter/clutter-backend.c
d9b8ab
index 34c088d..15a1d05 100644
d9b8ab
--- a/clutter/clutter-backend.c
d9b8ab
+++ b/clutter/clutter-backend.c
d9b8ab
@@ -378,8 +378,8 @@ static const struct {
d9b8ab
   const char *driver_desc;
d9b8ab
   CoglDriver driver_id;
d9b8ab
 } all_known_drivers[] = {
d9b8ab
-  { "gl3", "OpenGL 3.2 core profile", COGL_DRIVER_GL3 },
d9b8ab
   { "gl", "OpenGL legacy profile", COGL_DRIVER_GL },
d9b8ab
+  { "gl3", "OpenGL 3.2 core profile", COGL_DRIVER_GL3 },
d9b8ab
   { "gles2", "OpenGL ES 2.0", COGL_DRIVER_GLES2 },
d9b8ab
   { "any", "Default Cogl driver", COGL_DRIVER_ANY },
d9b8ab
 };
d9b8ab
-- 
d9b8ab
2.7.4
d9b8ab
d9b8ab
d9b8ab
From 03db9fc0b5035c1c74132b6f33468e8670802558 Mon Sep 17 00:00:00 2001
d9b8ab
From: "Owen W. Taylor" <otaylor@fishsoup.net>
d9b8ab
Date: Wed, 29 Jun 2016 17:03:46 -0400
d9b8ab
Subject: [PATCH 7/7] Don't create the Cogl GLib source multiple times
d9b8ab
d9b8ab
Since the check for backend->cogl_context was accidentally moved
d9b8ab
to clutter_backend_do_real_create_context, the Glib source that
d9b8ab
is created at the end of clutter_backend_do_create_context() is
d9b8ab
created and added each time create_context() is called, though
d9b8ab
create_context() is supposed to be idempotent.
d9b8ab
d9b8ab
https://bugzilla.gnome.org/show_bug.cgi?id=768243
d9b8ab
---
d9b8ab
 clutter/clutter-backend.c | 6 +++---
d9b8ab
 1 file changed, 3 insertions(+), 3 deletions(-)
d9b8ab
d9b8ab
diff --git a/clutter/clutter-backend.c b/clutter/clutter-backend.c
d9b8ab
index 15a1d05..56f2bf2 100644
d9b8ab
--- a/clutter/clutter-backend.c
d9b8ab
+++ b/clutter/clutter-backend.c
d9b8ab
@@ -265,9 +265,6 @@ clutter_backend_do_real_create_context (ClutterBackend  *backend,
d9b8ab
   CoglSwapChain *swap_chain;
d9b8ab
   GError *internal_error;
d9b8ab
 
d9b8ab
-  if (backend->cogl_context != NULL)
d9b8ab
-    return TRUE;
d9b8ab
-
d9b8ab
   klass = CLUTTER_BACKEND_GET_CLASS (backend);
d9b8ab
 
d9b8ab
   swap_chain = NULL;
d9b8ab
@@ -396,6 +393,9 @@ clutter_backend_real_create_context (ClutterBackend  *backend,
d9b8ab
   gboolean allow_any;
d9b8ab
   int i;
d9b8ab
 
d9b8ab
+  if (backend->cogl_context != NULL)
d9b8ab
+    return TRUE;
d9b8ab
+
d9b8ab
   if (allowed_drivers == NULL)
d9b8ab
     allowed_drivers = CLUTTER_DRIVERS;
d9b8ab
 
d9b8ab
-- 
d9b8ab
2.7.4
d9b8ab