[gnome-shell/wip/iainl/sd-notify-later] main, util: Notify systemd once we are fully initialised



commit 4c57edc9b5a0aa269a8fee161ca5dcb9bd06ea53
Author: Iain Lane <iainl gnome org>
Date:   Fri Oct 4 12:11:06 2019 +0100

    main, util: Notify systemd once we are fully initialised
    
    If graphical applications want to start from systemd units, they need to
    start after we're properly ready to display them. This is particularly
    important under X where `_GTK_FRAME_EXTENTS` and other xprops are needed
    to have the right theming.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/750

 js/ui/main.js    |  1 +
 src/main.c       | 11 -----------
 src/shell-util.c | 16 ++++++++++++++++
 src/shell-util.h |  2 ++
 4 files changed, 19 insertions(+), 11 deletions(-)
---
diff --git a/js/ui/main.js b/js/ui/main.js
index e8269f09be..40aa2d3628 100644
--- a/js/ui/main.js
+++ b/js/ui/main.js
@@ -229,6 +229,7 @@ function _initializeUI() {
     EndSessionDialog.init();
 
     // We're ready for the session manager to move to the next phase
+    Shell.util_sd_notify();
     Meta.register_with_session();
 
     _startDate = new Date();
diff --git a/src/main.c b/src/main.c
index 489026b765..6faf9934fb 100644
--- a/src/main.c
+++ b/src/main.c
@@ -24,14 +24,6 @@
 #include "shell-perf-log.h"
 #include "st.h"
 
-#ifdef HAVE_SYSTEMD
-#include <systemd/sd-daemon.h>
-#else
-/* So we don't need to add ifdef's everywhere */
-#define sd_notify(u, m)            do {} while (0)
-#define sd_notifyf(u, m, ...)      do {} while (0)
-#endif
-
 extern GType gnome_shell_plugin_get_type (void);
 
 #define SHELL_DBUS_SERVICE "org.gnome.Shell"
@@ -532,9 +524,6 @@ main (int argc, char **argv)
   shell_init_debug (g_getenv ("SHELL_DEBUG"));
 
   shell_dbus_init (meta_get_replace_current_wm ());
-  /* We only use NOTIFY_SOCKET exactly once; unset it so it doesn't remain in
-   * our environment. */
-  sd_notify (1, "READY=1");
   shell_a11y_init ();
   shell_perf_log_init ();
   shell_introspection_init ();
diff --git a/src/shell-util.c b/src/shell-util.c
index c22dd1c6e5..86b1de869e 100644
--- a/src/shell-util.c
+++ b/src/shell-util.c
@@ -26,6 +26,14 @@
 #include <langinfo.h>
 #endif
 
+#ifdef HAVE_SYSTEMD
+#include <systemd/sd-daemon.h>
+#else
+/* So we don't need to add ifdef's everywhere */
+#define sd_notify(u, m)            do {} while (0)
+#define sd_notifyf(u, m, ...)      do {} while (0)
+#endif
+
 static void
 stop_pick (ClutterActor       *actor,
            const ClutterColor *color)
@@ -659,3 +667,11 @@ shell_util_stop_systemd_unit (const char  *unit,
 {
   return shell_util_systemd_call ("StopUnit", unit, mode, error);
 }
+
+void
+shell_util_sd_notify ()
+{
+  /* We only use NOTIFY_SOCKET exactly once; unset it so it doesn't remain in
+   * our environment. */
+  sd_notify (1, "READY=1");
+}
diff --git a/src/shell-util.h b/src/shell-util.h
index c41e02c798..4453beb4a5 100644
--- a/src/shell-util.h
+++ b/src/shell-util.h
@@ -66,6 +66,8 @@ gboolean shell_util_stop_systemd_unit  (const char  *unit,
                                         const char  *mode,
                                         GError     **error);
 
+void shell_util_sd_notify (void);
+
 G_END_DECLS
 
 #endif /* __SHELL_UTIL_H__ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]