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
=== modified file 'src/seat-unity.c'
--- src/seat-unity.c 2013-05-20 05:20:45 +0000
+++ src/seat-unity.c 2013-05-31 02:42:33 +0000
@@ -64,8 +64,12 @@
64 /* Timeout when waiting for compositor to start */64 /* Timeout when waiting for compositor to start */
65 guint compositor_timeout;65 guint compositor_timeout;
6666
67 /* Next Mir ID to use for a compositor client */
67 gint next_id;68 gint next_id;
6869
70 /* TRUE if using VT switching fallback */
71 gboolean use_vt_switching;
72
69 /* The currently visible display */73 /* The currently visible display */
70 Display *active_display;74 Display *active_display;
71};75};
@@ -82,12 +86,25 @@
82static void86static void
83compositor_stopped_cb (Process *process, SeatUnity *seat)87compositor_stopped_cb (Process *process, SeatUnity *seat)
84{88{
89 if (seat->priv->compositor_timeout != 0)
90 g_source_remove (seat->priv->compositor_timeout);
91 seat->priv->compositor_timeout = 0;
92
85 if (seat_get_is_stopping (SEAT (seat)))93 if (seat_get_is_stopping (SEAT (seat)))
86 {94 {
87 SEAT_CLASS (seat_unity_parent_class)->stop (SEAT (seat));95 SEAT_CLASS (seat_unity_parent_class)->stop (SEAT (seat));
88 return;96 return;
89 }97 }
9098
99 /* If stopped before it was ready, then revert to VT mode */
100 if (!seat->priv->compositor_ready)
101 {
102 g_debug ("Compositor failed to start, switching to VT mode");
103 seat->priv->use_vt_switching = TRUE;
104 SEAT_CLASS (seat_unity_parent_class)->start (SEAT (seat));
105 return;
106 }
107
91 g_debug ("Stopping Unity seat, compositor terminated");108 g_debug ("Stopping Unity seat, compositor terminated");
92109
93 if (seat->priv->stopping_plymouth)110 if (seat->priv->stopping_plymouth)
@@ -243,8 +260,10 @@
243 absolute_command = g_strjoin (" ", absolute_binary, tokens[1], NULL);260 absolute_command = g_strjoin (" ", absolute_binary, tokens[1], NULL);
244 else261 else
245 absolute_command = g_strdup (absolute_binary);262 absolute_command = g_strdup (absolute_binary);
263 g_free (absolute_binary);
246 }264 }
247 g_free (absolute_binary);265 else
266 absolute_command = g_strdup (command);
248267
249 g_strfreev (tokens);268 g_strfreev (tokens);
250269
@@ -317,11 +336,6 @@
317336
318 absolute_command = get_absolute_command (command);337 absolute_command = get_absolute_command (command);
319 g_free (command);338 g_free (command);
320 if (!absolute_command)
321 {
322 g_debug ("Can't launch system compositor, not found in path");
323 return FALSE;
324 }
325339
326 /* Start the compositor */340 /* Start the compositor */
327 process_set_command (SEAT_UNITY (seat)->priv->compositor_process, absolute_command);341 process_set_command (SEAT_UNITY (seat)->priv->compositor_process, absolute_command);
@@ -359,11 +373,14 @@
359373
360 xserver = xserver_local_new ();374 xserver = xserver_local_new ();
361375
362 id = g_strdup_printf ("%d", SEAT_UNITY (seat)->priv->next_id);376 if (!SEAT_UNITY (seat)->priv->use_vt_switching)
363 SEAT_UNITY (seat)->priv->next_id++;377 {
364 xserver_local_set_mir_id (xserver, id);378 id = g_strdup_printf ("%d", SEAT_UNITY (seat)->priv->next_id);
365 xserver_local_set_mir_socket (xserver, SEAT_UNITY (seat)->priv->mir_socket_filename);379 SEAT_UNITY (seat)->priv->next_id++;
366 g_free (id);380 xserver_local_set_mir_id (xserver, id);
381 xserver_local_set_mir_socket (xserver, SEAT_UNITY (seat)->priv->mir_socket_filename);
382 g_free (id);
383 }
367384
368 command = seat_get_string_property (seat, "xserver-command");385 command = seat_get_string_property (seat, "xserver-command");
369 if (command)386 if (command)
@@ -437,7 +454,10 @@
437 xserver = XSERVER_LOCAL (display_get_display_server (display));454 xserver = XSERVER_LOCAL (display_get_display_server (display));
438455
439 session = xsession_new (XSERVER (xserver));456 session = xsession_new (XSERVER (xserver));
440 tty = g_strdup_printf ("/dev/tty%d", SEAT_UNITY (seat)->priv->vt);457 if (SEAT_UNITY (seat)->priv->use_vt_switching)
458 tty = g_strdup_printf ("/dev/tty%d", xserver_local_get_vt (xserver));
459 else
460 tty = g_strdup_printf ("/dev/tty%d", SEAT_UNITY (seat)->priv->vt);
441 session_set_tty (SESSION (session), tty);461 session_set_tty (SESSION (session), tty);
442 g_free (tty);462 g_free (tty);
443463
@@ -450,6 +470,17 @@
450 XServerLocal *xserver;470 XServerLocal *xserver;
451 const gchar *id;471 const gchar *id;
452472
473 /* If no compositor, have to use VT switching */
474 if (SEAT_UNITY (seat)->priv->use_vt_switching)
475 {
476 gint vt = xserver_local_get_vt (XSERVER_LOCAL (display_get_display_server (display)));
477 if (vt >= 0)
478 vt_set_active (vt);
479
480 SEAT_CLASS (seat_unity_parent_class)->set_active_display (seat, display);
481 return;
482 }
483
453 if (display == SEAT_UNITY (seat)->priv->active_display)484 if (display == SEAT_UNITY (seat)->priv->active_display)
454 return;485 return;
455 SEAT_UNITY (seat)->priv->active_display = display;486 SEAT_UNITY (seat)->priv->active_display = display;
@@ -466,6 +497,27 @@
466static Display *497static Display *
467seat_unity_get_active_display (Seat *seat)498seat_unity_get_active_display (Seat *seat)
468{499{
500 if (SEAT_UNITY (seat)->priv->use_vt_switching)
501 {
502 gint vt;
503 GList *link;
504 vt = vt_get_active ();
505 if (vt < 0)
506 return NULL;
507
508 for (link = seat_get_displays (seat); link; link = link->next)
509 {
510 Display *display = link->data;
511 XServerLocal *xserver;
512
513 xserver = XSERVER_LOCAL (display_get_display_server (display));
514 if (xserver_local_get_vt (xserver) == vt)
515 return display;
516 }
517
518 return NULL;
519 }
520
469 return SEAT_UNITY (seat)->priv->active_display;521 return SEAT_UNITY (seat)->priv->active_display;
470}522}
471523
472524
=== modified file 'tests/scripts/unity-compositor-fail-start.conf'
--- tests/scripts/unity-compositor-fail-start.conf 2013-05-20 05:20:45 +0000
+++ tests/scripts/unity-compositor-fail-start.conf 2013-05-31 02:42:33 +0000
@@ -1,5 +1,5 @@
1#1#
2# Check quits when the compositor fails to start2# Check falls back to VT swithcing when the compositor fails to start
3#3#
44
5[unity-system-compositor-config]5[unity-system-compositor-config]
@@ -14,5 +14,22 @@
14#?UNITY-SYSTEM-COMPOSITOR START14#?UNITY-SYSTEM-COMPOSITOR START
15#?UNITY-SYSTEM-COMPOSITOR EXIT CODE=115#?UNITY-SYSTEM-COMPOSITOR EXIT CODE=1
1616
17# Daemon stops with error17# X server starts in VT mode
18#?RUNNER DAEMON-EXIT STATUS=118#?XSERVER-0 START
19#?XSERVER-0 INDICATE-READY
20
21# LightDM connects to X server
22#?XSERVER-0 ACCEPT-CONNECT
23
24# Greeter starts
25#?GREETER-X-0 START
26#?XSERVER-0 ACCEPT-CONNECT
27#?GREETER-X-0 CONNECT-XSERVER
28#?GREETER-X-0 CONNECT-TO-DAEMON
29#?GREETER-X-0 CONNECTED-TO-DAEMON
30
31# Cleanup
32#?*STOP-DAEMON
33#?GREETER-X-0 TERMINATE SIGNAL=15
34#?XSERVER-0 TERMINATE SIGNAL=15
35#?RUNNER DAEMON-EXIT STATUS=0

Subscribers

People subscribed via source and target branches