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

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