]> rtime.felk.cvut.cz Git - sojka/lightdm.git/blobdiff - src/seat-unity.c
Remove built-in xlocal fallback from unity seat; adjust tests; add test for new type...
[sojka/lightdm.git] / src / seat-unity.c
index c4736104ba45f56f0c352732956faf82ca30e805..e9a89e02f7bb4d081a8cc9430deb66755fdf0ea4 100644 (file)
@@ -16,9 +16,7 @@
 
 #include "seat-unity.h"
 #include "configuration.h"
-#include "xserver-local.h"
-#include "xgreeter.h"
-#include "xsession.h"
+#include "x-server-local.h"
 #include "mir-server.h"
 #include "vt.h"
 #include "plymouth.h"
@@ -29,7 +27,8 @@ typedef enum
    USC_MESSAGE_PONG = 1,
    USC_MESSAGE_READY = 2,
    USC_MESSAGE_SESSION_CONNECTED = 3,
-   USC_MESSAGE_SET_ACTIVE_SESSION = 4
+   USC_MESSAGE_SET_ACTIVE_SESSION = 4,
+   USC_MESSAGE_SET_NEXT_SESSION = 5,
 } USCMessageID;
 
 struct SeatUnityPrivate
@@ -37,9 +36,6 @@ struct SeatUnityPrivate
     /* VT we are running on */
     gint vt;
 
-    /* TRUE if waiting for X server to start before stopping Plymouth */
-    gboolean stopping_plymouth;
-
     /* File to log to */
     gchar *log_file;
 
@@ -52,6 +48,7 @@ struct SeatUnityPrivate
 
     /* IO channel listening on for messages from the compositor */
     GIOChannel *from_compositor_channel;
+    guint from_compositor_watch;
 
     /* TRUE when the compositor indicates it is ready */
     gboolean compositor_ready;
@@ -67,11 +64,10 @@ struct SeatUnityPrivate
     /* Timeout when waiting for compositor to start */
     guint compositor_timeout;
 
-    /* Next Mir ID to use for a compositor client */
-    gint next_id;
-
-    /* TRUE if using VT switching fallback */
-    gboolean use_vt_switching;
+    /* Next Mir ID to use for a Mir sessions, X server and greeters */
+    gint next_session_id;
+    gint next_x_server_id;
+    gint next_greeter_id;
 
     /* The currently visible session */
     Session *active_session;
@@ -80,6 +76,12 @@ struct SeatUnityPrivate
 
 G_DEFINE_TYPE (SeatUnity, seat_unity, SEAT_TYPE);
 
+static gboolean
+seat_unity_get_start_local_sessions (Seat *seat)
+{
+    return !seat_get_string_property (seat, "xdmcp-manager");
+}
+
 static void
 seat_unity_setup (Seat *seat)
 {
@@ -104,23 +106,7 @@ compositor_stopped_cb (Process *process, SeatUnity *seat)
         return;
     }
 
-    /* If stopped before it was ready, then revert to VT mode */
-    if (!seat->priv->compositor_ready)
-    {
-        g_debug ("Compositor failed to start, switching to VT mode");
-        seat->priv->use_vt_switching = TRUE;
-        SEAT_CLASS (seat_unity_parent_class)->start (SEAT (seat));
-        return;
-    }
-
-    g_debug ("Stopping Unity seat, compositor terminated");
-
-    if (seat->priv->stopping_plymouth)
-    {
-        g_debug ("Stopping Plymouth, compositor failed to start");
-        plymouth_quit (FALSE);
-        seat->priv->stopping_plymouth = FALSE;
-    }
+    l_debug (seat, "Stopping Unity seat, compositor terminated");
 
     seat_stop (SEAT (seat));
 }
@@ -139,10 +125,17 @@ compositor_run_cb (Process *process, SeatUnity *seat)
     if (seat->priv->log_file)
     {
          int fd;
+         gchar *old_filename;
+
+         /* Move old file out of the way */
+         old_filename = g_strdup_printf ("%s.old", seat->priv->log_file);
+         rename (seat->priv->log_file, old_filename);
+         g_free (old_filename);
 
+         /* Create new file and log to it */
          fd = g_open (seat->priv->log_file, O_WRONLY | O_CREAT | O_TRUNC, 0600);
          if (fd < 0)
-             g_warning ("Failed to open log file %s: %s", seat->priv->log_file, g_strerror (errno));
+             l_warning (seat, "Failed to open log file %s: %s", seat->priv->log_file, g_strerror (errno));
          else
          {
              dup2 (fd, STDOUT_FILENO);
@@ -150,12 +143,6 @@ compositor_run_cb (Process *process, SeatUnity *seat)
              close (fd);
          }
     }
-
-    if (seat->priv->stopping_plymouth)
-    {      
-        seat->priv->stopping_plymouth = FALSE;
-        plymouth_quit (TRUE);
-    }  
 }
 
 static void
@@ -173,7 +160,7 @@ write_message (SeatUnity *seat, guint16 id, const guint8 *payload, guint16 paylo
 
     errno = 0;
     if (write (seat->priv->to_compositor_pipe[1], data, data_length) != data_length)
-        g_warning ("Failed to write to compositor: %s", strerror (errno));
+        l_warning (seat, "Failed to write to compositor: %s", strerror (errno));
 }
 
 static gboolean
@@ -186,7 +173,7 @@ read_cb (GIOChannel *source, GIOCondition condition, gpointer data)
   
     if (condition == G_IO_HUP)
     {
-        g_debug ("Compositor closed communication channel");
+        l_debug (seat, "Compositor closed communication channel");
         return FALSE;
     }
 
@@ -216,7 +203,7 @@ read_cb (GIOChannel *source, GIOCondition condition, gpointer data)
                                           &n_read,
                                           &error);
         if (error)
-            g_warning ("Failed to read from compositor: %s", error->message);
+            l_warning (seat, "Failed to read from compositor: %s", error->message);
         if (status != G_IO_STATUS_NORMAL)
             return TRUE;
         g_clear_error (&error);
@@ -237,28 +224,28 @@ read_cb (GIOChannel *source, GIOCondition condition, gpointer data)
     switch (id)
     {
     case USC_MESSAGE_PING:
-        g_debug ("PING!");
+        l_debug (seat, "PING!");
         write_message (seat, USC_MESSAGE_PONG, NULL, 0);
         break;
     case USC_MESSAGE_PONG:
-        g_debug ("PONG!");
+        l_debug (seat, "PONG!");
         break;
     case USC_MESSAGE_READY:
-        g_debug ("READY");
+        l_debug (seat, "READY");
         if (!seat->priv->compositor_ready)
         {
             seat->priv->compositor_ready = TRUE;
-            g_debug ("Compositor ready");
+            l_debug (seat, "Compositor ready");
             g_source_remove (seat->priv->compositor_timeout);
             seat->priv->compositor_timeout = 0;
             SEAT_CLASS (seat_unity_parent_class)->start (SEAT (seat));
         }
         break;
     case USC_MESSAGE_SESSION_CONNECTED:
-        g_debug ("SESSION CONNECTED");
+        l_debug (seat, "SESSION CONNECTED");
         break;
     default:
-        g_warning ("Ingoring unknown message %d with %d octets from system compositor", id, payload_length);
+        l_warning (seat, "Ignoring unknown message %d with %d octets from system compositor", id, payload_length);
         break;
     }
 
