Blame SOURCES/0004-daemon-Consolidate-session-type-and-supported-sessio.patch

4e44f9
From d76d6ff0761d47df938f1dab0daeeecac2feb56e Mon Sep 17 00:00:00 2001
4e44f9
From: Ray Strode <rstrode@redhat.com>
4e44f9
Date: Mon, 6 Sep 2021 08:43:28 -0400
4e44f9
Subject: [PATCH 4/5] daemon: Consolidate session-type and
4e44f9
 supported-session-types list
4e44f9
4e44f9
There's currently a bug in computing the session-type to use.
4e44f9
4e44f9
The `i > 0` check means wayland will overwrite x11 in the
4e44f9
transient session type list.
4e44f9
4e44f9
Morever, the separation between "session-type" and
4e44f9
"supported-session-types" is a little redundant. Since
4e44f9
supported-session-types is a sorted list, the first item should
4e44f9
always be the same as "session-type".
4e44f9
4e44f9
This commit addresses the bug and the redundant logic, by computing
4e44f9
the supported session types early in the function and indexing into
4e44f9
it to get the session-type.
4e44f9
4e44f9
A future cleanup could probably get rid of session-type entirely.
4e44f9
4e44f9
https://gitlab.gnome.org/GNOME/gdm/-/merge_requests/153
4e44f9
---
4e44f9
 daemon/gdm-local-display-factory.c | 193 +++++++++++++++++------------
4e44f9
 1 file changed, 116 insertions(+), 77 deletions(-)
4e44f9
4e44f9
diff --git a/daemon/gdm-local-display-factory.c b/daemon/gdm-local-display-factory.c
4e44f9
index 141d64c6..eba38671 100644
4e44f9
--- a/daemon/gdm-local-display-factory.c
4e44f9
+++ b/daemon/gdm-local-display-factory.c
4e44f9
@@ -197,164 +197,226 @@ get_preferred_display_server (GdmLocalDisplayFactory *factory)
4e44f9
         }
4e44f9
 
4e44f9
         if (!wayland_enabled && !xorg_enabled) {
4e44f9
                 return g_strdup ("none");
4e44f9
         }
4e44f9
 
4e44f9
         gdm_settings_direct_get_string (GDM_KEY_PREFERRED_DISPLAY_SERVER, &preferred_display_server);
4e44f9
 
4e44f9
         if (g_strcmp0 (preferred_display_server, "wayland") == 0) {
4e44f9
                 if (wayland_enabled)
4e44f9
                         return g_strdup (preferred_display_server);
4e44f9
                 else
4e44f9
                         return g_strdup ("xorg");
4e44f9
         }
4e44f9
 
4e44f9
         if (g_strcmp0 (preferred_display_server, "xorg") == 0) {
4e44f9
                 if (xorg_enabled)
4e44f9
                         return g_strdup (preferred_display_server);
4e44f9
                 else
4e44f9
                         return g_strdup ("wayland");
4e44f9
         }
4e44f9
 
4e44f9
         if (g_strcmp0 (preferred_display_server, "legacy-xorg") == 0) {
4e44f9
                 if (xorg_enabled)
4e44f9
                         return g_strdup (preferred_display_server);
4e44f9
         }
4e44f9
 
4e44f9
         return g_strdup ("none");
4e44f9
 }
4e44f9
 
4e44f9
+struct GdmDisplayServerConfiguration {
4e44f9
+        const char *display_server;
4e44f9
+        const char *key;
4e44f9
+        const char *binary;
4e44f9
+        const char *session_type;
4e44f9
+} display_server_configuration[] = {
4e44f9
+#ifdef ENABLE_WAYLAND_SUPPORT
4e44f9
+        { "wayland", GDM_KEY_WAYLAND_ENABLE, "/usr/bin/Xwayland", "wayland" },
4e44f9
+#endif
4e44f9
+        { "xorg", GDM_KEY_XORG_ENABLE, "/usr/bin/Xorg", "x11" },
4e44f9
+        { NULL, NULL, NULL },
4e44f9
+};
4e44f9
+
4e44f9
+static gboolean
4e44f9
+display_server_enabled (GdmLocalDisplayFactory *factory,
4e44f9
+                        const char             *display_server)
4e44f9
+{
4e44f9
+        size_t i;
4e44f9
+
4e44f9
+        for (i = 0; display_server_configuration[i].display_server != NULL; i++) {
4e44f9
+                const char *key = display_server_configuration[i].key;
4e44f9
+                const char *binary = display_server_configuration[i].binary;
4e44f9
+                gboolean enabled = FALSE;
4e44f9
+
4e44f9
+                if (!g_str_equal (display_server_configuration[i].display_server,
4e44f9
+                                  display_server))
4e44f9
+                        continue;
4e44f9
+
4e44f9
+                if (!gdm_settings_direct_get_boolean (key, &enabled) || !enabled)
4e44f9
+                        return FALSE;
4e44f9
+
4e44f9
+                if (!g_file_test (binary, G_FILE_TEST_IS_EXECUTABLE))
4e44f9
+                        return FALSE;
4e44f9
+
4e44f9
+                return TRUE;
4e44f9
+        }
4e44f9
+
4e44f9
+        return FALSE;
4e44f9
+}
4e44f9
+
4e44f9
 static const char *
4e44f9
-gdm_local_display_factory_get_session_type (GdmLocalDisplayFactory *factory,
4e44f9
-                                            gboolean                should_fall_back)
4e44f9
+get_session_type_for_display_server (GdmLocalDisplayFactory *factory,
4e44f9
+                                     const char             *display_server)
4e44f9
+{
4e44f9
+        size_t i;
4e44f9
+
4e44f9
+        for (i = 0; display_server_configuration[i].display_server != NULL; i++) {
4e44f9
+                if (!g_str_equal (display_server_configuration[i].display_server,
4e44f9
+                                  display_server))
4e44f9
+                        continue;
4e44f9
+
4e44f9
+                return display_server_configuration[i].session_type;
4e44f9
+        }
4e44f9
+
4e44f9
+        return NULL;
4e44f9
+}
4e44f9
+
4e44f9
+static char **
4e44f9
+gdm_local_display_factory_get_session_types (GdmLocalDisplayFactory *factory,
4e44f9
+                                             gboolean                should_fall_back)
4e44f9
 {
4e44f9
-        const char *session_types[3] = { NULL };
4e44f9
-        gsize i, session_type_index = 0;
4e44f9
         g_autofree gchar *preferred_display_server = NULL;
4e44f9
+        const char *fallback_display_server = NULL;
4e44f9
+        gboolean wayland_preferred = FALSE;
4e44f9
+        gboolean xorg_preferred = FALSE;
4e44f9
+        g_autoptr (GPtrArray) session_types_array = NULL;
4e44f9
+        char **session_types;
4e44f9
+
4e44f9
+        session_types_array = g_ptr_array_new ();
4e44f9
 
4e44f9
         preferred_display_server = get_preferred_display_server (factory);
4e44f9
 
4e44f9
-        if (g_strcmp0 (preferred_display_server, "wayland") != 0 &&
4e44f9
-            g_strcmp0 (preferred_display_server, "xorg") != 0)
4e44f9
-              return NULL;
4e44f9
+        g_debug ("GdmLocalDisplayFactory: Getting session type (prefers %s, falling back: %s)",
4e44f9
+                 preferred_display_server, should_fall_back? "yes" : "no");
4e44f9
 
4e44f9
-        for (i = 0; i < G_N_ELEMENTS (session_types) - 1; i++) {
4e44f9
-#ifdef ENABLE_WAYLAND_SUPPORT
4e44f9
-            if (i > 0 ||
4e44f9
-                g_strcmp0 (preferred_display_server, "wayland") == 0) {
4e44f9
-                    gboolean wayland_enabled = FALSE;
4e44f9
-                    if (gdm_settings_direct_get_boolean (GDM_KEY_WAYLAND_ENABLE, &wayland_enabled)) {
4e44f9
-                            if (wayland_enabled && g_file_test ("/usr/bin/Xwayland", G_FILE_TEST_IS_EXECUTABLE)) {
4e44f9
-                                    session_types[i] = "wayland";
4e44f9
-                                    continue;
4e44f9
-                            }
4e44f9
-                    }
4e44f9
-            }
4e44f9
-#endif
4e44f9
+        wayland_preferred = g_str_equal (preferred_display_server, "wayland");
4e44f9
+        xorg_preferred = g_str_equal (preferred_display_server, "xorg");
4e44f9
+
4e44f9
+        if (wayland_preferred)
4e44f9
+                fallback_display_server = "xorg";
4e44f9
+        else if (xorg_preferred)
4e44f9
+                fallback_display_server = "wayland";
4e44f9
+        else
4e44f9
+                return NULL;
4e44f9
 
4e44f9
-            if (i > 0 ||
4e44f9
-                g_strcmp0 (preferred_display_server, "xorg") == 0) {
4e44f9
-                    gboolean xorg_enabled = FALSE;
4e44f9
-                    if (gdm_settings_direct_get_boolean (GDM_KEY_XORG_ENABLE, &xorg_enabled)) {
4e44f9
-                            if (xorg_enabled && g_file_test ("/usr/bin/Xorg", G_FILE_TEST_IS_EXECUTABLE)) {
4e44f9
-                                    session_types[i] = "x11";
4e44f9
-                                    continue;
4e44f9
-                            }
4e44f9
-                    }
4e44f9
-            }
4e44f9
+        if (!should_fall_back) {
4e44f9
+                if (display_server_enabled (factory, preferred_display_server))
4e44f9
+                      g_ptr_array_add (session_types_array, (gpointer) get_session_type_for_display_server (factory, preferred_display_server));
4e44f9
         }
4e44f9
 
4e44f9
-        if (should_fall_back)
4e44f9
-                session_type_index++;
4e44f9
+        if (display_server_enabled (factory, fallback_display_server))
4e44f9
+                g_ptr_array_add (session_types_array, (gpointer) get_session_type_for_display_server (factory, fallback_display_server));
4e44f9
 
4e44f9
-        return session_types[session_type_index];
4e44f9
+        if (session_types_array->len == 0)
4e44f9
+                return NULL;
4e44f9
+
4e44f9
+        g_ptr_array_add (session_types_array, NULL);
4e44f9
+
4e44f9
+        session_types = g_strdupv ((char **) session_types_array->pdata);
4e44f9
+
4e44f9
+        return session_types;
4e44f9
 }
4e44f9
 
4e44f9
 static void
4e44f9
 on_display_disposed (GdmLocalDisplayFactory *factory,
4e44f9
                      GdmDisplay             *display)
4e44f9
 {
4e44f9
         g_debug ("GdmLocalDisplayFactory: Display %p disposed", display);
4e44f9
 }
4e44f9
 
4e44f9
 static void
4e44f9
 store_display (GdmLocalDisplayFactory *factory,
4e44f9
                GdmDisplay             *display)
4e44f9
 {
4e44f9
         GdmDisplayStore *store;
4e44f9
 
4e44f9
         store = gdm_display_factory_get_display_store (GDM_DISPLAY_FACTORY (factory));
4e44f9
         gdm_display_store_add (store, display);
4e44f9
 }
4e44f9
 
4e44f9
 /*
4e44f9
   Example:
4e44f9
   dbus-send --system --dest=org.gnome.DisplayManager \
4e44f9
   --type=method_call --print-reply --reply-timeout=2000 \
4e44f9
   /org/gnome/DisplayManager/Manager \
4e44f9
   org.gnome.DisplayManager.Manager.GetDisplays
4e44f9
 */
4e44f9
 gboolean
4e44f9
 gdm_local_display_factory_create_transient_display (GdmLocalDisplayFactory *factory,
4e44f9
                                                     char                  **id,
4e44f9
                                                     GError                **error)
4e44f9
 {
4e44f9
         gboolean         ret;
4e44f9
         GdmDisplay      *display = NULL;
4e44f9
         gboolean         is_initial = FALSE;
4e44f9
         const char      *session_type;
4e44f9
         g_autofree gchar *preferred_display_server = NULL;
4e44f9
 
4e44f9
         g_return_val_if_fail (GDM_IS_LOCAL_DISPLAY_FACTORY (factory), FALSE);
4e44f9
 
4e44f9
         ret = FALSE;
4e44f9
 
4e44f9
         g_debug ("GdmLocalDisplayFactory: Creating transient display");
4e44f9
 
4e44f9
         preferred_display_server = get_preferred_display_server (factory);
4e44f9
 
4e44f9
 #ifdef ENABLE_USER_DISPLAY_SERVER
4e44f9
         if (g_strcmp0 (preferred_display_server, "wayland") == 0 ||
4e44f9
             g_strcmp0 (preferred_display_server, "xorg") == 0) {
4e44f9
-                session_type = gdm_local_display_factory_get_session_type (factory, FALSE);
4e44f9
+                g_auto(GStrv) session_types = NULL;
4e44f9
 
4e44f9
-                if (session_type == NULL) {
4e44f9
+                session_types = gdm_local_display_factory_get_session_types (factory, FALSE);
4e44f9
+
4e44f9
+                if (session_types == NULL) {
4e44f9
                         g_set_error_literal (error,
4e44f9
                                              GDM_DISPLAY_ERROR,
4e44f9
                                              GDM_DISPLAY_ERROR_GENERAL,
4e44f9
                                              "Both Wayland and Xorg are unavailable");
4e44f9
                         return FALSE;
4e44f9
                 }
4e44f9
 
4e44f9
                 display = gdm_local_display_new ();
4e44f9
-                g_object_set (G_OBJECT (display), "session-type", session_type, NULL);
4e44f9
+                g_object_set (G_OBJECT (display),
4e44f9
+                              "session-type", session_types[0],
4e44f9
+                              "supported-session-types", session_types,
4e44f9
+                              NULL);
4e44f9
                 is_initial = TRUE;
4e44f9
         }
4e44f9
 #endif
4e44f9
         if (g_strcmp0 (preferred_display_server, "legacy-xorg") == 0) {
4e44f9
                 if (display == NULL) {
4e44f9
                         guint32 num;
4e44f9
 
4e44f9
                         num = take_next_display_number (factory);
4e44f9
 
4e44f9
                         display = gdm_legacy_display_new (num);
4e44f9
                 }
4e44f9
         }
4e44f9
 
4e44f9
         if (display == NULL) {
4e44f9
                 g_set_error_literal (error,
4e44f9
                                      GDM_DISPLAY_ERROR,
4e44f9
                                      GDM_DISPLAY_ERROR_GENERAL,
4e44f9
                                      "Invalid preferred display server configured");
4e44f9
                 return FALSE;
4e44f9
         }
4e44f9
 
4e44f9
         g_object_set (display,
4e44f9
                       "seat-id", "seat0",
4e44f9
                       "allow-timed-login", FALSE,
4e44f9
                       "is-initial", is_initial,
4e44f9
                       NULL);
4e44f9
 
4e44f9
         store_display (factory, display);
4e44f9
 
4e44f9
         if (! gdm_display_manage (display)) {
4e44f9
@@ -549,243 +611,220 @@ lookup_prepared_display_by_seat_id (const char *id,
4e44f9
 
4e44f9
         if (status != GDM_DISPLAY_PREPARED)
4e44f9
                 return FALSE;
4e44f9
 
4e44f9
         return lookup_by_seat_id (id, display, user_data);
4e44f9
 }
4e44f9
 
4e44f9
 static int
4e44f9
 on_seat0_graphics_check_timeout (gpointer user_data)
4e44f9
 {
4e44f9
         GdmLocalDisplayFactory *factory = user_data;
4e44f9
 
4e44f9
         factory->seat0_graphics_check_timeout_id = 0;
4e44f9
 
4e44f9
         /* Simply try to re-add seat0. If it is there already (i.e. CanGraphical
4e44f9
          * turned TRUE, then we'll find it and it will not be created again).
4e44f9
          */
4e44f9
         factory->seat0_graphics_check_timed_out = TRUE;
4e44f9
         ensure_display_for_seat (factory, "seat0");
4e44f9
 
4e44f9
         return G_SOURCE_REMOVE;
4e44f9
 }
4e44f9
 
4e44f9
 static void
4e44f9
 ensure_display_for_seat (GdmLocalDisplayFactory *factory,
4e44f9
                          const char             *seat_id)
4e44f9
 {
4e44f9
         int ret;
4e44f9
         gboolean seat_supports_graphics;
4e44f9
         gboolean is_seat0;
4e44f9
-        const char *session_type = "wayland";
4e44f9
+        g_auto (GStrv) session_types = NULL;
4e44f9
+        const char *legacy_session_types[] = { "x11", NULL };
4e44f9
         GdmDisplayStore *store;
4e44f9
         GdmDisplay      *display = NULL;
4e44f9
         g_autofree char *login_session_id = NULL;
4e44f9
         gboolean wayland_enabled = FALSE, xorg_enabled = FALSE;
4e44f9
         g_autofree gchar *preferred_display_server = NULL;
4e44f9
-        gboolean falling_back;
4e44f9
+        gboolean falling_back = FALSE;
4e44f9
 
4e44f9
         gdm_settings_direct_get_boolean (GDM_KEY_WAYLAND_ENABLE, &wayland_enabled);
4e44f9
         gdm_settings_direct_get_boolean (GDM_KEY_XORG_ENABLE, &xorg_enabled);
4e44f9
 
4e44f9
         preferred_display_server = get_preferred_display_server (factory);
4e44f9
 
4e44f9
         if (g_strcmp0 (preferred_display_server, "none") == 0) {
4e44f9
                g_debug ("GdmLocalDisplayFactory: Preferred display server is none, so not creating display");
4e44f9
                return;
4e44f9
         }
4e44f9
 
4e44f9
         ret = sd_seat_can_graphical (seat_id);
4e44f9
 
4e44f9
         if (ret < 0) {
4e44f9
                 g_critical ("Failed to query CanGraphical information for seat %s", seat_id);
4e44f9
                 return;
4e44f9
         }
4e44f9
 
4e44f9
         if (ret == 0) {
4e44f9
                 g_debug ("GdmLocalDisplayFactory: System doesn't currently support graphics");
4e44f9
                 seat_supports_graphics = FALSE;
4e44f9
         } else {
4e44f9
                 g_debug ("GdmLocalDisplayFactory: System supports graphics");
4e44f9
                 seat_supports_graphics = TRUE;
4e44f9
         }
4e44f9
 
4e44f9
         if (g_strcmp0 (seat_id, "seat0") == 0) {
4e44f9
                 is_seat0 = TRUE;
4e44f9
 
4e44f9
                 falling_back = factory->num_failures > 0;
4e44f9
-                session_type = gdm_local_display_factory_get_session_type (factory, falling_back);
4e44f9
+                session_types = gdm_local_display_factory_get_session_types (factory, falling_back);
4e44f9
 
4e44f9
                 g_debug ("GdmLocalDisplayFactory: New displays on seat0 will use %s%s",
4e44f9
-                         session_type, falling_back? " fallback" : "");
4e44f9
+                         session_types[0], falling_back? " fallback" : "");
4e44f9
         } else {
4e44f9
                 is_seat0 = FALSE;
4e44f9
 
4e44f9
                 g_debug ("GdmLocalDisplayFactory: New displays on seat %s will use X11 fallback", seat_id);
4e44f9
                 /* Force legacy X11 for all auxiliary seats */
4e44f9
                 seat_supports_graphics = TRUE;
4e44f9
-                session_type = "x11";
4e44f9
+                session_types = g_strdupv ((char **) legacy_session_types);
4e44f9
         }
4e44f9
 
4e44f9
         /* For seat0, we have a fallback logic to still try starting it after
4e44f9
          * SEAT0_GRAPHICS_CHECK_TIMEOUT seconds. i.e. we simply continue even if
4e44f9
          * CanGraphical is unset.
4e44f9
          * This is ugly, but it means we'll come up eventually in some
4e44f9
          * scenarios where no master device is present.
4e44f9
          * Note that we'll force an X11 fallback even though there might be
4e44f9
          * cases where an wayland capable device is present and simply not marked as
4e44f9
          * master-of-seat. In these cases, this should likely be fixed in the
4e44f9
          * udev rules.
4e44f9
          *
4e44f9
          * At the moment, systemd always sets CanGraphical for non-seat0 seats.
4e44f9
          * This is because non-seat0 seats are defined by having master-of-seat
4e44f9
          * set. This means we can avoid the fallback check for non-seat0 seats,
4e44f9
          * which simplifies the code.
4e44f9
          */
4e44f9
         if (is_seat0) {
4e44f9
                 if (!seat_supports_graphics) {
4e44f9
                         if (!factory->seat0_graphics_check_timed_out) {
4e44f9
                                 if (factory->seat0_graphics_check_timeout_id == 0) {
4e44f9
                                         g_debug ("GdmLocalDisplayFactory: seat0 doesn't yet support graphics.  Waiting %d seconds to try again.", SEAT0_GRAPHICS_CHECK_TIMEOUT);
4e44f9
                                         factory->seat0_graphics_check_timeout_id = g_timeout_add_seconds (SEAT0_GRAPHICS_CHECK_TIMEOUT,
4e44f9
                                                                                                           on_seat0_graphics_check_timeout,
4e44f9
                                                                                                           factory);
4e44f9
 
4e44f9
                                 } else {
4e44f9
                                         /* It is not yet time to force X11 fallback. */
4e44f9
                                         g_debug ("GdmLocalDisplayFactory: seat0 display requested when there is no graphics support before graphics check timeout.");
4e44f9
                                 }
4e44f9
 
4e44f9
                                 return;
4e44f9
                         }
4e44f9
 
4e44f9
                         g_debug ("GdmLocalDisplayFactory: Assuming we can use seat0 for X11 even though system says it doesn't support graphics!");
4e44f9
                         g_debug ("GdmLocalDisplayFactory: This might indicate an issue where the framebuffer device is not tagged as master-of-seat in udev.");
4e44f9
                         seat_supports_graphics = TRUE;
4e44f9
-                        session_type = "x11";
4e44f9
                         wayland_enabled = FALSE;
4e44f9
+                        g_strfreev (session_types);
4e44f9
+                        session_types = g_strdupv ((char **) legacy_session_types);
4e44f9
                 } else {
4e44f9
                         g_clear_handle_id (&factory->seat0_graphics_check_timeout_id, g_source_remove);
4e44f9
                 }
4e44f9
         }
4e44f9
 
4e44f9
         if (!seat_supports_graphics)
4e44f9
                 return;
4e44f9
 
4e44f9
-        if (session_type != NULL)
4e44f9
+        if (session_types != NULL)
4e44f9
                 g_debug ("GdmLocalDisplayFactory: %s login display for seat %s requested",
4e44f9
-                         session_type, seat_id);
4e44f9
+                         session_types[0], seat_id);
4e44f9
         else if (g_strcmp0 (preferred_display_server, "legacy-xorg") == 0)
4e44f9
                 g_debug ("GdmLocalDisplayFactory: Legacy Xorg login display for seat %s requested",
4e44f9
                          seat_id);
4e44f9
 
4e44f9
         store = gdm_display_factory_get_display_store (GDM_DISPLAY_FACTORY (factory));
4e44f9
 
4e44f9
         if (is_seat0)
4e44f9
                 display = gdm_display_store_find (store, lookup_prepared_display_by_seat_id, (gpointer) seat_id);
4e44f9
         else
4e44f9
                 display = gdm_display_store_find (store, lookup_by_seat_id, (gpointer) seat_id);
4e44f9
 
4e44f9
         /* Ensure we don't create the same display more than once */
4e44f9
         if (display != NULL) {
4e44f9
                 g_debug ("GdmLocalDisplayFactory: display already created");
4e44f9
                 return;
4e44f9
         }
4e44f9
 
4e44f9
         /* If we already have a login window, switch to it */
4e44f9
         if (gdm_get_login_window_session_id (seat_id, &login_session_id)) {
4e44f9
                 GdmDisplay *display;
4e44f9
 
4e44f9
                 display = gdm_display_store_find (store,
4e44f9
                                                   lookup_by_session_id,
4e44f9
                                                   (gpointer) login_session_id);
4e44f9
                 if (display != NULL &&
4e44f9
                     (gdm_display_get_status (display) == GDM_DISPLAY_MANAGED ||
4e44f9
                      gdm_display_get_status (display) == GDM_DISPLAY_WAITING_TO_FINISH)) {
4e44f9
                         g_object_set (G_OBJECT (display), "status", GDM_DISPLAY_MANAGED, NULL);
4e44f9
                         g_debug ("GdmLocalDisplayFactory: session %s found, activating.",
4e44f9
                                  login_session_id);
4e44f9
                         gdm_activate_session_by_id (factory->connection, seat_id, login_session_id);
4e44f9
                         return;
4e44f9
                 }
4e44f9
         }
4e44f9
 
4e44f9
         g_debug ("GdmLocalDisplayFactory: Adding display on seat %s", seat_id);
4e44f9
 
4e44f9
 #ifdef ENABLE_USER_DISPLAY_SERVER
4e44f9
         if (g_strcmp0 (preferred_display_server, "wayland") == 0 ||
4e44f9
             g_strcmp0 (preferred_display_server, "xorg") == 0) {
4e44f9
                 if (is_seat0) {
4e44f9
-                        g_autoptr (GPtrArray) supported_session_types = NULL;
4e44f9
-
4e44f9
-                        if (session_type == NULL) {
4e44f9
-                                g_warning ("GdmLocalDisplayFactory: Both Wayland and Xorg sessions are unavailable");
4e44f9
-                                return;
4e44f9
-                        }
4e44f9
-
4e44f9
-                        supported_session_types = g_ptr_array_new ();
4e44f9
-
4e44f9
-                        if (g_strcmp0 (preferred_display_server, "wayland") == 0) {
4e44f9
-                                if (wayland_enabled)
4e44f9
-                                        g_ptr_array_add (supported_session_types, "wayland");
4e44f9
-                        } else {
4e44f9
-                                if (xorg_enabled)
4e44f9
-                                        g_ptr_array_add (supported_session_types, "x11");
4e44f9
-                        }
4e44f9
-
4e44f9
-                        if (!falling_back) {
4e44f9
-                                if (g_strcmp0 (preferred_display_server, "wayland") == 0) {
4e44f9
-                                        if (xorg_enabled)
4e44f9
-                                                g_ptr_array_add (supported_session_types, "x11");
4e44f9
-                                } else {
4e44f9
-                                        if (wayland_enabled)
4e44f9
-                                                g_ptr_array_add (supported_session_types, "wayland");
4e44f9
-                                }
4e44f9
-                        }
4e44f9
-
4e44f9
-                        g_ptr_array_add (supported_session_types, NULL);
4e44f9
-
4e44f9
                         display = gdm_local_display_new ();
4e44f9
-                        g_object_set (G_OBJECT (display), "session-type", session_type, NULL);
4e44f9
-                        g_object_set (G_OBJECT (display), "supported-session-types", supported_session_types->pdata, NULL);
4e44f9
+                        g_object_set (G_OBJECT (display),
4e44f9
+                                      "session-type", session_types[0],
4e44f9
+                                      "supported-session-types", session_types,
4e44f9
+                                      NULL);
4e44f9
                 }
4e44f9
         }
4e44f9
 #endif
4e44f9
 
4e44f9
         if (display == NULL) {
4e44f9
                 guint32 num;
4e44f9
-                const char *supported_session_types[] = { "x11", NULL };
4e44f9
 
4e44f9
                 num = take_next_display_number (factory);
4e44f9
 
4e44f9
                 display = gdm_legacy_display_new (num);
4e44f9
-                g_object_set (G_OBJECT (display), "supported-session-types", supported_session_types, NULL);
4e44f9
+                g_object_set (G_OBJECT (display),
4e44f9
+                              "session-type", legacy_session_types[0],
4e44f9
+                              "supported-session-types", legacy_session_types,
4e44f9
+                              NULL);
4e44f9
         }
4e44f9
 
4e44f9
         g_object_set (display, "seat-id", seat_id, NULL);
4e44f9
         g_object_set (display, "is-initial", is_seat0, NULL);
4e44f9
 
4e44f9
         store_display (factory, display);
4e44f9
 
4e44f9
         /* let store own the ref */
4e44f9
         g_object_unref (display);
4e44f9
 
4e44f9
         if (! gdm_display_manage (display)) {
4e44f9
                 gdm_display_unmanage (display);
4e44f9
         }
4e44f9
 
4e44f9
         return;
4e44f9
 }
4e44f9
 
4e44f9
 static void
4e44f9
 delete_display (GdmLocalDisplayFactory *factory,
4e44f9
                 const char             *seat_id) {
4e44f9
 
4e44f9
         GdmDisplayStore *store;
4e44f9
 
4e44f9
         g_debug ("GdmLocalDisplayFactory: Removing used_display_numbers on seat %s", seat_id);
4e44f9
 
4e44f9
         store = gdm_display_factory_get_display_store (GDM_DISPLAY_FACTORY (factory));
4e44f9
         gdm_display_store_foreach_remove (store, lookup_by_seat_id, (gpointer) seat_id);
4e44f9
 }
4e44f9
 
4e44f9
 static gboolean
4e44f9
-- 
4e44f9
2.34.1
4e44f9