diff options
author | Alessandro Bono <alessandro.bono369@gmail.com> | 2022-10-12 17:53:44 +0200 |
---|---|---|
committer | Ray Strode <halfline@gmail.com> | 2022-10-28 18:31:38 +0000 |
commit | 6443bb4fb575486b3b0864713af0759ca1fe26d6 (patch) | |
tree | 5d46a7cf83ac2867984babf77a88be80e484af53 /daemon/gdm-local-display-factory.c | |
parent | 23e0134efcc0ef870bcc4d6b6d9a656df31396d6 (diff) | |
download | gdm-6443bb4fb575486b3b0864713af0759ca1fe26d6.tar.gz |
gdm-local-display-factory: Move early return on top
There is no need to perform all the checks if the display is already
created. While at it, add a debug message to make easier to understand
the message when a display already exists.
Diffstat (limited to 'daemon/gdm-local-display-factory.c')
-rw-r--r-- | daemon/gdm-local-display-factory.c | 56 |
1 files changed, 29 insertions, 27 deletions
diff --git a/daemon/gdm-local-display-factory.c b/daemon/gdm-local-display-factory.c index bdc242ae..471e1b46 100644 --- a/daemon/gdm-local-display-factory.c +++ b/daemon/gdm-local-display-factory.c @@ -765,6 +765,35 @@ ensure_display_for_seat (GdmLocalDisplayFactory *factory, g_autofree gchar *preferred_display_server = NULL; gboolean waiting_on_udev = FALSE; + g_debug ("GdmLocalDisplayFactory: display for seat %s requested", seat_id); + + /* Ensure we don't create the same display more than once */ + display = get_display_for_seat (factory, seat_id); + if (display != NULL) { + g_debug ("GdmLocalDisplayFactory: display for %s already created", seat_id); + return; + } + + /* If we already have a login window, switch to it */ + if (gdm_get_login_window_session_id (seat_id, &login_session_id)) { + GdmDisplay *display; + GdmDisplayStore *store; + + store = gdm_display_factory_get_display_store (GDM_DISPLAY_FACTORY (factory)); + display = gdm_display_store_find (store, + lookup_by_session_id, + (gpointer) login_session_id); + if (display != NULL && + (gdm_display_get_status (display) == GDM_DISPLAY_MANAGED || + gdm_display_get_status (display) == GDM_DISPLAY_WAITING_TO_FINISH)) { + g_object_set (G_OBJECT (display), "status", GDM_DISPLAY_MANAGED, NULL); + g_debug ("GdmLocalDisplayFactory: session %s found, activating.", + login_session_id); + gdm_activate_session_by_id (factory->connection, seat_id, login_session_id); + return; + } + } + preferred_display_server = get_preferred_display_server (factory); if (g_strcmp0 (preferred_display_server, "none") == 0) { @@ -873,33 +902,6 @@ ensure_display_for_seat (GdmLocalDisplayFactory *factory, g_debug ("GdmLocalDisplayFactory: %s login display for seat %s requested", session_types[0], seat_id); - /* Ensure we don't create the same display more than once */ - display = get_display_for_seat (factory, seat_id); - if (display != NULL) { - g_debug ("GdmLocalDisplayFactory: display for %s already created", seat_id); - return; - } - - /* If we already have a login window, switch to it */ - if (gdm_get_login_window_session_id (seat_id, &login_session_id)) { - GdmDisplay *display; - GdmDisplayStore *store; - - store = gdm_display_factory_get_display_store (GDM_DISPLAY_FACTORY (factory)); - display = gdm_display_store_find (store, - lookup_by_session_id, - (gpointer) login_session_id); - if (display != NULL && - (gdm_display_get_status (display) == GDM_DISPLAY_MANAGED || - gdm_display_get_status (display) == GDM_DISPLAY_WAITING_TO_FINISH)) { - g_object_set (G_OBJECT (display), "status", GDM_DISPLAY_MANAGED, NULL); - g_debug ("GdmLocalDisplayFactory: session %s found, activating.", - login_session_id); - gdm_activate_session_by_id (factory->connection, seat_id, login_session_id); - return; - } - } - g_debug ("GdmLocalDisplayFactory: Adding display on seat %s", seat_id); #ifdef ENABLE_USER_DISPLAY_SERVER |