@@ -308,7 +295,7 @@ static gboolean
 seat_unity_start (Seat *seat)
 {
     const gchar *compositor_command;
-    gchar *command, *absolute_command, *dir;
+    gchar *command, *absolute_command, *dir, *value;
     gboolean result;
     int timeout;
 
@@ -318,19 +305,19 @@ seat_unity_start (Seat *seat)
         gint active_vt = vt_get_active ();
         if (active_vt >= vt_get_min ())
         {
-            g_debug ("Compositor will replace Plymouth");
-            SEAT_UNITY (seat)->priv->stopping_plymouth = TRUE;
             SEAT_UNITY (seat)->priv->vt = active_vt;
-            plymouth_deactivate ();
+            plymouth_quit (TRUE);
         }
         else
-            g_debug ("Plymouth is running on VT %d, but this is less than the configured minimum of %d so not replacing it", active_vt, vt_get_min ());
+            l_debug (seat, "Plymouth is running on VT %d, but this is less than the configured minimum of %d so not replacing it", active_vt, vt_get_min ());
     }
+    if (plymouth_get_is_active ())
+        plymouth_quit (FALSE);
     if (SEAT_UNITY (seat)->priv->vt < 0)
         SEAT_UNITY (seat)->priv->vt = vt_get_unused ();
     if (SEAT_UNITY (seat)->priv->vt < 0)
     {
-        g_debug ("Failed to get a VT to run on");
+        l_debug (seat, "Failed to get a VT to run on");
         return FALSE;
     }
     vt_ref (SEAT_UNITY (seat)->priv->vt);
@@ -338,7 +325,7 @@ seat_unity_start (Seat *seat)
     /* Create pipes to talk to compositor */
     if (pipe (SEAT_UNITY (seat)->priv->to_compositor_pipe) < 0 || pipe (SEAT_UNITY (seat)->priv->from_compositor_pipe) < 0)
     {
-        g_debug ("Failed to create compositor pipes: %s", g_strerror (errno));
+        l_debug (seat, "Failed to create compositor pipes: %s", g_strerror (errno));
         return FALSE;
     }
 
@@ -348,18 +335,32 @@ seat_unity_start (Seat *seat)
 
     /* Listen for messages from the compositor */
     SEAT_UNITY (seat)->priv->from_compositor_channel = g_io_channel_unix_new (SEAT_UNITY (seat)->priv->from_compositor_pipe[0]);
-    g_io_add_watch (SEAT_UNITY (seat)->priv->from_compositor_channel, G_IO_IN | G_IO_HUP, read_cb, seat);
+    SEAT_UNITY (seat)->priv->from_compositor_watch = g_io_add_watch (SEAT_UNITY (seat)->priv->from_compositor_channel, G_IO_IN | G_IO_HUP, read_cb, seat);
 
     /* Setup logging */
     dir = config_get_string (config_get_instance (), "LightDM", "log-directory");
     SEAT_UNITY (seat)->priv->log_file = g_build_filename (dir, "unity-system-compositor.log", NULL);
-    g_debug ("Logging to %s", SEAT_UNITY (seat)->priv->log_file);
+    l_debug (seat, "Logging to %s", SEAT_UNITY (seat)->priv->log_file);
     g_free (dir);
 
+    /* Setup environment */
+    process_set_clear_environment (SEAT_UNITY (seat)->priv->compositor_process, TRUE);
+    process_set_env (SEAT_UNITY (seat)->priv->compositor_process, "XDG_SEAT", "seat0");
+    value = g_strdup_printf ("%d", SEAT_UNITY (seat)->priv->vt);
+    process_set_env (SEAT_UNITY (seat)->priv->compositor_process, "XDG_VTNR", value);
+    g_free (value);
+    /* Variable required for regression tests */
+    if (g_getenv ("LIGHTDM_TEST_ROOT"))
+    {
+        process_set_env (SEAT_UNITY (seat)->priv->compositor_process, "LIGHTDM_TEST_ROOT", g_getenv ("LIGHTDM_TEST_ROOT"));
+        process_set_env (SEAT_UNITY (seat)->priv->compositor_process, "LD_PRELOAD", g_getenv ("LD_PRELOAD"));
+        process_set_env (SEAT_UNITY (seat)->priv->compositor_process, "LD_LIBRARY_PATH", g_getenv ("LD_LIBRARY_PATH"));
+    }
+
     SEAT_UNITY (seat)->priv->mir_socket_filename = g_strdup ("/tmp/mir_socket"); // FIXME: Use this socket by default as XMir is hardcoded to this
     timeout = seat_get_integer_property (seat, "unity-compositor-timeout");
     compositor_command = seat_get_string_property (seat, "unity-compositor-command");
