Commit f40c940f authored by Ray Strode's avatar Ray Strode

Merge branch 'wip/gdm-vt-switch-fixes' into 'master'

Wip/gdm vt switch fixes

See merge request !48
parents 5db19c5b 2882e80f
Pipeline #32505 passed with stage
in 3 minutes and 51 seconds
...@@ -432,8 +432,7 @@ create_display (GdmLocalDisplayFactory *factory, ...@@ -432,8 +432,7 @@ create_display (GdmLocalDisplayFactory *factory,
{ {
GdmDisplayStore *store; GdmDisplayStore *store;
GdmDisplay *display = NULL; GdmDisplay *display = NULL;
char *active_session_id = NULL; g_autofree char *login_session_id = NULL;
int ret;
g_debug ("GdmLocalDisplayFactory: %s login display for seat %s requested", g_debug ("GdmLocalDisplayFactory: %s login display for seat %s requested",
session_type? : "X11", seat_id); session_type? : "X11", seat_id);
...@@ -450,31 +449,22 @@ create_display (GdmLocalDisplayFactory *factory, ...@@ -450,31 +449,22 @@ create_display (GdmLocalDisplayFactory *factory,
return NULL; return NULL;
} }
ret = sd_seat_get_active (seat_id, &active_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 (ret == 0) { GdmDisplay *display;
char *login_session_id = NULL;
display = gdm_display_store_find (store,
/* If we already have a login window, switch to it */ lookup_by_session_id,
if (gdm_get_login_window_session_id (seat_id, &login_session_id)) { (gpointer) login_session_id);
GdmDisplay *display; if (display != NULL &&
(gdm_display_get_status (display) == GDM_DISPLAY_MANAGED ||
display = gdm_display_store_find (store, gdm_display_get_status (display) == GDM_DISPLAY_WAITING_TO_FINISH)) {
lookup_by_session_id, g_object_set (G_OBJECT (display), "status", GDM_DISPLAY_MANAGED, NULL);
(gpointer) login_session_id); g_debug ("GdmLocalDisplayFactory: session %s found, activating.",
if (display != NULL && gdm_display_get_status (display) == GDM_DISPLAY_MANAGED) { 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_debug ("GdmLocalDisplayFactory: session %s found, activating.", return NULL;
login_session_id);
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 (&login_session_id, g_free);
} }
g_clear_pointer (&active_session_id, g_free);
} }
g_debug ("GdmLocalDisplayFactory: Adding display on seat %s", seat_id); g_debug ("GdmLocalDisplayFactory: Adding display on seat %s", seat_id);
...@@ -629,6 +619,7 @@ maybe_stop_greeter_in_background (GdmLocalDisplayFactory *factory, ...@@ -629,6 +619,7 @@ maybe_stop_greeter_in_background (GdmLocalDisplayFactory *factory,
GdmDisplay *display) GdmDisplay *display)
{ {
g_autofree char *display_session_type = NULL; g_autofree char *display_session_type = NULL;
gboolean doing_initial_setup = FALSE;
if (gdm_display_get_status (display) != GDM_DISPLAY_MANAGED) { if (gdm_display_get_status (display) != GDM_DISPLAY_MANAGED) {
g_debug ("GdmLocalDisplayFactory: login window not in managed state, so ignoring"); g_debug ("GdmLocalDisplayFactory: login window not in managed state, so ignoring");
...@@ -637,8 +628,15 @@ maybe_stop_greeter_in_background (GdmLocalDisplayFactory *factory, ...@@ -637,8 +628,15 @@ maybe_stop_greeter_in_background (GdmLocalDisplayFactory *factory,
g_object_get (G_OBJECT (display), g_object_get (G_OBJECT (display),
"session-type", &display_session_type, "session-type", &display_session_type,
"doing-initial-setup", &doing_initial_setup,
NULL); NULL);
/* we don't ever stop initial-setup implicitly */
if (doing_initial_setup) {
g_debug ("GdmLocalDisplayFactory: login window is performing initial-setup, so ignoring");
return;
}
/* we can only stop greeter for wayland sessions, since /* we can only stop greeter for wayland sessions, since
* X server would jump back on exit */ * X server would jump back on exit */
if (g_strcmp0 (display_session_type, "wayland") != 0) { if (g_strcmp0 (display_session_type, "wayland") != 0) {
...@@ -766,19 +764,6 @@ on_vt_changed (GIOChannel *source, ...@@ -766,19 +764,6 @@ on_vt_changed (GIOChannel *source,
return G_SOURCE_CONTINUE; return G_SOURCE_CONTINUE;
} }
ret = sd_seat_get_active ("seat0", &active_session_id, NULL);
if (ret == 0) {
g_autofree char *state = NULL;
ret = sd_session_get_state (active_session_id, &state);
/* if there's something already running on the active VT then bail */
if (ret == 0 && g_strcmp0 (state, "closing") != 0) {
g_debug ("GdmLocalDisplayFactory: initial VT is in use, so ignoring");
return G_SOURCE_CONTINUE;
}
}
if (gdm_local_display_factory_use_wayland ()) if (gdm_local_display_factory_use_wayland ())
session_type = "wayland"; session_type = "wayland";
......
...@@ -78,6 +78,7 @@ struct GdmManagerPrivate ...@@ -78,6 +78,7 @@ struct GdmManagerPrivate
#ifdef HAVE_LIBXDMCP #ifdef HAVE_LIBXDMCP
GdmXdmcpDisplayFactory *xdmcp_factory; GdmXdmcpDisplayFactory *xdmcp_factory;
#endif #endif
GdmDisplay *automatic_login_display;
GList *user_sessions; GList *user_sessions;
GHashTable *transient_sessions; GHashTable *transient_sessions;
GHashTable *open_reauthentication_requests; GHashTable *open_reauthentication_requests;
...@@ -92,7 +93,7 @@ struct GdmManagerPrivate ...@@ -92,7 +93,7 @@ struct GdmManagerPrivate
#ifdef WITH_PLYMOUTH #ifdef WITH_PLYMOUTH
guint plymouth_is_running : 1; guint plymouth_is_running : 1;
#endif #endif
guint ran_once : 1; guint did_automatic_login : 1;
}; };
enum { enum {
...@@ -1272,7 +1273,6 @@ set_up_automatic_login_session (GdmManager *manager, ...@@ -1272,7 +1273,6 @@ set_up_automatic_login_session (GdmManager *manager,
{ {
GdmSession *session; GdmSession *session;
char *display_session_type = NULL; char *display_session_type = NULL;
gboolean is_initial;
/* 0 is root user; since the daemon talks to the session object /* 0 is root user; since the daemon talks to the session object
* directly, itself, for automatic login * directly, itself, for automatic login
...@@ -1280,12 +1280,11 @@ set_up_automatic_login_session (GdmManager *manager, ...@@ -1280,12 +1280,11 @@ set_up_automatic_login_session (GdmManager *manager,
session = create_user_session_for_display (manager, display, 0); session = create_user_session_for_display (manager, display, 0);
g_object_get (G_OBJECT (display), g_object_get (G_OBJECT (display),
"is-initial", &is_initial,
"session-type", &display_session_type, "session-type", &display_session_type,
NULL); NULL);
g_object_set (G_OBJECT (session), g_object_set (G_OBJECT (session),
"display-is-initial", is_initial, "display-is-initial", FALSE,
NULL); NULL);
g_debug ("GdmManager: Starting automatic login conversation"); g_debug ("GdmManager: Starting automatic login conversation");
...@@ -1380,13 +1379,20 @@ set_up_session (GdmManager *manager, ...@@ -1380,13 +1379,20 @@ set_up_session (GdmManager *manager,
ActUserManager *user_manager; ActUserManager *user_manager;
ActUser *user; ActUser *user;
gboolean loaded; gboolean loaded;
gboolean is_initial_display = FALSE; gboolean seat_can_autologin = FALSE, seat_did_autologin = FALSE;
gboolean autologin_enabled = FALSE; gboolean autologin_enabled = FALSE;
g_autofree char *seat_id = NULL;
char *username = NULL; char *username = NULL;
g_object_get (G_OBJECT (display), "is-initial", &is_initial_display, NULL); g_object_get (G_OBJECT (display), "seat-id", &seat_id, NULL);
if (g_strcmp0 (seat_id, "seat0") == 0)
seat_can_autologin = TRUE;
if (manager->priv->did_automatic_login || manager->priv->automatic_login_display != NULL)
seat_did_autologin = TRUE;
if (!manager->priv->ran_once && is_initial_display) if (seat_can_autologin && !seat_did_autologin)
autologin_enabled = get_automatic_login_details (manager, &username); autologin_enabled = get_automatic_login_details (manager, &username);
if (!autologin_enabled) { if (!autologin_enabled) {
...@@ -1477,8 +1483,18 @@ on_display_status_changed (GdmDisplay *display, ...@@ -1477,8 +1483,18 @@ on_display_status_changed (GdmDisplay *display,
} }
#endif #endif
if (!doing_initial_setup && (status == GDM_DISPLAY_FINISHED || g_strcmp0 (session_type, "x11") == 0)) { if (display == manager->priv->automatic_login_display) {
manager->priv->ran_once = TRUE; g_clear_weak_pointer (&manager->priv->automatic_login_display);
manager->priv->did_automatic_login = TRUE;
#ifdef ENABLE_WAYLAND_SUPPORT
if (g_strcmp0 (session_type, "wayland") != 0 && status == GDM_DISPLAY_FAILED) {
/* we're going to fall back to X11, so try to autologin again
*/
manager->priv->did_automatic_login = FALSE;
}
#endif
} }
break; break;
default: default:
...@@ -1661,17 +1677,21 @@ on_start_user_session (StartUserSessionOperation *operation) ...@@ -1661,17 +1677,21 @@ on_start_user_session (StartUserSessionOperation *operation)
g_object_set_data (G_OBJECT (operation->session), "gdm-display", NULL); g_object_set_data (G_OBJECT (operation->session), "gdm-display", NULL);
create_user_session_for_display (operation->manager, display, allowed_uid); create_user_session_for_display (operation->manager, display, allowed_uid);
/* Give the user session a new display object for bookkeeping purposes */
create_display_for_user_session (operation->manager,
operation->session,
session_id);
if (g_strcmp0 (operation->service_name, "gdm-autologin") == 0) { if (g_strcmp0 (operation->service_name, "gdm-autologin") == 0) {
/* remove the unused prepared greeter display since we're not going /* remove the unused prepared greeter display since we're not going
* to have a greeter */ * to have a greeter */
gdm_display_store_remove (self->priv->display_store, display); gdm_display_store_remove (self->priv->display_store, display);
g_object_unref (display); g_object_unref (display);
}
/* Give the user session a new display object for bookkeeping purposes */ self->priv->automatic_login_display = g_object_get_data (G_OBJECT (operation->session), "gdm-display");
create_display_for_user_session (operation->manager, g_object_add_weak_pointer (G_OBJECT (display), (gpointer *) &self->priv->automatic_login_display);
operation->session, }
session_id);
} }
start_user_session (operation->manager, operation); start_user_session (operation->manager, operation);
...@@ -2565,6 +2585,8 @@ gdm_manager_dispose (GObject *object) ...@@ -2565,6 +2585,8 @@ gdm_manager_dispose (GObject *object)
g_return_if_fail (manager->priv != NULL); g_return_if_fail (manager->priv != NULL);
g_clear_weak_pointer (&manager->priv->automatic_login_display);
#ifdef HAVE_LIBXDMCP #ifdef HAVE_LIBXDMCP
g_clear_object (&manager->priv->xdmcp_factory); g_clear_object (&manager->priv->xdmcp_factory);
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment