summaryrefslogtreecommitdiff
path: root/libgdm
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2021-07-16 12:34:57 -0400
committerRay Strode <rstrode@redhat.com>2021-07-22 13:33:18 -0400
commit04853a3b8c17712cc7f74c3c405ef47af53151c1 (patch)
treebdd174fa2bc01eca932938e8007a9007668cb764 /libgdm
parentf66ff435ab9951c783ff17e16ade0a800cec5497 (diff)
downloadgdm-04853a3b8c17712cc7f74c3c405ef47af53151c1.tar.gz
daemon: Provide more flexibility for configuring display server
There's currently a way to disable wayland, but no way to disable Xorg. We currently prefer wayland if it's not disabled, but have no way to prefer Xorg without disabling wayland entirely. There's currently no way use legacy Xorg support at all if user display server support is enabled at a build time. This commit adds more flexibility to display server selection. It adds two new keys: XorgEnable and and PreferredDisplayServer. XorgEnable=false disables Xorg support entirely on seat 0. PreferredDisplayServer can be set to "wayland", "xorg", "legacy-xorg" or "none" to select which display server is used by default. If it's set to "wayland", it will fall back to "xorg". If it's set to "xorg" it will fall back to "wayland".
Diffstat (limited to 'libgdm')
-rw-r--r--libgdm/gdm-sessions.c72
1 files changed, 52 insertions, 20 deletions
diff --git a/libgdm/gdm-sessions.c b/libgdm/gdm-sessions.c
index 75d442ee..97ed5ef3 100644
--- a/libgdm/gdm-sessions.c
+++ b/libgdm/gdm-sessions.c
@@ -190,6 +190,8 @@ collect_sessions_from_directory (const char *dirname)
gboolean is_x11 = g_getenv ("WAYLAND_DISPLAY") == NULL &&
g_getenv ("RUNNING_UNDER_GDM") != NULL;
+ gboolean is_wayland = g_getenv ("WAYLAND_DISPLAY") != NULL &&
+ g_getenv ("RUNNING_UNDER_GDM") != NULL;
/* FIXME: add file monitor to directory */
@@ -206,18 +208,46 @@ collect_sessions_from_directory (const char *dirname)
continue;
}
- if (is_x11 && g_str_has_suffix (filename, "-xorg.desktop")) {
- char *base_name = g_strndup (filename, strlen (filename) - strlen ("-xorg.desktop"));
- char *fallback_name = g_strconcat (base_name, ".desktop", NULL);
- g_free (base_name);
- char *fallback_path = g_build_filename (dirname, fallback_name, NULL);
- g_free (fallback_name);
- if (g_file_test (fallback_path, G_FILE_TEST_EXISTS)) {
- g_free (fallback_path);
- g_debug ("Running under X11, ignoring %s", filename);
- continue;
+ if (is_wayland) {
+ if (g_str_has_suffix (filename, "-wayland.desktop")) {
+ g_autofree char *base_name = g_strndup (filename, strlen (filename) - strlen ("-wayland.desktop"));
+ g_autofree char *other_name = g_strconcat (base_name, ".desktop", NULL);
+ 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 Wayland, ignoring %s", filename);
+ continue;
+ }
+ } else {
+ g_autofree char *base_name = g_strndup (filename, strlen (filename) - strlen (".desktop"));
+ g_autofree char *other_name = g_strdup_printf ("%s-xorg.desktop", base_name);
+ 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 Wayland, ignoring %s", filename);
+ continue;
+ }
+ }
+ } else if (is_x11) {
+ if (g_str_has_suffix (filename, "-xorg.desktop")) {
+ g_autofree char *base_name = g_strndup (filename, strlen (filename) - strlen ("-xorg.desktop"));
+ g_autofree char *other_name = g_strconcat (base_name, ".desktop", NULL);
+ 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;
+ }
+ } else {
+ g_autofree char *base_name = g_strndup (filename, strlen (filename) - strlen (".desktop"));
+ g_autofree char *other_name = g_strdup_printf ("%s-wayland.desktop", base_name);
+ 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;
+ }
}
- g_free (fallback_path);
}
id = g_strndup (filename, strlen (filename) - strlen (".desktop"));
@@ -247,6 +277,9 @@ collect_sessions (void)
DATADIR "/gdm/BuiltInSessions/",
DATADIR "/xsessions/",
};
+ g_auto (GStrv) supported_session_types = NULL;
+
+ supported_session_types = g_strsplit (g_getenv ("GDM_SUPPORTED_SESSION_TYPES"), ":", -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);
@@ -284,23 +317,22 @@ collect_sessions (void)
g_free, (GDestroyNotify)gdm_session_file_free);
}
- for (i = 0; i < xorg_search_array->len; i++) {
- collect_sessions_from_directory (g_ptr_array_index (xorg_search_array, i));
+ if (!supported_session_types || g_strv_contains ((const char * const *) supported_session_types, "x11")) {
+ for (i = 0; i < xorg_search_array->len; i++) {
+ collect_sessions_from_directory (g_ptr_array_index (xorg_search_array, i));
+ }
}
#ifdef ENABLE_WAYLAND_SUPPORT
#ifdef ENABLE_USER_DISPLAY_SERVER
- if (g_getenv ("WAYLAND_DISPLAY") == NULL && g_getenv ("RUNNING_UNDER_GDM") != NULL) {
- goto out;
+ if (!supported_session_types || g_strv_contains ((const char * const *) supported_session_types, "wayland")) {
+ for (i = 0; i < wayland_search_array->len; i++) {
+ collect_sessions_from_directory (g_ptr_array_index (wayland_search_array, i));
+ }
}
#endif
-
- for (i = 0; i < wayland_search_array->len; i++) {
- collect_sessions_from_directory (g_ptr_array_index (wayland_search_array, i));
- }
#endif
-out:
g_hash_table_foreach_remove (gdm_available_sessions_map,
remove_duplicate_sessions,
names_seen_before);