-    command = g_strdup_printf ("%s --from-dm-fd %d --to-dm-fd %d --vt %d", compositor_command, SEAT_UNITY (seat)->priv->to_compositor_pipe[0], SEAT_UNITY (seat)->priv->from_compositor_pipe[1], SEAT_UNITY (seat)->priv->vt);
+    command = g_strdup_printf ("%s --file '%s' --from-dm-fd %d --to-dm-fd %d --vt %d", compositor_command, SEAT_UNITY (seat)->priv->mir_socket_filename, SEAT_UNITY (seat)->priv->to_compositor_pipe[0], SEAT_UNITY (seat)->priv->from_compositor_pipe[1], SEAT_UNITY (seat)->priv->vt);
 
     absolute_command = get_absolute_command (command);
     g_free (command);
@@ -384,7 +385,7 @@ seat_unity_start (Seat *seat)
     timeout = seat_get_integer_property (seat, "unity-compositor-timeout");
     if (timeout <= 0)
         timeout = 60;
-    g_debug ("Waiting for system compositor for %ds", timeout);
+    l_debug (seat, "Waiting for system compositor for %ds", timeout);
     SEAT_UNITY (seat)->priv->compositor_timeout = g_timeout_add (timeout * 1000, compositor_timeout_cb, seat);
 
     return TRUE;
@@ -393,47 +394,48 @@ seat_unity_start (Seat *seat)
 static DisplayServer *
 create_x_server (Seat *seat)
 {
-    XServerLocal *xserver;
-    const gchar *command = NULL, *layout = NULL, *config_file = NULL, *xdmcp_manager = NULL, *key_name = NULL;
+    XServerLocal *x_server;
+    const gchar *command = NULL, *layout = NULL, *config_file = NULL, *xdmcp_manager = NULL, *key_name = NULL, *xdg_seat = NULL;
     gboolean allow_tcp;
     gint port = 0;
     gchar *id;
 
-    g_debug ("Starting X server on Unity compositor");
+    l_debug (seat, "Starting X server on Unity compositor");
 
-    xserver = xserver_local_new ();
-
-    if (!SEAT_UNITY (seat)->priv->use_vt_switching)
-    {
-        id = g_strdup_printf ("%d", SEAT_UNITY (seat)->priv->next_id);
-        SEAT_UNITY (seat)->priv->next_id++;
-        xserver_local_set_mir_id (xserver, id);
-        xserver_local_set_mir_socket (xserver, SEAT_UNITY (seat)->priv->mir_socket_filename);
-        g_free (id);
-    }
+    x_server = x_server_local_new ();
 
     command = seat_get_string_property (seat, "xserver-command");
     if (command)
-        xserver_local_set_command (xserver, command);
+        x_server_local_set_command (x_server, command);
+
+    id = g_strdup_printf ("x-%d", SEAT_UNITY (seat)->priv->next_x_server_id);
+    SEAT_UNITY (seat)->priv->next_x_server_id++;
+    x_server_local_set_mir_id (x_server, id);
+    x_server_local_set_mir_socket (x_server, SEAT_UNITY (seat)->priv->mir_socket_filename);
+    g_free (id);
 
     layout = seat_get_string_property (seat, "xserver-layout");
     if (layout)
-        xserver_local_set_layout (xserver, layout);
+        x_server_local_set_layout (x_server, layout);
+    
+    xdg_seat = seat_get_string_property (seat, "xdg-seat");
+    if (xdg_seat)
+        x_server_local_set_xdg_seat (x_server, xdg_seat);
 
     config_file = seat_get_string_property (seat, "xserver-config");
     if (config_file)
-        xserver_local_set_config (xserver, config_file);
+        x_server_local_set_config (x_server, config_file);
 
     allow_tcp = seat_get_boolean_property (seat, "xserver-allow-tcp");
-    xserver_local_set_allow_tcp (xserver, allow_tcp);
+    x_server_local_set_allow_tcp (x_server, allow_tcp);
 
     xdmcp_manager = seat_get_string_property (seat, "xdmcp-manager");
     if (xdmcp_manager)
-        xserver_local_set_xdmcp_server (xserver, xdmcp_manager);
+        x_server_local_set_xdmcp_server (x_server, xdmcp_manager);
 
     port = seat_get_integer_property (seat, "xdmcp-port");
     if (port > 0)
-        xserver_local_set_xdmcp_port (xserver, port);
+        x_server_local_set_xdmcp_port (x_server, port);
 
     key_name = seat_get_string_property (seat, "xdmcp-key");
     if (key_name)
@@ -450,7 +452,7 @@ create_x_server (Seat *seat)
         keys = g_key_file_new ();
         result = g_key_file_load_from_file (keys, path, G_KEY_FILE_NONE, &error);
         if (error)
-            g_debug ("Error getting key %s", error->message);
+            l_debug (seat, "Error getting key %s", error->message);
         g_clear_error (&error);
 
         if (result)
@@ -460,10 +462,10 @@ create_x_server (Seat *seat)
             if (g_key_file_has_key (keys, "keyring", key_name, NULL))
                 key = g_key_file_get_string (keys, "keyring", key_name, NULL);
             else
-                g_debug ("Key %s not defined", key_name);
+                l_debug (seat, "Key %s not defined", key_name);
 
             if (key)
-                xserver_local_set_xdmcp_key (xserver, key);
+                x_server_local_set_xdmcp_key (x_server, key);
             g_free (key);
         }
 
@@ -471,7 +473,18 @@ create_x_server (Seat *seat)
         g_key_file_free (keys);
     }
 
-    return DISPLAY_SERVER (xserver);
+    return DISPLAY_SERVER (x_server);
+}
+
+static DisplayServer *
+create_mir_server (Seat *seat)
+{
+    MirServer *mir_server;
+
+    mir_server = mir_server_new ();
+    mir_server_set_parent_socket (mir_server, SEAT_UNITY (seat)->priv->mir_socket_filename);
+
+    return DISPLAY_SERVER (mir_server);
 }
 
 static DisplayServer *
@@ -480,10 +493,10 @@ seat_unity_create_display_server (Seat *seat, const gchar *session_type)
     if (strcmp (session_type, "x") == 0)
         return create_x_server (seat);
     else if (strcmp (session_type, "mir") == 0)
-        return DISPLAY_SERVER (mir_server_new ());
+        return create_mir_server (seat);
     else
     {
-        g_warning ("Can't create unsupported display server '%s'", session_type);
+        l_warning (seat, "Can't create unsupported display server '%s'", session_type);
         return NULL;
     }
 }
@@ -491,23 +504,69 @@ seat_unity_create_display_server (Seat *seat, const gchar *session_type)
 static Greeter *
 seat_unity_create_greeter_session (Seat *seat)
 {
-    XGreeter *greeter_session;
+    Greeter *greeter_session;
+    const gchar *xdg_seat;
+    gchar *id;
+    gint vt;
+
+    greeter_session = SEAT_CLASS (seat_unity_parent_class)->create_greeter_session (seat);
+    xdg_seat = seat_get_string_property (seat, "xdg-seat");
+    if (!xdg_seat)
+        xdg_seat = "seat0";
+    l_debug (seat, "Setting XDG_SEAT=%s", xdg_seat);
+    session_set_env (SESSION (greeter_session), "XDG_SEAT", xdg_seat);
 
-    greeter_session = xgreeter_new ();
-    session_set_env (SESSION (greeter_session), "XDG_SEAT", "seat0");
+    id = g_strdup_printf ("greeter-%d", SEAT_UNITY (seat)->priv->next_greeter_id);
+    SEAT_UNITY (seat)->priv->next_greeter_id++;
+    session_set_env (SESSION (greeter_session), "MIR_SERVER_NAME", id);
+    g_free (id);
+
+    vt = SEAT_UNITY (seat)->priv->vt;
+    if (vt >= 0)
+    {
+        gchar *value = g_strdup_printf ("%d", vt);
+        l_debug (seat, "Setting XDG_VTNR=%s", value);
+        session_set_env (SESSION (greeter_session), "XDG_VTNR", value);
+        g_free (value);
+    }
+    else
+        l_debug (seat, "Not setting XDG_VTNR");
 
-    return GREETER (greeter_session);
+    return greeter_session;
 }
 
 static Session *
 seat_unity_create_session (Seat *seat)
 {
-    XSession *session;
+    Session *session;
+    const gchar *xdg_seat;
+    gchar *id;
+    gint vt;
+
+    session = SEAT_CLASS (seat_unity_parent_class)->create_session (seat);
+    xdg_seat = seat_get_string_property (seat, "xdg-seat");
+    if (!xdg_seat)
+        xdg_seat = "seat0";
+    l_debug (seat, "Setting XDG_SEAT=%s", xdg_seat);
+    session_set_env (session, "XDG_SEAT", xdg_seat);
 
-    session = xsession_new ();
-    session_set_env (SESSION (session), "XDG_SEAT", "seat0");
+    id = g_strdup_printf ("session-%d", SEAT_UNITY (seat)->priv->next_session_id);
+    SEAT_UNITY (seat)->priv->next_session_id++;
+    session_set_env (session, "MIR_SERVER_NAME", id);
+    g_free (id);
+
+    vt = SEAT_UNITY (seat)->priv->vt;
+    if (vt >= 0)
+    {
+        gchar *value = g_strdup_printf ("%d", vt);
+        l_debug (seat, "Setting XDG_VTNR=%s", value);
+        session_set_env (SESSION (session), "XDG_VTNR", value);
+        g_free (value);
+    }
+    else
+        l_debug (seat, "Not setting XDG_VTNR");
 
-    return SESSION (session);
+    return session;
 }
 
 static void
