Centralize DESKTOP_STARTUP/AUTOSTART_ID handling
Add private API to GDK to move these variables from the environment into static scope. Also move the DESKTOP_STARTUP_ID validation here to reduce code duplication. Use constructors to read them as early as possible; however, do not unset them until first requested. This avoids breaking gnome-shell and gnome-settings-daemon, which want to use the DESKTOP_AUTOSTART_ID in their own gnome-session clients. Fixes https://gitlab.gnome.org/GNOME/gtk/issues/1761
This commit is contained in:
@ -26,7 +26,7 @@
|
||||
#include "gtksettings.h"
|
||||
#include "gtkprivate.h"
|
||||
|
||||
#include "gdk/gdkconstructor.h"
|
||||
#include "gdk/gdk-private.h"
|
||||
|
||||
G_DEFINE_TYPE (GtkApplicationImplDBus, gtk_application_impl_dbus, GTK_TYPE_APPLICATION_IMPL)
|
||||
|
||||
@ -155,29 +155,6 @@ gtk_application_get_proxy_if_service_present (GDBusConnection *connection,
|
||||
return proxy;
|
||||
}
|
||||
|
||||
#ifdef G_HAS_CONSTRUCTORS
|
||||
#ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
|
||||
#pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(stash_desktop_autostart_id)
|
||||
#endif
|
||||
G_DEFINE_CONSTRUCTOR(stash_desktop_autostart_id)
|
||||
#endif
|
||||
|
||||
static char *client_id = NULL;
|
||||
|
||||
static void
|
||||
stash_desktop_autostart_id (void)
|
||||
{
|
||||
const char *desktop_autostart_id;
|
||||
|
||||
desktop_autostart_id = g_getenv ("DESKTOP_AUTOSTART_ID");
|
||||
client_id = g_strdup (desktop_autostart_id ? desktop_autostart_id : "");
|
||||
|
||||
/* Unset DESKTOP_AUTOSTART_ID in order to avoid child processes to
|
||||
* use the same client id.
|
||||
*/
|
||||
g_unsetenv ("DESKTOP_AUTOSTART_ID");
|
||||
}
|
||||
|
||||
static void
|
||||
screensaver_signal_session (GDBusProxy *proxy,
|
||||
const char *sender_name,
|
||||
@ -280,10 +257,7 @@ gtk_application_impl_dbus_startup (GtkApplicationImpl *impl,
|
||||
gboolean same_bus;
|
||||
const char *bus_name;
|
||||
const char *client_interface;
|
||||
|
||||
#ifndef G_HAS_CONSTRUCTORS
|
||||
stash_desktop_autostart_id ();
|
||||
#endif
|
||||
const char *client_id = GDK_PRIVATE_CALL (gdk_get_desktop_autostart_id) ();
|
||||
|
||||
dbus->session = g_application_get_dbus_connection (G_APPLICATION (impl->application));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user