]> 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 7190279f2f5c9d483386a1b78228ed41e1511028..e9a89e02f7bb4d081a8cc9430deb66755fdf0ea4 100644 (file)
@@ -64,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;
@@ -107,15 +106,6 @@ compositor_stopped_cb (Process *process, SeatUnity *seat)
         return;
     }
 
-    /* If stopped before it was ready, then revert to VT mode */
-    if (!seat->priv->compositor_ready)
-    {
-        l_debug (seat, "Compositor failed to start, switching to VT mode");
-        seat->priv->use_vt_switching = TRUE;
-        SEAT_CLASS (seat_unity_parent_class)->start (SEAT (seat));
-        return;
-    }
-
     l_debug (seat, "Stopping Unity seat, compositor terminated");
 
     seat_stop (SEAT (seat));
@@ -408,6 +398,7 @@ create_x_server (Seat *seat)
     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;
 
     l_debug (seat, "Starting X server on Unity compositor");
 
@@ -417,18 +408,11 @@ create_x_server (Seat *seat)
     if (command)
         x_server_local_set_command (x_server, command);
 
-    if (SEAT_UNITY (seat)->priv->use_vt_switching)
-        x_server_local_set_vt (x_server, vt_get_unused ());
-    else
-    {
-        gchar *id;
-
-        id = g_strdup_printf ("%d", SEAT_UNITY (seat)->priv->next_id);
-        SEAT_UNITY (seat)->priv->next_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);
-    }
+    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)
@@ -500,18 +484,6 @@ create_mir_server (Seat *seat)
     mir_server = mir_server_new ();
     mir_server_set_parent_socket (mir_server, SEAT_UNITY (seat)->priv->mir_socket_filename);
 
-    if (SEAT_UNITY (seat)->priv->use_vt_switching)
-        mir_server_set_vt (mir_server, vt_get_unused ());
-    else
-    {
-        gchar *id;
-
-        id = g_strdup_printf ("%d", SEAT_UNITY (seat)->priv->next_id);
-        SEAT_UNITY (seat)->priv->next_id++;
-        mir_server_set_id (mir_server, id);
-        g_free (id);
-    }   
-
     return DISPLAY_SERVER (mir_server);
 }
 
@@ -534,7 +506,8 @@ seat_unity_create_greeter_session (Seat *seat)
 {
     Greeter *greeter_session;
     const gchar *xdg_seat;
-    gint vt = -1;
+    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");
@@ -543,9 +516,12 @@ seat_unity_create_greeter_session (Seat *seat)
     l_debug (seat, "Setting XDG_SEAT=%s", xdg_seat);
     session_set_env (SESSION (greeter_session), "XDG_SEAT", xdg_seat);
 
-    if (!SEAT_UNITY (seat)->priv->use_vt_switching)
-        vt = SEAT_UNITY (seat)->priv->vt;
+    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);
@@ -564,7 +540,8 @@ seat_unity_create_session (Seat *seat)
 {
     Session *session;
     const gchar *xdg_seat;
-    gint vt = -1;
+    gchar *id;
+    gint vt;
 
     session = SEAT_CLASS (seat_unity_parent_class)->create_session (seat);
     xdg_seat = seat_get_string_property (seat, "xdg-seat");
@@ -573,9 +550,12 @@ seat_unity_create_session (Seat *seat)
     l_debug (seat, "Setting XDG_SEAT=%s", xdg_seat);
     session_set_env (session, "XDG_SEAT", xdg_seat);
 
-    if (!SEAT_UNITY (seat)->priv->use_vt_switching)
-        vt = SEAT_UNITY (seat)->priv->vt;
+    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);
@@ -594,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);
@@ -618,8 +587,8 @@ seat_unity_set_active_session (Seat *seat, Session *session)
 
         if (IS_X_SERVER_LOCAL (display_server))
             id = x_server_local_get_mir_id (X_SERVER_LOCAL (display_server));
-        else if (IS_MIR_SERVER (display_server))
-            id = mir_server_get_id (MIR_SERVER (display_server));
+        else
+            id = session_get_env (session, "MIR_SERVER_NAME");
 
         if (id)
         {
@@ -636,24 +605,6 @@ 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;
-
-        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;
-        }
-
-        return NULL;
-    }
-
     return SEAT_UNITY (seat)->priv->active_session;
 }
 
@@ -666,16 +617,12 @@ seat_unity_set_next_session (Seat *seat, Session *session)
     if (!session)
         return;
 
-    /* If no compositor, don't worry about it */
-    if (SEAT_UNITY (seat)->priv->use_vt_switching)
-        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 if (IS_MIR_SERVER (display_server))
-        id = mir_server_get_id (MIR_SERVER (display_server));
+    else
+        id = session_get_env (session, "MIR_SERVER_NAME");
 
     if (id)
     {