gdm/wayland-only.patch
Ray Strode ca22418437 Drop Xorg support
Resolves: RHEL-31479
2024-07-26 16:23:20 -04:00

312 lines
11 KiB
Diff

From a5dcb9699cbb18c70da0a6ee57faa20124130787 Mon Sep 17 00:00:00 2001
From: rpm-build <rpm-build>
Date: Fri, 26 Jul 2024 16:21:35 -0400
Subject: [PATCH] wayland-only.patch
---
daemon/gdm-local-display-factory.c | 12 +++++++++++-
libgdm/gdm-sessions.c | 20 ++++++++++++--------
2 files changed, 23 insertions(+), 9 deletions(-)
diff --git a/daemon/gdm-local-display-factory.c b/daemon/gdm-local-display-factory.c
index f2d8e15..cfbd598 100644
--- a/daemon/gdm-local-display-factory.c
+++ b/daemon/gdm-local-display-factory.c
@@ -192,75 +192,81 @@ take_next_display_number (GdmLocalDisplayFactory *factory)
/* now reserve this number */
g_debug ("GdmLocalDisplayFactory: Reserving X display: %u", ret);
g_hash_table_insert (factory->used_display_numbers, GUINT_TO_POINTER (ret), NULL);
return ret;
}
static char *
get_preferred_display_server (GdmLocalDisplayFactory *factory)
{
g_autofree gchar *preferred_display_server = NULL;
gboolean wayland_enabled = FALSE, xorg_enabled = FALSE;
gdm_settings_direct_get_boolean (GDM_KEY_WAYLAND_ENABLE, &wayland_enabled);
gdm_settings_direct_get_boolean (GDM_KEY_XORG_ENABLE, &xorg_enabled);
if (wayland_enabled && !xorg_enabled) {
return g_strdup ("wayland");
}
if (!wayland_enabled && !xorg_enabled) {
return g_strdup ("none");
}
gdm_settings_direct_get_string (GDM_KEY_PREFERRED_DISPLAY_SERVER, &preferred_display_server);
if (g_strcmp0 (preferred_display_server, "wayland") == 0) {
if (wayland_enabled)
return g_strdup (preferred_display_server);
+#ifdef ENABLE_XORG_SUPPORT
else
return g_strdup ("xorg");
+#endif
}
if (g_strcmp0 (preferred_display_server, "xorg") == 0) {
+#ifdef ENABLE_XORG_SUPPORT
if (xorg_enabled)
return g_strdup (preferred_display_server);
else
+#endif
return g_strdup ("wayland");
}
+#ifdef ENABLE_XORG_SUPPORT
if (g_strcmp0 (preferred_display_server, "legacy-xorg") == 0) {
if (xorg_enabled)
return g_strdup (preferred_display_server);
}
+#endif
return g_strdup ("none");
}
struct GdmDisplayServerConfiguration {
const char *display_server;
const char *key;
const char *binary;
const char *session_type;
} display_server_configuration[] = {
#ifdef ENABLE_WAYLAND_SUPPORT
{ "wayland", GDM_KEY_WAYLAND_ENABLE, "/usr/bin/Xwayland", "wayland" },
#endif
{ "xorg", GDM_KEY_XORG_ENABLE, "/usr/bin/Xorg", "x11" },
{ NULL, NULL, NULL },
};
static gboolean
display_server_enabled (GdmLocalDisplayFactory *factory,
const char *display_server)
{
size_t i;
for (i = 0; display_server_configuration[i].display_server != NULL; i++) {
const char *key = display_server_configuration[i].key;
const char *binary = display_server_configuration[i].binary;
gboolean enabled = FALSE;
if (!g_str_equal (display_server_configuration[i].display_server,
display_server))
@@ -289,74 +295,78 @@ get_session_type_for_display_server (GdmLocalDisplayFactory *factory,
display_server))
continue;
return display_server_configuration[i].session_type;
}
return NULL;
}
static char **
gdm_local_display_factory_get_session_types (GdmLocalDisplayFactory *factory,
gboolean should_fall_back)
{
g_autofree gchar *preferred_display_server = NULL;
const char *fallback_display_server = NULL;
gboolean wayland_preferred = FALSE;
gboolean xorg_preferred = FALSE;
g_autoptr (GPtrArray) session_types_array = NULL;
char **session_types;
session_types_array = g_ptr_array_new ();
preferred_display_server = get_preferred_display_server (factory);
g_debug ("GdmLocalDisplayFactory: Getting session type (prefers %s, falling back: %s)",
preferred_display_server, should_fall_back? "yes" : "no");
wayland_preferred = g_str_equal (preferred_display_server, "wayland");
xorg_preferred = g_str_equal (preferred_display_server, "xorg");
+#ifdef ENABLE_XORG_SUPPORT
if (wayland_preferred)
fallback_display_server = "xorg";
else if (xorg_preferred)
fallback_display_server = "wayland";
else
return NULL;
+#endif
- if (!should_fall_back) {
+ if (!should_fall_back || fallback_display_server == NULL) {
if (display_server_enabled (factory, preferred_display_server))
g_ptr_array_add (session_types_array, (gpointer) get_session_type_for_display_server (factory, preferred_display_server));
}
+#ifdef ENABLE_XORG_SUPPORT
if (display_server_enabled (factory, fallback_display_server))
g_ptr_array_add (session_types_array, (gpointer) get_session_type_for_display_server (factory, fallback_display_server));
+#endif
if (session_types_array->len == 0)
return NULL;
g_ptr_array_add (session_types_array, NULL);
session_types = g_strdupv ((char **) session_types_array->pdata);
return session_types;
}
static void
on_display_disposed (GdmLocalDisplayFactory *factory,
GdmDisplay *display)
{
g_debug ("GdmLocalDisplayFactory: Display %p disposed", display);
}
static void
store_display (GdmLocalDisplayFactory *factory,
GdmDisplay *display)
{
GdmDisplayStore *store;
store = gdm_display_factory_get_display_store (GDM_DISPLAY_FACTORY (factory));
gdm_display_store_add (store, display);
}
/*
Example:
diff --git a/libgdm/gdm-sessions.c b/libgdm/gdm-sessions.c
index 0aedcf9..211b6f6 100644
--- a/libgdm/gdm-sessions.c
+++ b/libgdm/gdm-sessions.c
@@ -304,115 +304,119 @@ collect_sessions_from_directory (const char *dirname)
g_autofree char *other_path = g_build_filename (dirname, other_name, NULL);
if (g_file_test (other_path, G_FILE_TEST_EXISTS)) {
g_debug ("Running under X11, ignoring %s", filename);
continue;
}
}
}
id = g_strndup (filename, strlen (filename) - strlen (".desktop"));
full_path = g_build_filename (dirname, filename, NULL);
load_session_file (id, full_path);
g_free (id);
g_free (full_path);
}
g_dir_close (dir);
}
static void
collect_sessions (void)
{
g_autoptr(GHashTable) names_seen_before = NULL;
g_autoptr(GPtrArray) xorg_search_array = NULL;
g_autoptr(GPtrArray) wayland_search_array = NULL;
gchar *session_dir = NULL;
int i;
- const char *xorg_search_dirs[] = {
- "/etc/X11/sessions/",
- DMCONFDIR "/Sessions/",
- DATADIR "/gdm/BuiltInSessions/",
- DATADIR "/xsessions/",
- };
const gchar *supported_session_types_env = NULL;
g_auto (GStrv) supported_session_types = NULL;
+ const gchar * const *system_data_dirs = g_get_system_data_dirs ();
supported_session_types_env = g_getenv ("GDM_SUPPORTED_SESSION_TYPES");
if (supported_session_types_env != NULL) {
supported_session_types = g_strsplit (supported_session_types_env, ":", -1);
}
names_seen_before = g_hash_table_new (g_str_hash, g_str_equal);
- xorg_search_array = g_ptr_array_new_with_free_func (g_free);
- const gchar * const *system_data_dirs = g_get_system_data_dirs ();
+#ifdef ENABLE_XORG_SUPPORT
+ const char *xorg_search_dirs[] = {
+ "/etc/X11/sessions/",
+ DMCONFDIR "/Sessions/",
+ DATADIR "/gdm/BuiltInSessions/",
+ DATADIR "/xsessions/",
+ };
+ xorg_search_array = g_ptr_array_new_with_free_func (g_free);
for (i = 0; system_data_dirs[i]; i++) {
session_dir = g_build_filename (system_data_dirs[i], "xsessions", NULL);
g_ptr_array_add (xorg_search_array, session_dir);
}
for (i = 0; i < G_N_ELEMENTS (xorg_search_dirs); i++) {
g_ptr_array_add (xorg_search_array, g_strdup (xorg_search_dirs[i]));
}
+#endif
#ifdef ENABLE_WAYLAND_SUPPORT
const char *wayland_search_dirs[] = {
DATADIR "/wayland-sessions/",
};
wayland_search_array = g_ptr_array_new_with_free_func (g_free);
for (i = 0; system_data_dirs[i]; i++) {
session_dir = g_build_filename (system_data_dirs[i], "wayland-sessions", NULL);
g_ptr_array_add (wayland_search_array, session_dir);
}
for (i = 0; i < G_N_ELEMENTS (wayland_search_dirs); i++) {
g_ptr_array_add (wayland_search_array, g_strdup (wayland_search_dirs[i]));
}
#endif
if (gdm_available_sessions_map == NULL) {
gdm_available_sessions_map = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, (GDestroyNotify)gdm_session_file_free);
}
+#ifdef ENABLE_XORG_SUPPORT
if (!supported_session_types || g_strv_contains ((const char * const *) supported_session_types, "x11")) {
for (i = xorg_search_array->len - 1; i >= 0; i--) {
collect_sessions_from_directory (g_ptr_array_index (xorg_search_array, i));
}
}
+#endif
#ifdef ENABLE_WAYLAND_SUPPORT
#ifdef ENABLE_USER_DISPLAY_SERVER
if (!supported_session_types || g_strv_contains ((const char * const *) supported_session_types, "wayland")) {
for (i = wayland_search_array->len - 1; i >= 0; i--) {
collect_sessions_from_directory (g_ptr_array_index (wayland_search_array, i));
}
}
#endif
#endif
g_hash_table_foreach_remove (gdm_available_sessions_map,
remove_duplicate_sessions,
names_seen_before);
}
static gint
compare_session_ids (gconstpointer a,
gconstpointer b)
{
GdmSessionFile *session_a, *session_b;
session_a = (GdmSessionFile *) g_hash_table_lookup (gdm_available_sessions_map, a);
session_b = (GdmSessionFile *) g_hash_table_lookup (gdm_available_sessions_map, b);
if (session_a == NULL)
return -1;
if (session_b == NULL)
return 1;
--
2.44.0