File gdm-disable-wayland-on-unsupported-chipsets.patch of Package gdm.14058

Index: b/common/Makefile.am
===================================================================
--- a/common/Makefile.am	2018-04-08 20:48:03.795852078 +0800
+++ b/common/Makefile.am	2018-04-08 20:48:08.039731495 +0800
@@ -20,6 +20,8 @@
 	-DGDM_DEFAULTS_CONF=\"$(GDM_DEFAULTS_CONF)\"	\
 	-DGDM_CUSTOM_CONF=\"$(GDM_CUSTOM_CONF)\"	\
 	-DGDM_OLD_CONF=\"$(GDM_OLD_CONF)\"		\
+	-DGDM_RUN_DIR=\"$(GDM_RUN_DIR)\"	\
+	-DGDM_RUNTIME_CONF=\"$(GDM_RUNTIME_CONF)\"	\
 	-DGDM_SESSION_DEFAULT_PATH=\"$(GDM_SESSION_DEFAULT_PATH)\" \
 	$(COMMON_CFLAGS)				\
 	$(NULL)
Index: b/common/gdm-settings-desktop-backend.c
===================================================================
--- a/common/gdm-settings-desktop-backend.c	2018-04-08 20:48:03.795852078 +0800
+++ b/common/gdm-settings-desktop-backend.c	2018-04-08 20:48:08.039731495 +0800
@@ -46,12 +46,90 @@
         guint       save_id;
 };
 
+enum {
+        PROP_0,
+        PROP_FILENAME,
+};
+
 static void     gdm_settings_desktop_backend_class_init (GdmSettingsDesktopBackendClass *klass);
 static void     gdm_settings_desktop_backend_init       (GdmSettingsDesktopBackend      *settings_desktop_backend);
 static void     gdm_settings_desktop_backend_finalize   (GObject                        *object);
 
 G_DEFINE_TYPE (GdmSettingsDesktopBackend, gdm_settings_desktop_backend, GDM_TYPE_SETTINGS_BACKEND)
 
