core: Retrieve DESKTOP_AUTOSTART_ID early on startup

With the move away from GTK3, and the indirect dependency on GTK4
grown in the GNOME Shell side, we've indirectly gotten a small sneaky
behavioral change: The GTK4 library will, right on dlopen, get
DESKTOP_AUTOSTART_ID for itself and delete it from the environment.

This happens before our own X11 session management code is
initialized, which confuses the hell out of it, into thinking
initialization is actually shutdown, gnome-session does not follow
along with this request, which leaves GNOME Shell into a confused
startup state where it never calls SmcSaveYourselfDone() and grinds
startup to a halt until gnome-session decides to move things forward.

In order to fix this, get the DESKTOP_AUTOSTART_ID before we lend
control to GNOME Shell bits and GTK4 is possibly initialized, and
feed it directly to our X11 session manager bits.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2906>
This commit is contained in:
Carlos Garnacho 2023-03-09 17:34:22 +01:00 committed by Marge Bot
parent d31b781efb
commit 5daddf0bc7
2 changed files with 11 additions and 10 deletions

View File

@ -289,6 +289,17 @@ meta_context_main_configure (MetaContext *context,
meta_wayland_override_display_name (context_main->options.wayland_display);
#endif
if (!context_main->options.sm.client_id)
{
const char *desktop_autostart_id;
desktop_autostart_id = g_getenv ("DESKTOP_AUTOSTART_ID");
if (desktop_autostart_id)
context_main->options.sm.client_id = g_strdup (desktop_autostart_id);
}
g_unsetenv ("DESKTOP_AUTOSTART_ID");
return TRUE;
}

View File

@ -280,16 +280,6 @@ meta_session_init (MetaContext *context,
SmcCallbacks callbacks;
char *saved_client_id;
if (!previous_client_id)
{
const char *desktop_autostart_id;
desktop_autostart_id = g_getenv ("DESKTOP_AUTOSTART_ID");
if (desktop_autostart_id)
previous_client_id = desktop_autostart_id;
}
g_unsetenv ("DESKTOP_AUTOSTART_ID");
meta_topic (META_DEBUG_SM, "Initializing session with save file '%s'",
previous_save_file ? previous_save_file : "(none)");