]> git.pld-linux.org Git - packages/kde4-kdebase-workspace.git/blame - kde4-kdebase-workspace-kdm_plymouth081.patch
- drop enlightenment reqs
[packages/kde4-kdebase-workspace.git] / kde4-kdebase-workspace-kdm_plymouth081.patch
CommitLineData
56654046
JR
1diff --git a/kdm/backend/dm.c b/kdm/backend/dm.c
2index e0f1366..5a5f8a7 100644
3--- a/kdm/backend/dm.c
4+++ b/kdm/backend/dm.c
5@@ -1347,54 +1347,207 @@ getBusyVTs(void)
6 return activeVTs;
7 }
8
9+static int
10+get_active_vt (void)
11+{
12+ int console_fd;
13+ struct vt_stat console_state = { 0 };
14+ console_fd = open ("/dev/tty0", O_RDONLY | O_NOCTTY);
15+ if (console_fd < 0) {
16+ return 0;
17+ }
18+ ioctl (console_fd, VT_GETSTATE, &console_state);
19+
20+ close (console_fd);
21+ return console_state.v_active;
22+}
23+
24+static int
25+plymouth_is_running (void)
26+{
27+ static int running = -1;
28+ if (running == 0)
29+ return 0;
30+
31+ int status;
32+ status = system ("/usr/bin/plymouth --ping");
33+
34+ running = WIFEXITED (status) && WEXITSTATUS (status) == 0;
35+ logWarn ("plymouth is %srunning\n", running?"":"NOT ");
36+ return running;
37+}
38+
39+static int
40+plymouth_has_active_vt (void)
41+{
42+ int status;
43+ status = system ("/usr/bin/plymouth --has-active-vt");
44+
45+ return WIFEXITED (status) && WEXITSTATUS (status) == 0;
46+}
47+
48+static int
49+plymouth_prepare_for_transition (void)
50+{
51+ int status;
52+ status = system ("/usr/bin/plymouth deactivate");
53+
54+ return WIFEXITED (status) && WEXITSTATUS (status) == 0;
55+}
56+
57+int
58+plymouth_quit_with_transition (void)
59+{
60+ int status;
61+ status = system ("/usr/bin/plymouth --wait quit --retain-splash");
62+
63+ return WIFEXITED (status) && WEXITSTATUS (status) == 0;
64+}
65+
66+int
67+plymouth_quit_without_transition (void)
68+{
69+ int status;
70+ status = system ("/usr/bin/plymouth --wait quit");
71+
72+ return WIFEXITED (status) && WEXITSTATUS (status) == 0;
73+}
74+
75+static int
76+triggered_to_force_display_on_active_vt (void)
77+{
78+ int should_force_display_on_active_vt;
79+ should_force_display_on_active_vt=open("/var/spool/gdm/force-display-on-active-vt", O_RDONLY);
80+ if ( should_force_display_on_active_vt >= 0 )
81+ close(should_force_display_on_active_vt);
82+ unlink("/var/spool/gdm/force-display-on-active-vt");
83+ return should_force_display_on_active_vt;
84+}
85+
86 static void
87 allocateVT(struct display *d)
88 {
89 struct display *cd;
90- int i, tvt, volun;
91+ int i, tvt;
92
93 if ((d->displayType & d_location) == dLocal &&
94 d->status == notRunning && !d->serverVT && d->reqSrvVT >= 0)
95 {
96+ /* Try to find the correct VT.
97+ * If ServerVT is specified in the config, use it (if the admin used the
98+ * same VT for multiple display, it is his/her own fault, no checks done).
99+ * Otherwise, walk the list of specified VTs. Positive numbers are used
100+ * even if the VT is already in use by a tty. Negative numbers and
101+ * unspecified numbers (up to #15) are used if not already in use.
102+ * VTs already in use (cd->serverVT) or requested (cd->reqSrvVT)
103+ * by any display are skipped.
104+ */
105+
106+ /* some special handling is needed for Plymouth:
107+ * if no VT is requested, use the active VT from plymouth for the first
108+ * started display.
109+ * If the display takes over the VT from plymouth, deactivate plymouth
110+ */
111+
112+ char allowedVTs[16] = { 0 };
113 if (d->reqSrvVT && d->reqSrvVT < 16) {
114- d->serverVT = d->reqSrvVT;
115+ allowedVTs[d->reqSrvVT] = 1;
116 } else {
117- for (i = tvt = 0;;) {
118- if (serverVTs[i]) {
119- tvt = atoi(serverVTs[i++]);
120- volun = False;
121- if (tvt < 0) {
122- tvt = -tvt;
123- volun = True;
124- }
125- if (!tvt || tvt >= 16)
126- continue;
127- } else {
128- if (++tvt >= 16)
129- break;
130- volun = True;
131+ for (i = 0; serverVTs[i]; i++) {
132+ tvt = atoi(serverVTs[i]);
133+ if ((tvt >= 0) && (tvt < 16)) {
134+ allowedVTs[tvt] = 1;
135+ } else if (tvt > -16) {
136+ allowedVTs[-tvt] = 2;
137 }
138- for (cd = displays; cd; cd = cd->next) {
139- if (cd->reqSrvVT == tvt && /* protect from lusers */
140- (cd->status != zombie || cd->zstatus != DS_REMOVE))
141- goto next;
142- if (cd->serverVT == tvt) {
143- if (cd->status != zombie || cd->zstatus == DS_REMOTE)
144- goto next;
145- if (!cd->follower) {
146- d->serverVT = -1;
147- cd->follower = d;
148- return;
149- }
150- }
151+ }
152+
153+ for (tvt = 15; allowedVTs[tvt] == 0; tvt--) {
154+ allowedVTs[tvt] = 2;
155+ }
156+
157+ for (cd = displays; cd; cd = cd->next) {
158+ if (cd->status != zombie) {
159+ if (cd->reqSrvVT >= 0) allowedVTs[cd->reqSrvVT] = 0;
160+ if (cd->serverVT >= 0) allowedVTs[cd->serverVT] = 0;
161+ } else if (cd->zstatus == DS_REMOTE) {
162+ /* dying, but will spawn new server for remote login */
163+ if (cd->serverVT >= 0) allowedVTs[cd->serverVT] = 0;
164+ } else if (cd->zstatus != DS_REMOVE) {
165+ /* dying, but will be restarted or reserved */
166+ if (cd->reqSrvVT >= 0) allowedVTs[cd->reqSrvVT] = 0;
167 }
168- if (!volun || !((1 << tvt) & getBusyVTs())) {
169- d->serverVT = tvt;
170+ }
171+ }
172+
173+ /* check for plymouth using newer methods */
174+ d->plymouth_vt = -1;
175+ if (plymouth_is_running ()) {
176+ if (plymouth_has_active_vt ()) {
177+ int vt = get_active_vt ();
178+ if (allowedVTs[vt]) {
179+ logWarn ("plymouth is active on VT %d, reusing for %s\n", vt, d->name);
180+ d->serverVT = vt;
181+ d->plymouth_vt = vt;
182 return;
183 }
184- next: ;
185+ }
186+ /* fallback to old/deprecated method */
187+ } else if ( triggered_to_force_display_on_active_vt() >= 0 ) {
188+ int vt = get_active_vt ();
189+ if (allowedVTs[vt]) {
190+ d->serverVT = vt;
191+ return;
192+ }
193+ }
194+
195+ for (tvt = 0; tvt < 16; tvt++) {
196+ if ((allowedVTs[tvt] == 1) ||
197+ ((allowedVTs[tvt] == 2) && !((1 << tvt) & getBusyVTs()))) {
198+ d->serverVT = tvt;
199+ return;
200 }
201 }
202+
203+ for (cd = displays; cd; cd = cd->next) {
204+ if ((cd->status == zombie) && (cd->zstatus != DS_REMOTE) &&
205+ (cd->follower == 0) && (cd->reqSrvVT != cd->serverVT)) {
206+ /* removed; or restarted/reserved on any VT */
207+ d->serverVT = -1;
208+ cd->follower = d;
209+ return;
210+ }
211+ }
212+ }
213+}
214+
215+static void
216+replacePlymouth(void)
217+{
218+ struct display *cd;
219+
220+ /* if one display reuses plymouth' VT, plymouth is stopped in the
221+ * startServerSuccess/Failed callback (see server.c). In any other
222+ * case plymouth is stopped now.
223+ */
224+ for (cd = displays; cd; cd = cd->next) {
225+ if ((cd->serverVT > 0) && (cd->serverVT == cd->plymouth_vt)) {
226+ if (cd->status == notRunning) {
227+ /* tell plymouth to quit when server has started */
228+ logWarn ("plymouth should quit after server startup\n");
229+ plymouth_prepare_for_transition ();
230+ kickDisplay(cd);
231+ return;
232+ } else if (cd->status == running) {
233+ /* replacing server is starting up, do nothing */
234+ return;
235+ }
236+ }
237+ }
238+
239+ if ( plymouth_is_running ()) {
240+ plymouth_prepare_for_transition ();
241+ plymouth_quit_without_transition ();
242 }
243 }
244 #endif
245@@ -1407,6 +1560,7 @@ startDisplays(void)
246 #ifdef HAVE_VTS
247 activeVTs = -1;
248 forEachDisplayRev(allocateVT);
249+ replacePlymouth();
250 #endif
251 forEachDisplay(kickDisplay);
252 }
253diff --git a/kdm/backend/dm.h b/kdm/backend/dm.h
254index 64e106b..930af0e 100644
255--- a/kdm/backend/dm.h
256+++ b/kdm/backend/dm.h
257@@ -304,6 +304,8 @@ struct display {
258 int authNum; /* number of authorizations */
259 char *authFile; /* file to store authorization in */
260 char *greeterAuthFile; /* file to store authorization for greeter in */
261+
262+ int plymouth_vt; /* Plymouth's VT nr */
263 };
264
265 #define d_location 1
266@@ -428,6 +430,9 @@ int anyDisplaysLeft(void);
267 void forEachDisplay(void (*f)(struct display *));
268 #ifdef HAVE_VTS
269 void forEachDisplayRev(void (*f)(struct display *));
270+/* function for plymouth */
271+int plymouth_quit_with_transition (void);
272+int plymouth_quit_without_transition (void);
273 #endif
274 void removeDisplay(struct display *old);
275 struct display
276diff --git a/kdm/backend/server.c b/kdm/backend/server.c
277index d8dd6f3..8b4708e 100644
278--- a/kdm/backend/server.c
279+++ b/kdm/backend/server.c
280@@ -80,6 +80,7 @@ startServerOnce(void)
281 char **argv;
282
283 debug("startServerOnce for %s, try %d\n", d->name, ++d->startTries);
284+
285 d->serverStatus = starting;
286 switch (Fork(&d->serverPid)) {
287 case 0:
288@@ -137,6 +138,12 @@ startServerSuccess()
289 struct display *d = startingServer;
290 d->serverStatus = ignore;
291 serverTimeout = TO_INF;
292+ if ((d->serverVT > 0) && (d->serverVT == d->plymouth_vt)) {
293+ int plymouth_running;
294+ logWarn ("Quitting Plymouth with transition\n" );
295+ plymouth_running = !plymouth_quit_with_transition ();
296+ logWarn ("Is Plymouth still running? %s\n", plymouth_running ? "yes" : "no");
297+ }
298 debug("X server ready, starting session\n");
299 startDisplayP2(d);
300 }
301@@ -154,6 +161,10 @@ startServerFailed()
302 startingServer = 0;
303 logError("X server for display %s cannot be started,"
304 " session disabled\n", d->name);
305+ if ((d->serverVT > 0) && (d->serverVT == d->plymouth_vt)) {
306+ logWarn ("Quitting Plymouth without transition\n" );
307+ plymouth_quit_without_transition ();
308+ }
309 stopDisplay(d);
310 }
311 }
This page took 0.058011 seconds and 4 git commands to generate.