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

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