Merge lp:~robert-ancell/lightdm/unity-vt-fallback into lp:~mir-team/lightdm/unity

Proposed by Robert Ancell
Status: Merged
Approved by: Chris Halse Rogers
Approved revision: 1611
Merged at revision: 1611
Proposed branch: lp:~robert-ancell/lightdm/unity-vt-fallback
Merge into: lp:~mir-team/lightdm/unity
Diff against target: 180 lines (+84/-15)
2 files modified
src/seat-unity.c (+64/-12)
tests/scripts/unity-compositor-fail-start.conf (+20/-3)
To merge this branch: bzr merge lp:~robert-ancell/lightdm/unity-vt-fallback
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Chris Halse Rogers Approve
Mir development team Pending
Review via email: mp+166631@code.launchpad.net

Commit message

Fall back to VT switching if can't start the system compositor

To post a comment you must log in.
Revision history for this message
Chris Halse Rogers (raof) wrote :

Looks correct to me.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/seat-unity.c'
2--- src/seat-unity.c 2013-05-20 05:20:45 +0000
3+++ src/seat-unity.c 2013-05-31 02:42:33 +0000
4@@ -64,8 +64,12 @@
5 /* Timeout when waiting for compositor to start */
6 guint compositor_timeout;
7
8+ /* Next Mir ID to use for a compositor client */
9 gint next_id;
10
11+ /* TRUE if using VT switching fallback */
12+ gboolean use_vt_switching;
13+
14 /* The currently visible display */
15 Display *active_display;
16 };
17@@ -82,12 +86,25 @@
18 static void
19 compositor_stopped_cb (Process *process, SeatUnity *seat)
20 {
21+ if (seat->priv->compositor_timeout != 0)
22+ g_source_remove (seat->priv->compositor_timeout);
23+ seat->priv->compositor_timeout = 0;
24+
25 if (seat_get_is_stopping (SEAT (seat)))
26 {
27 SEAT_CLASS (seat_unity_parent_class)->stop (SEAT (seat));
28 return;
29 }
30
31+ /* If stopped before it was ready, then revert to VT mode */
32+ if (!seat->priv->compositor_ready)
33+ {
34+ g_debug ("Compositor failed to start, switching to VT mode");
35+ seat->priv->use_vt_switching = TRUE;
36+ SEAT_CLASS (seat_unity_parent_class)->start (SEAT (seat));
37+ return;
38+ }
39+
40 g_debug ("Stopping Unity seat, compositor terminated");
41
42 if (seat->priv->stopping_plymouth)
43@@ -243,8 +260,10 @@
44 absolute_command = g_strjoin (" ", absolute_binary, tokens[1], NULL);
45 else
46 absolute_command = g_strdup (absolute_binary);
47+ g_free (absolute_binary);
48 }
49- g_free (absolute_binary);
50+ else
51+ absolute_command = g_strdup (command);
52
53 g_strfreev (tokens);
54
55@@ -317,11 +336,6 @@
56
57 absolute_command = get_absolute_command (command);
58 g_free (command);
59- if (!absolute_command)
60- {
61- g_debug ("Can't launch system compositor, not found in path");
62- return FALSE;
63- }
64
65 /* Start the compositor */
66 process_set_command (SEAT_UNITY (seat)->priv->compositor_process, absolute_command);
67@@ -359,11 +373,14 @@
68
69 xserver = xserver_local_new ();
70
71- id = g_strdup_printf ("%d", SEAT_UNITY (seat)->priv->next_id);
72- SEAT_UNITY (seat)->priv->next_id++;
73- xserver_local_set_mir_id (xserver, id);
74- xserver_local_set_mir_socket (xserver, SEAT_UNITY (seat)->priv->mir_socket_filename);
75- g_free (id);
76+ if (!SEAT_UNITY (seat)->priv->use_vt_switching)
77+ {
78+ id = g_strdup_printf ("%d", SEAT_UNITY (seat)->priv->next_id);
79+ SEAT_UNITY (seat)->priv->next_id++;
80+ xserver_local_set_mir_id (xserver, id);
81+ xserver_local_set_mir_socket (xserver, SEAT_UNITY (seat)->priv->mir_socket_filename);
82+ g_free (id);
83+ }
84
85 command = seat_get_string_property (seat, "xserver-command");
86 if (command)
87@@ -437,7 +454,10 @@
88 xserver = XSERVER_LOCAL (display_get_display_server (display));
89
90 session = xsession_new (XSERVER (xserver));
91- tty = g_strdup_printf ("/dev/tty%d", SEAT_UNITY (seat)->priv->vt);
92+ if (SEAT_UNITY (seat)->priv->use_vt_switching)
93+ tty = g_strdup_printf ("/dev/tty%d", xserver_local_get_vt (xserver));
94+ else
95+ tty = g_strdup_printf ("/dev/tty%d", SEAT_UNITY (seat)->priv->vt);
96 session_set_tty (SESSION (session), tty);
97 g_free (tty);
98
99@@ -450,6 +470,17 @@
100 XServerLocal *xserver;
101 const gchar *id;
102
103+ /* If no compositor, have to use VT switching */
104+ if (SEAT_UNITY (seat)->priv->use_vt_switching)
105+ {
106+ gint vt = xserver_local_get_vt (XSERVER_LOCAL (display_get_display_server (display)));
107+ if (vt >= 0)
108+ vt_set_active (vt);
109+
110+ SEAT_CLASS (seat_unity_parent_class)->set_active_display (seat, display);
111+ return;
112+ }
113+
114 if (display == SEAT_UNITY (seat)->priv->active_display)
115 return;
116 SEAT_UNITY (seat)->priv->active_display = display;
117@@ -466,6 +497,27 @@
118 static Display *
119 seat_unity_get_active_display (Seat *seat)
120 {
121+ if (SEAT_UNITY (seat)->priv->use_vt_switching)
122+ {
123+ gint vt;
124+ GList *link;
125+ vt = vt_get_active ();
126+ if (vt < 0)
127+ return NULL;
128+
129+ for (link = seat_get_displays (seat); link; link = link->next)
130+ {
131+ Display *display = link->data;
132+ XServerLocal *xserver;
133+
134+ xserver = XSERVER_LOCAL (display_get_display_server (display));
135+ if (xserver_local_get_vt (xserver) == vt)
136+ return display;
137+ }
138+
139+ return NULL;
140+ }
141+
142 return SEAT_UNITY (seat)->priv->active_display;
143 }
144
145
146=== modified file 'tests/scripts/unity-compositor-fail-start.conf'
147--- tests/scripts/unity-compositor-fail-start.conf 2013-05-20 05:20:45 +0000
148+++ tests/scripts/unity-compositor-fail-start.conf 2013-05-31 02:42:33 +0000
149@@ -1,5 +1,5 @@
150 #
151-# Check quits when the compositor fails to start
152+# Check falls back to VT swithcing when the compositor fails to start
153 #
154
155 [unity-system-compositor-config]
156@@ -14,5 +14,22 @@
157 #?UNITY-SYSTEM-COMPOSITOR START
158 #?UNITY-SYSTEM-COMPOSITOR EXIT CODE=1
159
160-# Daemon stops with error
161-#?RUNNER DAEMON-EXIT STATUS=1
162+# X server starts in VT mode
163+#?XSERVER-0 START
164+#?XSERVER-0 INDICATE-READY
165+
166+# LightDM connects to X server
167+#?XSERVER-0 ACCEPT-CONNECT
168+
169+# Greeter starts
170+#?GREETER-X-0 START
171+#?XSERVER-0 ACCEPT-CONNECT
172+#?GREETER-X-0 CONNECT-XSERVER
173+#?GREETER-X-0 CONNECT-TO-DAEMON
174+#?GREETER-X-0 CONNECTED-TO-DAEMON
175+
176+# Cleanup
177+#?*STOP-DAEMON
178+#?GREETER-X-0 TERMINATE SIGNAL=15
179+#?XSERVER-0 TERMINATE SIGNAL=15
180+#?RUNNER DAEMON-EXIT STATUS=0

Subscribers

People subscribed via source and target branches