]> rtime.felk.cvut.cz Git - sojka/lightdm.git/blobdiff - src/seat.c
Override logind's or consolekit's decision to automatically change active session...
[sojka/lightdm.git] / src / seat.c
index 7347d1ce87b00b268374cb5e0cd04e6879a0717b..040b289d7a7d1ee721bfdcdbb7754f18b1348aea 100644 (file)
@@ -232,6 +232,8 @@ seat_set_active_session (Seat *seat, Session *session)
             session_lock (seat->priv->active_session);
         g_object_unref (seat->priv->active_session);
     }
+
+    session_activate (session);
     seat->priv->active_session = g_object_ref (session);
 }
 
@@ -269,7 +271,7 @@ run_script (Seat *seat, DisplayServer *display_server, const gchar *script_name,
     Process *script;
     gboolean result = FALSE;
   
-    script = process_new ();
+    script = process_new (NULL, NULL);
 
     process_set_command (script, script_name);
 
@@ -526,6 +528,17 @@ run_session (Seat *seat, Session *session)
         g_object_unref (seat->priv->session_to_activate);
         seat->priv->session_to_activate = NULL;
     }
+    else if (session != seat->priv->active_session)
+    {
+        /* Multiple sessions can theoretically be on the same VT (especially
+           if using Mir).  If a new session appears on an existing active VT,
+           logind will mark it as active, while ConsoleKit will re-mark the
+           oldest session as active.  In either case, that may not be the
+           session that we want to be active.  So let's be explicit and
+           re-activate the correct session whenever a new session starts.
+           There's no harm to do this in seats that enforce separate VTs. */
+        session_activate (seat->priv->active_session);
+    }
 }
 
 static Session *
@@ -924,14 +937,17 @@ prepend_argv (gchar ***argv, const gchar *value)
 }
 
 static Session *
-create_guest_session (Seat *seat)
+create_guest_session (Seat *seat, const gchar *session_name)
 {
-    const gchar *session_name, *guest_wrapper;
+    const gchar *guest_wrapper;
     gchar *sessions_dir, **argv;
     SessionConfig *session_config;
     Session *session;
 
-    session_name = seat_get_string_property (seat, "user-session");
+    if (!session_name)
+        session_name = seat_get_string_property (seat, "guest-session");
+    if (!session_name)
+        session_name = seat_get_string_property (seat, "user-session");
     sessions_dir = config_get_string (config_get_instance (), "LightDM", "sessions-directory");
     session_config = find_session_config (seat, sessions_dir, session_name);
     g_free (sessions_dir);
@@ -984,7 +1000,7 @@ greeter_start_session_cb (Greeter *greeter, SessionType type, const gchar *sessi
     /* Get the session to use */
     if (greeter_get_guest_authenticated (greeter))
     {
-        session = create_guest_session (seat);
+        session = create_guest_session (seat, session_name);
         if (!session)
             return FALSE;
         session_set_pam_service (session, AUTOLOGIN_SERVICE);
@@ -1395,7 +1411,7 @@ seat_switch_to_guest (Seat *seat, const gchar *session_name)
         return TRUE;
     }
 
-    session = create_guest_session (seat);
+    session = create_guest_session (seat, session_name);
     if (!session)
         return FALSE;
 
@@ -1511,7 +1527,7 @@ seat_real_start (Seat *seat)
     if (autologin_timeout == 0 || autologin_in_background)
     {
         if (autologin_guest)
-            session = create_guest_session (seat);
+            session = create_guest_session (seat, NULL);
         else if (autologin_username != NULL)
             session = create_user_session (seat, autologin_username, TRUE);