@@ -515,17 +574,6 @@ seat_unity_set_active_session (Seat *seat, Session *session)
 {
     DisplayServer *display_server;
 
-    /* If no compositor, have to use VT switching */
-    if (SEAT_UNITY (seat)->priv->use_vt_switching)
-    {
-        gint vt = display_server_get_vt (session_get_display_server (session));
-        if (vt >= 0)
-            vt_set_active (vt);
-
-        SEAT_CLASS (seat_unity_parent_class)->set_active_session (seat, session);
-        return;
-    }
-
     if (session == SEAT_UNITY (seat)->priv->active_session)
         return;
     SEAT_UNITY (seat)->priv->active_session = g_object_ref (session);
@@ -533,13 +581,22 @@ seat_unity_set_active_session (Seat *seat, Session *session)
     display_server = session_get_display_server (session);
     if (SEAT_UNITY (seat)->priv->active_display_server != display_server)
     {
-        const gchar *id;
+        const gchar *id = NULL;
 
         SEAT_UNITY (seat)->priv->active_display_server = g_object_ref (display_server);
-        id = xserver_local_get_mir_id (XSERVER_LOCAL (display_server));
 
-        g_debug ("Switching to Mir session %s", id);
-        write_message (SEAT_UNITY (seat), USC_MESSAGE_SET_ACTIVE_SESSION, (const guint8 *) id, strlen (id));
+        if (IS_X_SERVER_LOCAL (display_server))
+            id = x_server_local_get_mir_id (X_SERVER_LOCAL (display_server));
+        else
+            id = session_get_env (session, "MIR_SERVER_NAME");
+
+        if (id)
+        {
+            l_debug (seat, "Switching to Mir session %s", id);
+            write_message (SEAT_UNITY (seat), USC_MESSAGE_SET_ACTIVE_SESSION, (const guint8 *) id, strlen (id));
+        }
+        else
+            l_warning (seat, "Failed to work out session ID");
     }
 
     SEAT_CLASS (seat_unity_parent_class)->set_active_session (seat, session);
@@ -548,36 +605,47 @@ seat_unity_set_active_session (Seat *seat, Session *session)
 static Session *
 seat_unity_get_active_session (Seat *seat)
 {
-    if (SEAT_UNITY (seat)->priv->use_vt_switching)
-    {
-        gint vt;
-        GList *link;
-        vt = vt_get_active ();
-        if (vt < 0)
-            return NULL;
+    return SEAT_UNITY (seat)->priv->active_session;
+}
 
-        for (link = seat_get_sessions (seat); link; link = link->next)
-        {
-            Session *session = link->data;
-            if (display_server_get_vt (session_get_display_server (session)) == vt)
-                return session;
-        }
+static void
+seat_unity_set_next_session (Seat *seat, Session *session)
+{
+    DisplayServer *display_server;
+    const gchar *id = NULL;
 
-        return NULL;
+    if (!session)
+        return;
+
+    display_server = session_get_display_server (session);
+
+    if (IS_X_SERVER_LOCAL (display_server))
+        id = x_server_local_get_mir_id (X_SERVER_LOCAL (display_server));
+    else
+        id = session_get_env (session, "MIR_SERVER_NAME");
+
+    if (id)
+    {
+        l_debug (seat, "Marking Mir session %s as the next session", id);
+        write_message (SEAT_UNITY (seat), USC_MESSAGE_SET_NEXT_SESSION, (const guint8 *) id, strlen (id));
+    }
+    else
+    {
+        l_debug (seat, "Failed to work out session ID to mark");
     }
 
-    return SEAT_UNITY (seat)->priv->active_session;
+    SEAT_CLASS (seat_unity_parent_class)->set_next_session (seat, session);
 }
 
 static void
 seat_unity_run_script (Seat *seat, DisplayServer *display_server, Process *script)
 {
     const gchar *path;
-    XServerLocal *xserver;
+    XServerLocal *x_server;
 
-    xserver = XSERVER_LOCAL (display_server);
-    path = xserver_local_get_authority_file_path (xserver);
-    process_set_env (script, "DISPLAY", xserver_get_address (XSERVER (xserver)));
+    x_server = X_SERVER_LOCAL (display_server);
+    path = x_server_local_get_authority_file_path (x_server);
+    process_set_env (script, "DISPLAY", x_server_get_address (X_SERVER (x_server)));
     process_set_env (script, "XAUTHORITY", path);
 
     SEAT_CLASS (seat_unity_parent_class)->run_script (seat, display_server, script);
@@ -618,6 +686,7 @@ seat_unity_finalize (GObject *object)
     close (seat->priv->from_compositor_pipe[0]);
     close (seat->priv->from_compositor_pipe[1]);
     g_io_channel_unref (seat->priv->from_compositor_channel);
+    g_source_remove (seat->priv->from_compositor_watch);
     g_free (seat->priv->read_buffer);
     g_object_unref (seat->priv->compositor_process);
     if (seat->priv->active_session)
@@ -635,6 +704,7 @@ seat_unity_class_init (SeatUnityClass *klass)
     SeatClass *seat_class = SEAT_CLASS (klass);
 
     object_class->finalize = seat_unity_finalize;
+    seat_class->get_start_local_sessions = seat_unity_get_start_local_sessions;
     seat_class->setup = seat_unity_setup;
     seat_class->start = seat_unity_start;
     seat_class->create_display_server = seat_unity_create_display_server;
@@ -642,6 +712,7 @@ seat_unity_class_init (SeatUnityClass *klass)
     seat_class->create_session = seat_unity_create_session;
     seat_class->set_active_session = seat_unity_set_active_session;
     seat_class->get_active_session = seat_unity_get_active_session;
+    seat_class->set_next_session = seat_unity_set_next_session;
     seat_class->run_script = seat_unity_run_script;
     seat_class->stop = seat_unity_stop;