File gdm-ignore-duplicate-session.patch of Package gdm.7833

Index: gdm-3.26.2.1/libgdm/gdm-sessions.c
===================================================================
--- gdm-3.26.2.1.orig/libgdm/gdm-sessions.c
+++ gdm-3.26.2.1/libgdm/gdm-sessions.c
@@ -202,6 +202,34 @@ collect_sessions_from_directory (const c
         g_dir_close (dir);
 }
 
+static gboolean
+find_translated_name (const char     *id,
+                      GdmSessionFile *session,
+                      char           *translated_name)
+{
+        if (g_str_equal (id, "default"))
+                return FALSE;
+
+        return g_str_equal (session->translated_name, translated_name) ? TRUE : FALSE;
+}
+
+static void
+remove_duplicated_session_name (void)
+{
+        GdmSessionFile *session;
+        char           *translated_name = NULL;
+
+        session = g_hash_table_lookup (gdm_available_sessions_map, "default");
+        if (session)
+                translated_name = session->translated_name;
+
+        if (translated_name) {
+                session = g_hash_table_find (gdm_available_sessions_map, (GHRFunc)find_translated_name, translated_name);
+                if (session)
+                        g_hash_table_remove (gdm_available_sessions_map, session->id);
+        }
+}
+
 static void
 collect_sessions (void)
 {
@@ -233,6 +261,7 @@ collect_sessions (void)
 #ifdef ENABLE_WAYLAND_SUPPORT
 #ifdef ENABLE_USER_DISPLAY_SERVER
         if (g_getenv ("WAYLAND_DISPLAY") == NULL && g_getenv ("RUNNING_UNDER_GDM") != NULL) {
+                remove_duplicated_session_name();
                 return;
         }
 #endif
@@ -241,6 +270,8 @@ collect_sessions (void)
                 collect_sessions_from_directory (wayland_search_dirs [i]);
         }
 #endif
+
+        remove_duplicated_session_name();
 }
 
 /**
openSUSE Build Service is sponsored by