From 5e737a57402fa626af7f037b9485bd172c8a3dff Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Mon, 30 Jul 2018 16:21:29 -0400 Subject: daemon: try harder to get to a login screen at logout commit 22c332ba and some follow up commits try to ensure the user never stays on a blank VT by jumping to a login screen in the event they'd end up on one. Unfortunately, that part of the code can't start a login screen if there's not one running at all. This commit moves the code to GdmLocalDisplyFactory where the login screens are created, so users won't end up on a blank VT even if no login screen is yet running. --- daemon/gdm-local-display-factory.c | 36 ++++++++++++++++++++++++---- daemon/gdm-manager.c | 48 -------------------------------------- 2 files changed, 31 insertions(+), 53 deletions(-) (limited to 'daemon') diff --git a/daemon/gdm-local-display-factory.c b/daemon/gdm-local-display-factory.c index f68eda8d..f214185f 100644 --- a/daemon/gdm-local-display-factory.c +++ b/daemon/gdm-local-display-factory.c @@ -28,6 +28,8 @@ #include #include +#include + #include "gdm-common.h" #include "gdm-manager.h" #include "gdm-display-factory.h" @@ -267,6 +269,7 @@ on_display_status_changed (GdmDisplay *display, int num; char *seat_id = NULL; char *session_type = NULL; + char *session_class = NULL; gboolean is_initial = TRUE; gboolean is_local = TRUE; @@ -278,6 +281,7 @@ on_display_status_changed (GdmDisplay *display, "is-initial", &is_initial, "is-local", &is_local, "session-type", &session_type, + "session-class", &session_class, NULL); status = gdm_display_get_status (display); @@ -297,7 +301,7 @@ on_display_status_changed (GdmDisplay *display, * ensures we get a new login screen when the user logs out, * if there isn't one. */ - if (is_local) { + if (is_local && g_strcmp0 (session_class, "greeter") != 0) { /* reset num failures */ factory->priv->num_failures = 0; @@ -342,6 +346,7 @@ on_display_status_changed (GdmDisplay *display, g_free (seat_id); g_free (session_type); + g_free (session_class); } static gboolean @@ -370,12 +375,33 @@ create_display (GdmLocalDisplayFactory *factory, { GdmDisplayStore *store; GdmDisplay *display = NULL; + char *active_session_id = NULL; + int ret; - /* Ensure we don't create the same display more than once */ store = gdm_display_factory_get_display_store (GDM_DISPLAY_FACTORY (factory)); - display = gdm_display_store_find (store, lookup_by_seat_id, (gpointer) seat_id); - if (display != NULL) { - return NULL; + + ret = sd_seat_get_active (seat_id, &active_session_id, NULL); + + if (ret == 0) { + char *login_session_id = NULL; + + /* If we already have a login window, switch to it */ + if (gdm_get_login_window_session_id (seat_id, &login_session_id)) { + if (g_strcmp0 (active_session_id, login_session_id) != 0) { + gdm_activate_session_by_id (factory->priv->connection, seat_id, login_session_id); + } + g_clear_pointer (&login_session_id, g_free); + g_clear_pointer (&active_session_id, g_free); + return NULL; + } + g_clear_pointer (&active_session_id, g_free); + } else { + /* Ensure we don't create the same display more than once */ + display = gdm_display_store_find (store, lookup_by_seat_id, (gpointer) seat_id); + + if (display != NULL) { + return NULL; + } } g_debug ("GdmLocalDisplayFactory: Adding display on seat %s", seat_id); diff --git a/daemon/gdm-manager.c b/daemon/gdm-manager.c index 11945522..f17bd1a5 100644 --- a/daemon/gdm-manager.c +++ b/daemon/gdm-manager.c @@ -1287,53 +1287,6 @@ maybe_start_pending_initial_login (GdmManager *manager, g_free (user_session_seat_id); } -static void -activate_login_window_session_on_seat (GdmManager *self, - const char *seat_id) -{ - char *session_id; - - if (!gdm_get_login_window_session_id (seat_id, &session_id)) { - return; - } - - if (session_id) { - gdm_activate_session_by_id (self, seat_id, session_id); - g_free (session_id); - } -} - -static void -maybe_activate_other_session (GdmManager *self, - GdmDisplay *old_display) -{ - char *seat_id = NULL; - char *session_id = NULL; - int ret; - - g_object_get (G_OBJECT (old_display), - "seat-id", &seat_id, - NULL); - - ret = sd_seat_get_active (seat_id, &session_id, NULL); - - if (ret == 0) { - GdmDisplay *display; - - display = gdm_display_store_find (self->priv->display_store, - lookup_by_session_id, - (gpointer) session_id); - - if (display == NULL || gdm_display_get_status (display) == GDM_DISPLAY_FINISHED) { - activate_login_window_session_on_seat (self, seat_id); - } - - g_free (session_id); - } - - g_free (seat_id); -} - static const char * get_username_for_greeter_display (GdmManager *manager, GdmDisplay *display) @@ -1579,7 +1532,6 @@ on_display_status_changed (GdmDisplay *display, manager->priv->ran_once = TRUE; } maybe_start_pending_initial_login (manager, display); - maybe_activate_other_session (manager, display); break; default: break; -- cgit v1.2.1