+static void
+_gdm_settings_desktop_backend_set_file_name (GdmSettingsDesktopBackend *backend,
+                                             const char                *filename)
+{
+        gboolean res;
+        GError  *error;
+        char *contents;
+
+        backend->priv = GDM_SETTINGS_DESKTOP_BACKEND_GET_PRIVATE (backend);
+
+        g_free (backend->priv->filename);
+        backend->priv->filename = g_strdup (filename);
+
+        backend->priv->key_file = g_key_file_new ();
+
+        error = NULL;
+        res = g_key_file_load_from_file (backend->priv->key_file,
+                                         backend->priv->filename,
+                                         G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS,
+                                         &error);
+        if (! res) {
+                g_warning ("Unable to load file '%s': %s", backend->priv->filename, error->message);
+        }
+
+        contents = g_key_file_to_data (backend->priv->key_file, NULL, NULL);
+
+        if (contents != NULL) {
+                g_debug ("GdmSettings: %s is:\n%s\n", backend->priv->filename, contents);
+                g_free (contents);
+        }
+
+}
+
+static void
+gdm_settings_desktop_backend_set_property (GObject      *object,
+                                           guint         prop_id,
+                                           const GValue *value,
+                                           GParamSpec   *pspec)
+{
+        GdmSettingsDesktopBackend *self;
+
+        self = GDM_SETTINGS_DESKTOP_BACKEND (object);
+
+        switch (prop_id) {
+                case PROP_FILENAME:
+                        _gdm_settings_desktop_backend_set_file_name (self, g_value_get_string (value));
+                        break;
+                default:
+                        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                        break;
+        }
+}
+
+static void
+gdm_settings_desktop_backend_get_property (GObject      *object,
+                                           guint         prop_id,
+                                           GValue       *value,
+                                           GParamSpec   *pspec)
+{
+        GdmSettingsDesktopBackend *self;
+
+        self = GDM_SETTINGS_DESKTOP_BACKEND (object);
+
+        switch (prop_id) {
+                case PROP_FILENAME:
+                        g_value_set_string (value, self->priv->filename);
+                        break;
+                default:
+                        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                        break;
+        }
+}
+
 static gboolean
 parse_key_string (const char *keystring,
                   char      **group,
@@ -308,41 +386,27 @@
         GObjectClass            *object_class = G_OBJECT_CLASS (klass);
         GdmSettingsBackendClass *backend_class = GDM_SETTINGS_BACKEND_CLASS (klass);
 
+        object_class->get_property = gdm_settings_desktop_backend_get_property;
+        object_class->set_property = gdm_settings_desktop_backend_set_property;
         object_class->finalize = gdm_settings_desktop_backend_finalize;
 
         backend_class->get_value = gdm_settings_desktop_backend_get_value;
         backend_class->set_value = gdm_settings_desktop_backend_set_value;
 
         g_type_class_add_private (klass, sizeof (GdmSettingsDesktopBackendPrivate));
+
+        g_object_class_install_property (object_class,
+                                         PROP_FILENAME,
+                                         g_param_spec_string ("filename",
+                                                              "File Name",
+                                                              "The name of the configuration file",
+                                                              NULL,
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
 }
 
 static void
 gdm_settings_desktop_backend_init (GdmSettingsDesktopBackend *backend)
 {
-        gboolean res;
-        GError  *error;
-        char *contents;
-
-        backend->priv = GDM_SETTINGS_DESKTOP_BACKEND_GET_PRIVATE (backend);
-
-        backend->priv->key_file = g_key_file_new ();
-        backend->priv->filename = g_strdup (GDM_CUSTOM_CONF);
-
-        error = NULL;
-        res = g_key_file_load_from_file (backend->priv->key_file,
-                                         backend->priv->filename,
-                                         G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS,
-                                         &error);
-        if (! res) {
-                g_warning ("Unable to load file '%s': %s", backend->priv->filename, error->message);
-        }
-
-        contents = g_key_file_to_data (backend->priv->key_file, NULL, NULL);
-
-        if (contents != NULL) {
-                g_debug ("GdmSettings: %s is:\n%s\n", backend->priv->filename, contents);
-                g_free (contents);
-        }
 }
 
 static void
@@ -365,11 +429,15 @@
 }
 
 GdmSettingsBackend *
-gdm_settings_desktop_backend_new (void)
+gdm_settings_desktop_backend_new (const char* filename)
 {
         GObject *object;
 
-        object = g_object_new (GDM_TYPE_SETTINGS_DESKTOP_BACKEND, NULL);
+        if (!g_file_test (filename, G_FILE_TEST_IS_REGULAR))
+                return NULL;
 
+        object = g_object_new (GDM_TYPE_SETTINGS_DESKTOP_BACKEND,
+                               "filename", filename,
+                               NULL);
         return GDM_SETTINGS_BACKEND (object);
 }
Index: b/common/gdm-settings-desktop-backend.h
===================================================================
--- a/common/gdm-settings-desktop-backend.h	2018-04-08 20:48:03.795852078 +0800
+++ b/common/gdm-settings-desktop-backend.h	2018-04-08 20:48:08.039731495 +0800
@@ -49,7 +49,7 @@
 
 GType                      gdm_settings_desktop_backend_get_type        (void);
 
-GdmSettingsBackend        *gdm_settings_desktop_backend_new             (void);
+GdmSettingsBackend        *gdm_settings_desktop_backend_new             (const char* filename);
 
 G_END_DECLS
 
Index: b/common/gdm-settings.c
===================================================================
--- a/common/gdm-settings.c	2018-04-08 20:48:03.795852078 +0800
+++ b/common/gdm-settings.c	2018-04-08 20:48:08.039731495 +0800
@@ -43,7 +43,7 @@
 
 struct GdmSettingsPrivate
 {
-        GdmSettingsBackend *backend;
+        GList *backends;
 };
 
 enum {
@@ -80,15 +80,28 @@
 {
         GError  *local_error;
         gboolean res;
+        GList   *l;
 
         g_return_val_if_fail (GDM_IS_SETTINGS (settings), FALSE);
         g_return_val_if_fail (key != NULL, FALSE);
 
         local_error = NULL;
-        res = gdm_settings_backend_get_value (settings->priv->backend,
-                                              key,
-                                              value,
-                                              &local_error);
+
+        for (l = settings->priv->backends; l; l = g_list_next (l)) {
+                GdmSettingsBackend *backend = l->data;
+
+                if (local_error) {
+                        g_error_free (local_error);
+                        local_error = NULL;
+                }
+
+                res = gdm_settings_backend_get_value (backend,
+                                                      key,
+                                                      value,
+                                                      &local_error);
+                if (res)
+                        break;
+        }
         if (! res) {
                 g_propagate_error (error, local_error);
         }
@@ -104,6 +117,7 @@
 {
         GError  *local_error;
         gboolean res;
+        GList   *l;
 
         g_return_val_if_fail (GDM_IS_SETTINGS (settings), FALSE);
         g_return_val_if_fail (key != NULL, FALSE);
@@ -111,10 +125,23 @@
         g_debug ("Setting value %s", key);
 
         local_error = NULL;
-        res = gdm_settings_backend_set_value (settings->priv->backend,
-                                              key,
-                                              value,
-                                              &local_error);
+
+        for (l = settings->priv->backends; l; l = g_list_next (l)) {
+                GdmSettingsBackend *backend = l->data;
+
+                if (local_error) {
+                        g_error_free (local_error);
+                        local_error = NULL;
+                }
+
+                res = gdm_settings_backend_set_value (backend,
+                                                      key,
+                                                      value,
+                                                      &local_error);
+                if (res)
+                        break;
+        }
+
         if (! res) {
                 g_propagate_error (error, local_error);
         }
@@ -162,13 +189,27 @@
 static void
 gdm_settings_init (GdmSettings *settings)
 {
+        GList *l;
+        GdmSettingsBackend *backend;
+
         settings->priv = GDM_SETTINGS_GET_PRIVATE (settings);
 
-        settings->priv->backend = gdm_settings_desktop_backend_new ();
-        g_signal_connect (settings->priv->backend,
-                          "value-changed",
-                          G_CALLBACK (backend_value_changed),
-                          settings);
+        backend = gdm_settings_desktop_backend_new (GDM_CUSTOM_CONF);
+        if (backend)
+                settings->priv->backends = g_list_prepend (NULL, backend);
+
+        backend = gdm_settings_desktop_backend_new (GDM_RUNTIME_CONF);
+        if (backend)
+                settings->priv->backends = g_list_prepend (settings->priv->backends, backend);
+
+        for (l = settings->priv->backends; l; l = g_list_next (l)) {
+                backend = l->data;
+
+                g_signal_connect (backend,
+                                  "value-changed",
+                                  G_CALLBACK (backend_value_changed),
+                                  settings);
+        }
 }
 
 static void
@@ -183,9 +224,9 @@
 
         g_return_if_fail (settings->priv != NULL);
 
-        if (settings->priv->backend != NULL) {
-                g_object_unref (settings->priv->backend);
-        }
+        g_list_foreach (settings->priv->backends, (GFunc) g_object_unref, NULL);
+        g_list_free (settings->priv->backends);
+        settings->priv->backends = NULL;
 
         settings_object = NULL;
 
Index: b/configure.ac
===================================================================
--- a/configure.ac	2018-04-08 20:48:03.795852078 +0800
+++ b/configure.ac	2018-04-08 20:48:08.039731495 +0800
@@ -1424,6 +1424,24 @@
 AC_SUBST(GDM_SCREENSHOT_DIR)
 
 dnl ---------------------------------------------------------------------------
+dnl - runtime conf
+dnl ---------------------------------------------------------------------------
+
+withval=""
+AC_ARG_WITH(runtime_conf,
+            AS_HELP_STRING([--with-runtime-conf=<FILENAME>],
+                           [FILENAME to give to runtime configuration file @<:@default=GDM_RUN_DIR/custom.conf@:>@]))
+
+if test x$withval != x; then
+	GDM_RUNTIME_CONF="$withval"
+else
+	GDM_RUNTIME_CONF="$GDM_RUN_DIR/custom.conf"
+fi
+
+AC_SUBST(GDM_RUNTIME_CONF)
+
+
+dnl ---------------------------------------------------------------------------
 dnl - Finish
 dnl ---------------------------------------------------------------------------
 
Index: b/data/61-gdm.rules
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ b/data/61-gdm.rules	2018-04-08 20:48:46.514902428 +0800
@@ -0,0 +1,17 @@
+# Disable Wayland on specific chipsets
+
+# Cirrus Logic
+ATTR{vendor}=="0x1013", ATTR{device}=="0x00b8", ATTR{subsystem_vendor}=="0x1af4", ATTR{subsystem_device}=="0x1100", RUN+="/bin/sh -c '/bin/mkdir /run/gdm ; /usr/bin/printf \"[daemon]\nWaylandEnable=false\" >> /run/gdm/custom.conf'"
+
+# Matrox Electronics Systems Ltd. MGA G200 server engines
+ATTR{vendor}=="0x102b", ATTR{device}=="0x0522", RUN+="/bin/sh -c '/bin/mkdir /run/gdm ; /usr/bin/printf \"[daemon]\nWaylandEnable=false\" >> /run/gdm/custom.conf'"
+ATTR{vendor}=="0x102b", ATTR{device}=="0x0524", RUN+="/bin/sh -c '/bin/mkdir /run/gdm ; /usr/bin/printf \"[daemon]\nWaylandEnable=false\" >> /run/gdm/custom.conf'"
+ATTR{vendor}=="0x102b", ATTR{device}=="0x0530", RUN+="/bin/sh -c '/bin/mkdir /run/gdm ; /usr/bin/printf \"[daemon]\nWaylandEnable=false\" >> /run/gdm/custom.conf'"
+ATTR{vendor}=="0x102b", ATTR{device}=="0x0532", RUN+="/bin/sh -c '/bin/mkdir /run/gdm ; /usr/bin/printf \"[daemon]\nWaylandEnable=false\" >> /run/gdm/custom.conf'"
+ATTR{vendor}=="0x102b", ATTR{device}=="0x0533", RUN+="/bin/sh -c '/bin/mkdir /run/gdm ; /usr/bin/printf \"[daemon]\nWaylandEnable=false\" >> /run/gdm/custom.conf'"
+ATTR{vendor}=="0x102b", ATTR{device}=="0x0534", RUN+="/bin/sh -c '/bin/mkdir /run/gdm ; /usr/bin/printf \"[daemon]\nWaylandEnable=false\" >> /run/gdm/custom.conf'"
+ATTR{vendor}=="0x102b", ATTR{device}=="0x0536", RUN+="/bin/sh -c '/bin/mkdir /run/gdm ; /usr/bin/printf \"[daemon]\nWaylandEnable=false\" >> /run/gdm/custom.conf'"
+ATTR{vendor}=="0x102b", ATTR{device}=="0x0538", RUN+="/bin/sh -c '/bin/mkdir /run/gdm ; /usr/bin/printf \"[daemon]\nWaylandEnable=false\" >> /run/gdm/custom.conf'"
+
+# ASPEED Technology, Inc.
+ATTR{vendor}=="0x1a03", ATTR{device}=="0x2000", RUN+="/bin/sh -c '/bin/mkdir /run/gdm ; /usr/bin/printf \"[daemon]\nWaylandEnable=false\" >> /run/gdm/custom.conf'"
Index: b/data/Makefile.am
===================================================================
--- a/data/Makefile.am	2018-04-08 20:48:03.795852078 +0800
+++ b/data/Makefile.am	2018-04-08 20:48:08.043735154 +0800
@@ -161,12 +161,16 @@
 pam_files = $(pam_arch_files)
 endif
 
+udevrulesdir = $(prefix)/lib/udev/rules.d
+udevrules_DATA = 61-gdm.rules
+
 EXTRA_DIST +=			\
 	$(dconf_db_files)	\
 	$(schemas_in_files)	\
 	$(schemas_DATA)		\
 	$(dbusconf_in_files)	\
 	$(localealias_DATA)	\
+	$(udevrules_DATA)	\
 	gdm.schemas.in.in	\
 	gdm.conf-custom.in 	\
 	Xsession.in 		\
openSUSE Build Service is sponsored by