Blame SOURCES/0002-local-display-factory-Add-gdm_local_display_factory_.patch

c90517
From 1541f84c4e782ba5e403dd5fc4cbb2cede9ca568 Mon Sep 17 00:00:00 2001
c90517
From: Hans de Goede <hdegoede@redhat.com>
c90517
Date: Wed, 16 May 2018 14:10:34 +0100
c90517
Subject: [PATCH 02/48] local-display-factory: Add
c90517
 gdm_local_display_factory_use_wayland() helper
c90517
c90517
Factor out the code which decides if Xorg or Wayland should be used into
c90517
a helper function.
c90517
---
c90517
 daemon/gdm-local-display-factory.c | 23 +++++++++++++++--------
c90517
 1 file changed, 15 insertions(+), 8 deletions(-)
c90517
c90517
diff --git a/daemon/gdm-local-display-factory.c b/daemon/gdm-local-display-factory.c
c90517
index 1a9196ee1..b21e3aee0 100644
c90517
--- a/daemon/gdm-local-display-factory.c
c90517
+++ b/daemon/gdm-local-display-factory.c
c90517
@@ -158,60 +158,73 @@ take_next_display_number (GdmLocalDisplayFactory *factory)
c90517
                         ret = num + 1;
c90517
                         break;
c90517
                 }
c90517
         }
c90517
  out:
c90517
 
c90517
         /* now reserve this number */
c90517
         g_debug ("GdmLocalDisplayFactory: Reserving X display: %u", ret);
c90517
         g_hash_table_insert (factory->priv->used_display_numbers, GUINT_TO_POINTER (ret), NULL);
c90517
 
c90517
         return ret;
c90517
 }
c90517
 
c90517
 static void
c90517
 on_display_disposed (GdmLocalDisplayFactory *factory,
c90517
                      GdmDisplay             *display)
c90517
 {
c90517
         g_debug ("GdmLocalDisplayFactory: Display %p disposed", display);
c90517
 }
c90517
 
c90517
 static void
c90517
 store_display (GdmLocalDisplayFactory *factory,
c90517
                GdmDisplay             *display)
c90517
 {
c90517
         GdmDisplayStore *store;
c90517
 
c90517
         store = gdm_display_factory_get_display_store (GDM_DISPLAY_FACTORY (factory));
c90517
         gdm_display_store_add (store, display);
c90517
 }
c90517
 
c90517
+static gboolean
c90517
+gdm_local_display_factory_use_wayland (void)
c90517
+{
c90517
+#ifdef ENABLE_WAYLAND_SUPPORT
c90517
+        gboolean wayland_enabled = FALSE;
c90517
+        if (gdm_settings_direct_get_boolean (GDM_KEY_WAYLAND_ENABLE, &wayland_enabled)) {
c90517
+                if (wayland_enabled && g_file_test ("/usr/bin/Xwayland", G_FILE_TEST_IS_EXECUTABLE) )
c90517
+                        return TRUE;
c90517
+        }
c90517
+#endif
c90517
+        return FALSE;
c90517
+}
c90517
+
c90517
 /*
c90517
   Example:
c90517
   dbus-send --system --dest=org.gnome.DisplayManager \
c90517
   --type=method_call --print-reply --reply-timeout=2000 \
c90517
   /org/gnome/DisplayManager/Manager \
c90517
   org.gnome.DisplayManager.Manager.GetDisplays
c90517
 */
c90517
 gboolean
c90517
 gdm_local_display_factory_create_transient_display (GdmLocalDisplayFactory *factory,
c90517
                                                     char                  **id,
c90517
                                                     GError                **error)
c90517
 {
c90517
         gboolean         ret;
c90517
         GdmDisplay      *display = NULL;
c90517
 
c90517
         g_return_val_if_fail (GDM_IS_LOCAL_DISPLAY_FACTORY (factory), FALSE);
c90517
 
c90517
         ret = FALSE;
c90517
 
c90517
         g_debug ("GdmLocalDisplayFactory: Creating transient display");
c90517
 
c90517
 #ifdef ENABLE_USER_DISPLAY_SERVER
c90517
         display = gdm_local_display_new ();
c90517
 #else
c90517
         if (display == NULL) {
c90517
                 guint32 num;
c90517
 
c90517
                 num = take_next_display_number (factory);
c90517
 
c90517
                 display = gdm_legacy_display_new (num);
c90517
@@ -422,68 +435,62 @@ gdm_local_display_factory_sync_seats (GdmLocalDisplayFactory *factory)
c90517
         GVariant *array;
c90517
         GVariantIter iter;
c90517
         const char *seat;
c90517
 
c90517
         result = g_dbus_connection_call_sync (factory->priv->connection,
c90517
                                               "org.freedesktop.login1",
c90517
                                               "/org/freedesktop/login1",
c90517
                                               "org.freedesktop.login1.Manager",
c90517
                                               "ListSeats",
c90517
                                               NULL,
c90517
                                               G_VARIANT_TYPE ("(a(so))"),
c90517
                                               G_DBUS_CALL_FLAGS_NONE,
c90517
                                               -1,
c90517
                                               NULL, &error);
c90517
 
c90517
         if (!result) {
c90517
                 g_warning ("GdmLocalDisplayFactory: Failed to issue method call: %s", error->message);
c90517
                 g_clear_error (&error);
c90517
                 return FALSE;
c90517
         }
c90517
 
c90517
         array = g_variant_get_child_value (result, 0);
c90517
         g_variant_iter_init (&iter, array);
c90517
 
c90517
         while (g_variant_iter_loop (&iter, "(&so)", &seat, NULL)) {
c90517
                 gboolean is_initial;
c90517
                 const char *session_type = NULL;
c90517
 
c90517
                 if (g_strcmp0 (seat, "seat0") == 0) {
c90517
                         is_initial = TRUE;
c90517
-#ifdef ENABLE_WAYLAND_SUPPORT
c90517
-                        gboolean wayland_enabled = FALSE;
c90517
-                        if (gdm_settings_direct_get_boolean (GDM_KEY_WAYLAND_ENABLE, &wayland_enabled)) {
c90517
-                                if (wayland_enabled && g_file_test ("/usr/bin/Xwayland", G_FILE_TEST_IS_EXECUTABLE) ) {
c90517
-                                        session_type = "wayland";
c90517
-                                }
c90517
-                        }
c90517
-#endif
c90517
+                        if (gdm_local_display_factory_use_wayland ())
c90517
+                                session_type = "wayland";
c90517
                 } else {
c90517
                         is_initial = FALSE;
c90517
                 }
c90517
 
c90517
                 create_display (factory, seat, session_type, is_initial);
c90517
         }
c90517
 
c90517
         g_variant_unref (result);
c90517
         g_variant_unref (array);
c90517
         return TRUE;
c90517
 }
c90517
 
c90517
 static void
c90517
 on_seat_new (GDBusConnection *connection,
c90517
              const gchar     *sender_name,
c90517
              const gchar     *object_path,
c90517
              const gchar     *interface_name,
c90517
              const gchar     *signal_name,
c90517
              GVariant        *parameters,
c90517
              gpointer         user_data)
c90517
 {
c90517
         const char *seat;
c90517
 
c90517
         g_variant_get (parameters, "(&s&o)", &seat, NULL);
c90517
         create_display (GDM_LOCAL_DISPLAY_FACTORY (user_data), seat, NULL, FALSE);
c90517
 }
c90517
 
c90517
 static void
c90517
 on_seat_removed (GDBusConnection *connection,
c90517
                  const gchar     *sender_name,
c90517
-- 
c90517
2.26.0
c90517