[mutter] core: make session registration an explicit step



commit 773ae8dc65aecabf711e6799835d567aa1f5098d
Author: Ray Strode <rstrode redhat com>
Date:   Thu Feb 28 10:37:03 2013 -0500

    core: make session registration an explicit step
    
    gnome-shell shouldn't announce to the session manager it's
    "ready" until it's fully initialized.  It currently tells
    the session manager it's ready as soon as it hits the main
    loop. This causes nautilus in classic mode to start before
    we have workspaces initialized.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=694876

 src/core/main.c   |   70 ++++++++++++++++++++++++++++++----------------------
 src/core/mutter.c |    1 +
 src/meta/main.h   |    7 +++--
 3 files changed, 45 insertions(+), 33 deletions(-)
---
diff --git a/src/core/main.c b/src/core/main.c
index e590854..6070918 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -447,9 +447,48 @@ meta_init (void)
 }
 
 /**
+ * meta_register_with_session:
+ *
+ * Registers mutter with the session manager.  Call this after completing your own
+ * initialization.
+ *
+ * This should be called when the session manager can safely continue to the
+ * next phase of startup and potentially display windows.
+ */
+void
+meta_register_with_session (void)
+{
+  if (!opt_disable_sm)
+    {
+      if (opt_client_id == NULL)
+        {
+          const gchar *desktop_autostart_id;
+
+          desktop_autostart_id = g_getenv ("DESKTOP_AUTOSTART_ID");
+
+          if (desktop_autostart_id != NULL)
+            opt_client_id = g_strdup (desktop_autostart_id);
+        }
+
+      /* Unset DESKTOP_AUTOSTART_ID in order to avoid child processes to
+       * use the same client id. */
+      g_unsetenv ("DESKTOP_AUTOSTART_ID");
+
+      meta_session_init (opt_client_id, opt_save_file);
+    }
+  /* Free memory possibly allocated by the argument parsing which are
+   * no longer needed.
+   */
+  g_free (opt_save_file);
+  g_free (opt_display_name);
+  g_free (opt_client_id);
+}
+
+/**
  * meta_run: (skip)
  *
- * Runs mutter. Call this after completing your own initialization.
+ * Runs mutter. Call this after completing initialization that doesn't require
+ * an event loop.
  *
  * Return value: mutter's exit status
  */
@@ -509,35 +548,6 @@ meta_run (void)
   if (!meta_ui_have_a_theme ())
     meta_fatal (_("Could not find a theme! Be sure %s exists and contains the usual themes.\n"),
                 MUTTER_DATADIR"/themes");
-  
-  /* Connect to SM as late as possible - but before managing display,
-   * or we might try to manage a window before we have the session
-   * info
-   */
-  if (!opt_disable_sm)
-    {
-      if (opt_client_id == NULL)
-        {
-          const gchar *desktop_autostart_id;
-  
-          desktop_autostart_id = g_getenv ("DESKTOP_AUTOSTART_ID");
- 
-          if (desktop_autostart_id != NULL)
-            opt_client_id = g_strdup (desktop_autostart_id);
-        }
-
-      /* Unset DESKTOP_AUTOSTART_ID in order to avoid child processes to
-       * use the same client id. */
-      g_unsetenv ("DESKTOP_AUTOSTART_ID");
-
-      meta_session_init (opt_client_id, opt_save_file);
-    }
-  /* Free memory possibly allocated by the argument parsing which are
-   * no longer needed.
-   */
-  g_free (opt_save_file);
-  g_free (opt_display_name);
-  g_free (opt_client_id);
 
   if (!meta_display_open ())
     meta_exit (META_EXIT_ERROR);
diff --git a/src/core/mutter.c b/src/core/mutter.c
index feb617b..3216726 100644
--- a/src/core/mutter.c
+++ b/src/core/mutter.c
@@ -81,5 +81,6 @@ main (int argc, char **argv)
     meta_plugin_manager_load (plugin);
 
   meta_init ();
+  meta_register_with_session ();
   return meta_run ();
 }
diff --git a/src/meta/main.h b/src/meta/main.h
index 1382678..256987e 100644
--- a/src/meta/main.h
+++ b/src/meta/main.h
@@ -26,9 +26,10 @@
 
 #include <glib.h>
 
-GOptionContext *meta_get_option_context (void);
-void            meta_init               (void);
-int             meta_run                (void);
+GOptionContext *meta_get_option_context     (void);
+void            meta_init                   (void);
+int             meta_run                    (void);
+void            meta_register_with_session  (void);
 gboolean        meta_get_replace_current_wm (void);  /* Actually defined in util.c */
 
 void            meta_set_wm_name              (const char *wm_name);


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