commit 601751da395ba1bdb9cf013a68cc6c10d67962ac
Author: Behdad Esfahbod <behdad@behdad.org>
Date:   Mon Dec 8 00:11:09 2008 -0500

    Don't connect to session manager until we are ready.
    
    gnome-session takes our connection as "I'm ready, go ahead and start
    the next phase (Nautilus)".  To avoid Nautilus icons jumping around
    when we set struts, we should set the struts before connecting to
    session.

diff --git a/gnome-panel/main.c b/gnome-panel/main.c
index 4792b4d..892e98c 100644
--- a/gnome-panel/main.c
+++ b/gnome-panel/main.c
@@ -50,6 +50,8 @@ main (int argc, char **argv)
 	GOptionContext *context;
 	GnomeProgram   *program;
 
+	panel_session_inhibit ();
+
 	bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
 	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
 	textdomain (GETTEXT_PACKAGE);
@@ -76,10 +78,10 @@ main (int argc, char **argv)
 	gnome_authentication_manager_init ();
 
 	panel_action_protocol_init ();
+
 	panel_multiscreen_init ();
-	panel_init_stock_icons_and_items ();
 
-	panel_session_init ();
+	panel_init_stock_icons_and_items ();
 
 	gconf_client_add_dir (panel_gconf_get_client (),
 			      "/desktop/gnome/interface",
@@ -97,6 +99,12 @@ main (int argc, char **argv)
 
 	xstuff_init ();
 
+	/* flush to make sure our struts are seen by everyone
+	 * starting immediate after (ie. metacity) */
+	gdk_flush ();
+
+	panel_session_init ();
+
 	gtk_main ();
 
 	panel_lockdown_finalize ();
diff --git a/gnome-panel/panel-session.c b/gnome-panel/panel-session.c
index 337ee5c..3802ce9 100644
--- a/gnome-panel/panel-session.c
+++ b/gnome-panel/panel-session.c
@@ -59,18 +59,38 @@ panel_session_do_not_restart (void)
 	gnome_client_set_restart_style (client, GNOME_RESTART_IF_RUNNING);
 }
 
+char *session_manager;
+
+void
+panel_session_inhibit (void)
+{
+	/* Why is the following API deprecated and not working?
+	 * Got to do it the hard way.
+	 *
+	 * gnome_client_disable_master_connection ();
+	 */
+	session_manager = g_strdup (g_getenv ("SESSION_MANAGER"));
+	g_unsetenv ("SESSION_MANAGER");
+}
+
 void
 panel_session_init (void)
 {
 	GnomeClient *client;
 
+	client = gnome_master_client ();
+
+	if (session_manager) {
+		g_setenv ("SESSION_MANAGER", session_manager, TRUE);
+		g_free (session_manager);
+		gnome_client_connect (client);
+	}
+
 	/* We don't want the WM to try and save/restore our
 	 * window position
 	 */
 	gdk_set_sm_client_id (NULL);
 
-	client = gnome_master_client ();
-
         if (!getenv ("GNOME_PANEL_DEBUG"))
                 gnome_client_set_restart_style (client, GNOME_RESTART_IMMEDIATELY);
 
diff --git a/gnome-panel/panel-session.h b/gnome-panel/panel-session.h
index 9b2e480..d4b9ec4 100644
--- a/gnome-panel/panel-session.h
+++ b/gnome-panel/panel-session.h
@@ -27,6 +27,7 @@
 
 G_BEGIN_DECLS
 
+void panel_session_inhibit        (void);
 void panel_session_init           (void);
 void panel_session_do_not_restart (void);
 
