/* The sessions on this seat */
GList *sessions;
+ /* The last session set to active */
+ Session *active_session;
+
+ /* The session belonging to the active greeter user */
+ Session *next_session;
+
/* The session to set active when it starts */
Session *session_to_activate;
g_return_if_fail (seat != NULL);
+ /* Unlock this session */
+ if (session != seat->priv->active_session && !IS_GREETER (session))
+ session_unlock (session);
+
SEAT_GET_CLASS (seat)->set_active_session (seat, session);
/* Stop any greeters */
session_stop (s);
}
}
+
+ /* Lock previous sessions */
+ if (seat->priv->active_session)
+ {
+ if (session != seat->priv->active_session && !IS_GREETER (seat->priv->active_session))
+ session_lock (seat->priv->active_session);
+ g_object_unref (seat->priv->active_session);
+ }
+ seat->priv->active_session = g_object_ref (session);
}
Session *
return SEAT_GET_CLASS (seat)->get_active_session (seat);
}
+Session *
+seat_get_next_session (Seat *seat)
+{
+ g_return_val_if_fail (seat != NULL, NULL);
+ return seat->priv->next_session;
+}
+
gboolean
seat_get_can_switch (Seat *seat)
{
}
if (!IS_GREETER (session))
+ {
g_signal_emit (seat, signals[RUNNING_USER_SESSION], 0, session);
+ emit_upstart_signal ("desktop-session-start");
+ }
session_run (session);
}
}
+static Session *
+find_user_session (Seat *seat, const gchar *username)
+{
+ GList *link;
+
+ if (!username)
+ return NULL;
+
+ for (link = seat->priv->sessions; link; link = link->next)
+ {
+ Session *session = link->data;
+
+ if (!session_get_is_stopping (session) && strcmp (session_get_username (session), username) == 0)
+ return session;
+ }
+
+ return NULL;
+}
+
+static void
+greeter_active_username_changed_cb (Greeter *greeter, GParamSpec *pspec, Seat *seat)
+{
+ Session *session;
+
+ session = find_user_session (seat, greeter_get_active_username (greeter));
+ if (session)
+ {
+ if (seat->priv->next_session)
+ g_object_unref (seat->priv->next_session);
+ seat->priv->next_session = g_object_ref (session);
+
+ SEAT_GET_CLASS (seat)->set_next_session (seat, session);
+ }
+}
+
static void
session_authentication_complete_cb (Session *session, Seat *seat)
{
g_signal_handlers_disconnect_matched (session, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, seat);
seat->priv->sessions = g_list_remove (seat->priv->sessions, session);
+ if (session == seat->priv->active_session)
+ {
+ g_object_unref (seat->priv->active_session);
+ seat->priv->active_session = NULL;
+ }
+ if (session == seat->priv->next_session)
+ {
+ g_object_unref (seat->priv->next_session);
+ seat->priv->next_session = NULL;
+ }
+ if (session == seat->priv->session_to_activate)
+ {
+ g_object_unref (seat->priv->session_to_activate);
+ seat->priv->session_to_activate = NULL;
+ }
display_server = session_get_display_server (session);
if (!display_server)
}
static Session *
-create_session (Seat *seat, gboolean autostart)
+create_session (Seat *seat, gboolean autostart, const gchar *username)
{
Session *session;
+ Session *user_session;
- session = SEAT_GET_CLASS (seat)->create_session (seat);
+ user_session = find_user_session (seat, username);
+ session = SEAT_GET_CLASS (seat)->create_session (seat, user_session);
seat->priv->sessions = g_list_append (seat->priv->sessions, session);
if (autostart)
g_signal_connect (session, "authentication-complete", G_CALLBACK (session_authentication_complete_cb), seat);
g_free (sessions_dir);
if (session_config)
{
+ const gchar *desktop_name;
gchar **argv;
- session = create_session (seat, TRUE);
+ session = create_session (seat, TRUE, username);
session_set_session_type (session, session_config_get_session_type (session_config));
session_set_env (session, "DESKTOP_SESSION", session_name);
session_set_env (session, "GDMSESSION", session_name);
+ desktop_name = session_config_get_desktop_name (session_config);
+ if (desktop_name)
+ session_set_env (session, "XDG_CURRENT_DESKTOP", desktop_name);
if (language && language[0] != '\0')
{
session_set_env (session, "LANG", language);
return NULL;
}
- session = create_session (seat, TRUE);
+ session = create_session (seat, TRUE, NULL);
session_set_session_type (session, session_config_get_session_type (session_config));
session_set_do_authenticate (session, TRUE);
session_set_is_guest (session, TRUE);
}
static Session *
-greeter_create_session_cb (Greeter *greeter, Seat *seat)
+greeter_create_session_cb (Greeter *greeter, Seat *seat, const gchar *username)
{
Session *session;
- session = create_session (seat, FALSE);
+ session = create_session (seat, FALSE, username);
session_set_session_type (session, session_get_session_type (SESSION (greeter)));
session_set_display_server (session, session_get_display_server (SESSION (greeter)));
*argv = new_argv;
}
-static Session *
-find_user_session (Seat *seat, const gchar *username)
-{
- GList *link;
-
- if (!username)
- return NULL;
-
- for (link = seat->priv->sessions; link; link = link->next)
- {
- Session *session = link->data;
-
- if (!session_get_is_stopping (session) && strcmp (session_get_username (session), username) == 0)
- return session;
- }
-
- return NULL;
-}
-
static gboolean
greeter_start_session_cb (Greeter *greeter, SessionType type, const gchar *session_name, Seat *seat)
{
greeter_session = SEAT_GET_CLASS (seat)->create_greeter_session (seat);
session_set_session_type (SESSION (greeter_session), session_config_get_session_type (session_config));
seat->priv->sessions = g_list_append (seat->priv->sessions, SESSION (greeter_session));
+ g_signal_connect (greeter_session, "notify::active-username", G_CALLBACK (greeter_active_username_changed_cb), seat);
g_signal_connect (greeter_session, "authentication-complete", G_CALLBACK (session_authentication_complete_cb), seat);
g_signal_connect (greeter_session, "stopped", G_CALLBACK (session_stopped_cb), seat);
}
static Session *
-seat_real_create_session (Seat *seat)
+seat_real_create_session (Seat *seat, Session *user_session)
{
return session_new ();
}
{
}
+static void
+seat_real_set_next_session (Seat *seat, Session *session)
+{
+}
+
static Session *
seat_real_get_active_session (Seat *seat)
{
g_signal_handlers_disconnect_matched (session, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, self);
}
g_list_free_full (self->priv->sessions, g_object_unref);
+ if (self->priv->active_session)
+ g_object_unref (self->priv->active_session);
+ if (self->priv->next_session)
+ g_object_unref (self->priv->next_session);
if (self->priv->session_to_activate)
g_object_unref (self->priv->session_to_activate);
klass->create_session = seat_real_create_session;
klass->set_active_session = seat_real_set_active_session;
klass->get_active_session = seat_real_get_active_session;
+ klass->set_next_session = seat_real_set_next_session;
klass->run_script = seat_real_run_script;
klass->stop = seat_real_stop;