1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
|
From 57c255f05e1c6141e6c5d108b0d9708fb14fe0a2 Mon Sep 17 00:00:00 2001
From: Myrrh Periwinkle <myrrhperiwinkle@qtmlabs.xyz>
Date: Mon, 26 May 2025 09:48:11 +0700
Subject: [PATCH 1/4] daemon: Replace some seat0 checks with sd_seat_can_tty
Fixes code that checks for seat0 when we actually want to check if the
seat is VT-capable instead.
---
daemon/gdm-local-display-factory.c | 4 ++--
daemon/gdm-session.c | 3 ++-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/daemon/gdm-local-display-factory.c b/daemon/gdm-local-display-factory.c
index e6494d76c..8d1e83c13 100644
--- a/daemon/gdm-local-display-factory.c
+++ b/daemon/gdm-local-display-factory.c
@@ -583,9 +583,9 @@ on_display_status_changed (GdmDisplay *display,
((g_strcmp0 (session_class, "greeter") != 0 &&
(!seat_active_session || g_strcmp0(session_id, seat_active_session) == 0)) ||
#if defined(ENABLE_USER_DISPLAY_SERVER)
- (g_strcmp0 (seat_id, "seat0") == 0 && factory->active_vt == GDM_INITIAL_VT) ||
+ (sd_seat_can_tty (seat_id) && factory->active_vt == GDM_INITIAL_VT) ||
#endif
- g_strcmp0 (seat_id, "seat0") != 0)) {
+ !sd_seat_can_tty (seat_id))) {
/* reset num failures */
factory->num_failures = 0;
diff --git a/daemon/gdm-session.c b/daemon/gdm-session.c
index 33dee7606..e7d2cb0bd 100644
--- a/daemon/gdm-session.c
+++ b/daemon/gdm-session.c
@@ -3661,7 +3661,8 @@ gdm_session_get_display_mode (GdmSession *self)
return GDM_SESSION_DISPLAY_MODE_REUSE_VT;
}
- if (g_strcmp0 (self->display_seat_id, "seat0") != 0) {
+ if (self->display_seat_id != NULL &&
+ !sd_seat_can_tty (self->display_seat_id)) {
return GDM_SESSION_DISPLAY_MODE_LOGIND_MANAGED;
}
--
GitLab
From b137624114ea7b21bb537bd0c8f0784dfe01c1f0 Mon Sep 17 00:00:00 2001
From: Myrrh Periwinkle <myrrhperiwinkle@qtmlabs.xyz>
Date: Sun, 25 May 2025 20:03:30 +0700
Subject: [PATCH 2/4] daemon: Reactivate greeter after opening non-VT user
session
systemd-logind automatically activates newly created sessions on non-VT
seats. Switch back to the greeter session in that case so the greeter
can complete whatever is needed between opening and starting the
session, and switch to the actual session when we start it.
---
daemon/gdm-manager.c | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/daemon/gdm-manager.c b/daemon/gdm-manager.c
index 19a2f1f0e..bdf4ed4d3 100644
--- a/daemon/gdm-manager.c
+++ b/daemon/gdm-manager.c
@@ -1940,6 +1940,13 @@ on_start_user_session (StartUserSessionOperation *operation)
}
}
+ if (gdm_session_get_display_mode (operation->session) == GDM_SESSION_DISPLAY_MODE_LOGIND_MANAGED) {
+ gdm_activate_session_by_id (operation->manager->connection,
+ NULL,
+ gdm_session_get_display_seat_id (operation->session),
+ session_id);
+ }
+
start_user_session (operation->manager, operation);
out:
@@ -1962,7 +1969,7 @@ queue_start_user_session (GdmManager *manager,
g_object_set_data (G_OBJECT (session), "start-user-session-operation", operation);
}
-static void
+static gboolean
start_user_session_if_ready (GdmManager *manager,
GdmSession *session,
const char *service_name)
@@ -1976,6 +1983,8 @@ start_user_session_if_ready (GdmManager *manager,
} else {
g_object_set_data (G_OBJECT (session), "waiting-to-start", GINT_TO_POINTER (TRUE));
}
+
+ return start_when_ready;
}
static void
@@ -2017,6 +2026,8 @@ on_user_session_opened (GdmSession *session,
const char *session_id,
GdmManager *manager)
{
+ gboolean start_when_ready;
+
manager->user_sessions = g_list_append (manager->user_sessions,
g_object_ref (session));
if (g_strcmp0 (service_name, "gdm-autologin") == 0 &&
@@ -2026,7 +2037,20 @@ on_user_session_opened (GdmSession *session,
g_object_set_data (G_OBJECT (session), "start-when-ready", GINT_TO_POINTER (TRUE));
}
- start_user_session_if_ready (manager, session, service_name);
+ start_when_ready = start_user_session_if_ready (manager, session, service_name);
+
+ if (!start_when_ready &&
+ gdm_session_get_display_mode (session) == GDM_SESSION_DISPLAY_MODE_LOGIND_MANAGED) {
+ /* systemd-logind automatically activates newly created sessions on seats
+ * without VTs. Go back to greeter so it can run animations as well as prompt
+ * for terminating conflicting sessions. */
+ GdmDisplay *display = get_display_for_user_session (session);
+
+ gdm_activate_session_by_id (manager->connection,
+ NULL,
+ gdm_session_get_display_seat_id (session),
+ gdm_display_get_session_id (display));
+ }
}
static void
--
GitLab
From 57d6285b2aa03552f27cfe443fa7924ccfb417a4 Mon Sep 17 00:00:00 2001
From: Myrrh Periwinkle <myrrhperiwinkle@qtmlabs.xyz>
Date: Mon, 26 May 2025 08:57:30 +0700
Subject: [PATCH 3/4] daemon: Check for prepared display before creating
non-seat0 display
Fixes an issue where duplicate greeter sessions are created when
multiple sessions on the same non-seat0 seat is terminated.
Checking for managed displays is not needed here since any managed
display should already be registered with systemd-logind and therefore
will be detected by gdm_get_login_window_session_id.
---
daemon/gdm-local-display-factory.c | 25 +------------------------
1 file changed, 1 insertion(+), 24 deletions(-)
diff --git a/daemon/gdm-local-display-factory.c b/daemon/gdm-local-display-factory.c
index 8d1e83c13..9b9b3e8d7 100644
--- a/daemon/gdm-local-display-factory.c
+++ b/daemon/gdm-local-display-factory.c
@@ -669,21 +669,6 @@ lookup_prepared_display_by_seat_id (const char *id,
return lookup_by_seat_id (id, display, user_data);
}
-static gboolean
-lookup_managed_display_by_seat_id (const char *id,
- GdmDisplay *display,
- gpointer user_data)
-{
- int status;
-
- status = gdm_display_get_status (display);
-
- if (status != GDM_DISPLAY_MANAGED)
- return FALSE;
-
- return lookup_by_seat_id (id, display, user_data);
-}
-
#ifdef HAVE_UDEV
static gboolean
udev_is_settled (GdmLocalDisplayFactory *factory)
@@ -795,19 +780,11 @@ GdmDisplay *
get_display_for_seat (GdmLocalDisplayFactory *factory,
const char *seat_id)
{
- GdmDisplay *display;
GdmDisplayStore *store;
- gboolean is_seat0;
store = gdm_display_factory_get_display_store (GDM_DISPLAY_FACTORY (factory));
- is_seat0 = g_strcmp0 (seat_id, "seat0") == 0;
- if (is_seat0)
- display = gdm_display_store_find (store, lookup_prepared_display_by_seat_id, (gpointer) seat_id);
- else
- display = gdm_display_store_find (store, lookup_managed_display_by_seat_id, (gpointer) seat_id);
-
- return display;
+ return gdm_display_store_find (store, lookup_prepared_display_by_seat_id, (gpointer) seat_id);
}
static void
--
GitLab
From b2ba0dd44cd9ab4274f7f7e9a3bb11dbc79a41ac Mon Sep 17 00:00:00 2001
From: Myrrh Periwinkle <myrrhperiwinkle@qtmlabs.xyz>
Date: Mon, 26 May 2025 08:44:30 +0700
Subject: [PATCH 4/4] daemon: Don't switch to greeter if a background non-VT
user session end
---
daemon/gdm-local-display-factory.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/daemon/gdm-local-display-factory.c b/daemon/gdm-local-display-factory.c
index 9b9b3e8d7..188374fd2 100644
--- a/daemon/gdm-local-display-factory.c
+++ b/daemon/gdm-local-display-factory.c
@@ -585,7 +585,7 @@ on_display_status_changed (GdmDisplay *display,
#if defined(ENABLE_USER_DISPLAY_SERVER)
(sd_seat_can_tty (seat_id) && factory->active_vt == GDM_INITIAL_VT) ||
#endif
- !sd_seat_can_tty (seat_id))) {
+ (g_strcmp0 (session_class, "greeter") == 0 && !sd_seat_can_tty (seat_id)))) {
/* reset num failures */
factory->num_failures = 0;
--
GitLab
|