Index: gui/gdmchooser.c
===================================================================
RCS file: /cvs/gnome/gdm2/gui/gdmchooser.c,v
retrieving revision 1.86
diff -u -p -r1.86 gdmchooser.c
--- gui/gdmchooser.c	22 Nov 2005 20:59:36 -0000	1.86
+++ gui/gdmchooser.c	23 Nov 2005 16:27:24 -0000
@@ -150,12 +150,6 @@ static XdmcpBuffer querybuf;
 static GSList *bcaddr;
 static GSList *queryaddr;
 
-enum {
-	GDM_BACKGROUND_NONE = 0,
-	GDM_BACKGROUND_IMAGE = 1,
-	GDM_BACKGROUND_COLOR = 2
-};
-
 static gchar *GdmHosts;
 
 static GladeXML *chooser_app;
@@ -1814,7 +1808,7 @@ gdm_reread_config (int sig, gpointer dat
 	    gdm_config_reload_int    (GDM_KEY_BACKGROUND_TYPE)) {
 
 		if (gdm_config_get_int (GDM_KEY_BACKGROUND_TYPE) != GDM_BACKGROUND_NONE)
-			setup_background_color (gdm_config_get_string (GDM_KEY_BACKGROUND_COLOR));
+			setup_background (FALSE, gdm_wm_screens, gdm_wm_allscreens);
 	}
 
 	return TRUE;
@@ -1977,7 +1971,7 @@ main (int argc, char *argv[])
     /* but just in case */
     if (RUNNING_UNDER_GDM) {
 	if (gdm_config_get_int (GDM_KEY_BACKGROUND_TYPE) != GDM_BACKGROUND_NONE)
-		setup_background_color (gdm_config_get_string (GDM_KEY_BACKGROUND_COLOR));
+		setup_background (FALSE,  gdm_wm_screens, gdm_wm_allscreens);
 
 	gdm_common_setup_cursor (GDK_WATCH);
     }
Index: gui/gdmcommon.c
===================================================================
RCS file: /cvs/gnome/gdm2/gui/gdmcommon.c,v
retrieving revision 1.16
diff -u -p -r1.16 gdmcommon.c
--- gui/gdmcommon.c	23 Nov 2005 01:37:29 -0000	1.16
+++ gui/gdmcommon.c	23 Nov 2005 16:27:24 -0000
@@ -304,7 +304,7 @@ gdm_common_select_time_format (void)
 }
 
 /* Not to look too shaby on Xinerama setups */
-void
+static void
 setup_background_color (gchar *bg_color)
 {
   GdkColormap *colormap;
@@ -376,3 +376,162 @@ gdm_get_welcomemsg (void)
 	return welcomemsg;
 }
 
+static void
+set_root (GdkPixbuf *pb)
+{
+	GdkPixmap *pm;
+	gint width, height;
+
+	g_return_if_fail (pb != NULL);
+
+	gdk_drawable_get_size (gdk_get_default_root_window (), &width, &height);
+	pm = gdk_pixmap_new (gdk_get_default_root_window (), 
+			width, height, -1);
+
+
+	/* paranoia */
+	if (pm == NULL)
+		return;
+
+	gdk_draw_pixbuf (pm, NULL, pb, 0, 0, 0, 0, -1, -1, 
+			GDK_RGB_DITHER_MAX, 0, 0);
+
+	gdk_error_trap_push ();
+
+	gdk_window_set_back_pixmap (gdk_get_default_root_window (),
+				    pm,
+				    FALSE /* parent_relative */);
+
+	g_object_unref (G_OBJECT (pm));
+
+	gdk_window_clear (gdk_get_default_root_window ());
+
+	gdk_flush ();
+	gdk_error_trap_pop ();
+}
+
+static GdkPixbuf *
+render_scaled_back (const GdkPixbuf *pb, int n_screens, GdkRectangle * allscreens)
+{
+	int i;
+	int width, height;
+
+	GdkPixbuf *back = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
+					  gdk_pixbuf_get_has_alpha (pb),
+					  8,
+					  gdk_screen_width (),
+					  gdk_screen_height ());
+
+	width = gdk_pixbuf_get_width (pb);
+	height = gdk_pixbuf_get_height (pb);
+
+	for (i = 0; i < n_screens; i++) {
+		gdk_pixbuf_scale (pb, back,
+				  allscreens[i].x,
+				  allscreens[i].y,
+				  allscreens[i].width,
+				  allscreens[i].height,
+				  allscreens[i].x /* offset_x */,
+				  allscreens[i].y /* offset_y */,
+				  (double) allscreens[i].width / width,
+				  (double) allscreens[i].height / height,
+				  GDK_INTERP_BILINEAR);
+	}
+
+	return back;
+}
+
+static void
+add_color_to_pb (GdkPixbuf *pb, GdkColor *color)
+{
+	int width = gdk_pixbuf_get_width (pb);
+	int height = gdk_pixbuf_get_height (pb);
+	int rowstride = gdk_pixbuf_get_rowstride (pb);
+	guchar *pixels = gdk_pixbuf_get_pixels (pb);
+	gboolean has_alpha = gdk_pixbuf_get_has_alpha (pb);
+	int i;
+	int cr = color->red >> 8;
+	int cg = color->green >> 8;
+	int cb = color->blue >> 8;
+
+	if ( ! has_alpha)
+		return;
+
+	for (i = 0; i < height; i++) {
+		int ii;
+		guchar *p = pixels + (rowstride * i);
+		for (ii = 0; ii < width; ii++) {
+			int r = p[0];
+			int g = p[1];
+			int b = p[2];
+			int a = p[3];
+
+			p[0] = (r * a + cr * (255 - a)) >> 8;
+			p[1] = (g * a + cg * (255 - a)) >> 8;
+			p[2] = (b * a + cb * (255 - a)) >> 8;
+			p[3] = 255;
+
+			p += 4;
+		}
+	}
+}
+
+/* setup background color/image */
+void
+setup_background (gboolean graphical_greeter, int n_screens, GdkRectangle *allscreens)
+{
+	GdkColor color;
+	GdkPixbuf *pb = NULL;
+	gchar *bg_color;	
+	gchar *bg_image = gdm_config_get_string (GDM_KEY_BACKGROUND_IMAGE);
+	gint   bg_type  = gdm_config_get_int    (GDM_KEY_BACKGROUND_TYPE); 
+
+	if (graphical_greeter) {
+		bg_color = gdm_config_get_string (GDM_KEY_GRAPHICAL_THEME_COLOR);
+	  	/* If a graphical theme color does not exist fallback to the plain color */
+		if (ve_string_empty (bg_color)) {
+		    bg_color = gdm_config_get_string (GDM_KEY_BACKGROUND_COLOR);
+		}
+	}
+	else
+		bg_color = gdm_config_get_string (GDM_KEY_BACKGROUND_COLOR);
+
+	if ((bg_type == GDM_BACKGROUND_IMAGE ||
+	     bg_type == GDM_BACKGROUND_IMAGE_AND_COLOR) &&
+	    ! ve_string_empty (bg_image))
+		pb = gdk_pixbuf_new_from_file (bg_image, NULL);
+
+	/* Load background image */
+	if (pb != NULL) {
+		if (gdk_pixbuf_get_has_alpha (pb)) {
+			if (bg_type == GDM_BACKGROUND_IMAGE_AND_COLOR) {
+				if (bg_color == NULL ||
+				    bg_color[0] == '\0' ||
+				    ! gdk_color_parse (bg_color,
+					       &color)) {
+					gdk_color_parse ("#000000", &color);
+				}
+				add_color_to_pb (pb, &color);
+			}
+		}
+		if (gdm_config_get_bool (GDM_KEY_BACKGROUND_SCALE_TO_FIT)) {
+			GdkPixbuf *spb = render_scaled_back (pb, n_screens, allscreens);
+			g_object_unref (G_OBJECT (pb));
+			pb = spb;
+		}
+
+		/* paranoia */
+		if (pb != NULL) {
+			set_root (pb);
+			g_object_unref (G_OBJECT (pb));
+		}
+	/* Load background color */
+	} else if (bg_type != GDM_BACKGROUND_NONE &&
+	           bg_type != GDM_BACKGROUND_IMAGE) {
+		setup_background_color (bg_color);
+	/* Load default background */
+	} else {
+		gchar *blank_color = g_strdup ("#000000");
+		setup_background_color (blank_color);
+	}
+}
Index: gui/gdmcommon.h
===================================================================
RCS file: /cvs/gnome/gdm2/gui/gdmcommon.h,v
retrieving revision 1.12
diff -u -p -r1.12 gdmcommon.h
--- gui/gdmcommon.h	22 Nov 2005 07:48:46 -0000	1.12
+++ gui/gdmcommon.h	23 Nov 2005 16:27:24 -0000
@@ -54,7 +54,15 @@ GdkPixbuf *gdm_common_get_face          
                                          guint       max_height);
 gchar*	gdm_common_get_config_file	(void);
 gboolean gdm_common_select_time_format	(void);
-void	setup_background_color		(gchar *bg_color);
 gchar*	gdm_get_welcomemsg		(void);
+
+enum {
+	GDM_BACKGROUND_NONE = 0,
+	GDM_BACKGROUND_IMAGE_AND_COLOR = 1,
+	GDM_BACKGROUND_COLOR = 2,
+	GDM_BACKGROUND_IMAGE = 3
+};
+
+void setup_background (gboolean graphical_greeter, int n_screens, GdkRectangle *allscreens);
 
 #endif /* GDM_COMMON_H */
Index: gui/gdmlogin.c
===================================================================
RCS file: /cvs/gnome/gdm2/gui/gdmlogin.c,v
retrieving revision 1.256
diff -u -p -r1.256 gdmlogin.c
--- gui/gdmlogin.c	22 Nov 2005 20:30:35 -0000	1.256
+++ gui/gdmlogin.c	23 Nov 2005 16:27:24 -0000
@@ -84,13 +84,6 @@ enum {
 	GREETER_ULIST_LOGIN_COLUMN
 };
 
-enum {
-	GDM_BACKGROUND_NONE = 0,
-	GDM_BACKGROUND_IMAGE_AND_COLOR = 1,
-	GDM_BACKGROUND_COLOR = 2,
-	GDM_BACKGROUND_IMAGE = 3,
-};
-
 static GtkWidget *login;
 static GtkWidget *logo_frame = NULL;
 static GtkWidget *logo_image = NULL;
@@ -3012,156 +3004,6 @@ gdm_login_gui_init (void)
     }
 }
 
-static void
-set_root (GdkPixbuf *pb)
-{
-	GdkPixmap *pm;
-	gint width, height;
-
-	g_return_if_fail (pb != NULL);
-
-	gdk_drawable_get_size (gdk_get_default_root_window (), &width, &height);
-	pm = gdk_pixmap_new (gdk_get_default_root_window (), 
-			width, height, -1);
-
-
-	/* paranoia */
-	if (pm == NULL)
-		return;
-
-	gdk_draw_pixbuf (pm, NULL, pb, 0, 0, 0, 0, -1, -1, 
-			GDK_RGB_DITHER_MAX, 0, 0);
-
-	gdk_error_trap_push ();
-
-	gdk_window_set_back_pixmap (gdk_get_default_root_window (),
-				    pm,
-				    FALSE /* parent_relative */);
-
-	g_object_unref (G_OBJECT (pm));
-
-	gdk_window_clear (gdk_get_default_root_window ());
-
-	gdk_flush ();
-	gdk_error_trap_pop ();
-}
-
-static GdkPixbuf *
-render_scaled_back (const GdkPixbuf *pb)
-{
-	int i;
-	int width, height;
-
-	GdkPixbuf *back = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
-					  gdk_pixbuf_get_has_alpha (pb),
-					  8,
-					  gdk_screen_width (),
-					  gdk_screen_height ());
-
-	width = gdk_pixbuf_get_width (pb);
-	height = gdk_pixbuf_get_height (pb);
-
-	for (i = 0; i < gdm_wm_screens; i++) {
-		gdk_pixbuf_scale (pb, back,
-				  gdm_wm_allscreens[i].x,
-				  gdm_wm_allscreens[i].y,
-				  gdm_wm_allscreens[i].width,
-				  gdm_wm_allscreens[i].height,
-				  gdm_wm_allscreens[i].x /* offset_x */,
-				  gdm_wm_allscreens[i].y /* offset_y */,
-				  (double) gdm_wm_allscreens[i].width / width,
-				  (double) gdm_wm_allscreens[i].height / height,
-				  GDK_INTERP_BILINEAR);
-	}
-
-	return back;
-}
-
-static void
-add_color_to_pb (GdkPixbuf *pb, GdkColor *color)
-{
-	int width = gdk_pixbuf_get_width (pb);
-	int height = gdk_pixbuf_get_height (pb);
-	int rowstride = gdk_pixbuf_get_rowstride (pb);
-	guchar *pixels = gdk_pixbuf_get_pixels (pb);
-	gboolean has_alpha = gdk_pixbuf_get_has_alpha (pb);
-	int i;
-	int cr = color->red >> 8;
-	int cg = color->green >> 8;
-	int cb = color->blue >> 8;
-
-	if ( ! has_alpha)
-		return;
-
-	for (i = 0; i < height; i++) {
-		int ii;
-		guchar *p = pixels + (rowstride * i);
-		for (ii = 0; ii < width; ii++) {
-			int r = p[0];
-			int g = p[1];
-			int b = p[2];
-			int a = p[3];
-
-			p[0] = (r * a + cr * (255 - a)) >> 8;
-			p[1] = (g * a + cg * (255 - a)) >> 8;
-			p[2] = (b * a + cb * (255 - a)) >> 8;
-			p[3] = 255;
-
-			p += 4;
-		}
-	}
-}
-
-/* setup background color/image */
-static void
-setup_background (void)
-{
-	GdkColor color;
-	GdkPixbuf *pb = NULL;
-	gchar *bg_color = gdm_config_get_string (GDM_KEY_BACKGROUND_COLOR);
-	gchar *bg_image = gdm_config_get_string (GDM_KEY_BACKGROUND_IMAGE);
-	gint   bg_type  = gdm_config_get_int    (GDM_KEY_BACKGROUND_TYPE); 
-
-	if ((bg_type == GDM_BACKGROUND_IMAGE ||
-	     bg_type == GDM_BACKGROUND_IMAGE_AND_COLOR) &&
-	    ! ve_string_empty (bg_image))
-		pb = gdk_pixbuf_new_from_file (bg_image, NULL);
-
-	/* Load background image */
-	if (pb != NULL) {
-		if (gdk_pixbuf_get_has_alpha (pb)) {
-			if (bg_type == GDM_BACKGROUND_IMAGE_AND_COLOR) {
-				if (bg_color == NULL ||
-				    bg_color[0] == '\0' ||
-				    ! gdk_color_parse (bg_color,
-					       &color)) {
-					gdk_color_parse ("#000000", &color);
-				}
-				add_color_to_pb (pb, &color);
-			}
-		}
-		if (gdm_config_get_bool (GDM_KEY_BACKGROUND_SCALE_TO_FIT)) {
-			GdkPixbuf *spb = render_scaled_back (pb);
-			g_object_unref (G_OBJECT (pb));
-			pb = spb;
-		}
-
-		/* paranoia */
-		if (pb != NULL) {
-			set_root (pb);
-			g_object_unref (G_OBJECT (pb));
-		}
-	/* Load background color */
-	} else if (bg_type != GDM_BACKGROUND_NONE &&
-	           bg_type != GDM_BACKGROUND_IMAGE) {
-		setup_background_color (bg_color);
-	/* Load default background */
-	} else {
-		gchar *blank_color = g_strdup ("#000000");
-		setup_background_color (blank_color);
-	}
-}
-
 enum {
 	RESPONSE_RESTART,
 	RESPONSE_REBOOT,
@@ -3223,7 +3065,7 @@ else
 	    gdm_config_reload_bool   (GDM_KEY_BACKGROUND_REMOTE_ONLY_COLOR)) {
 
 		gdm_kill_thingies ();
-		setup_background ();
+		setup_background (FALSE, gdm_wm_screens, gdm_wm_allscreens);
 		back_prog_launch_after_timeout ();
 	}
 
@@ -3332,7 +3174,7 @@ main (int argc, char *argv[])
     /* Load the background as early as possible so GDM does not leave  */
     /* the background unfilled.   The cursor should be a watch already */
     /* but just in case */
-    setup_background ();
+    setup_background (FALSE, gdm_wm_screens, gdm_wm_allscreens);
     gdm_common_setup_cursor (GDK_WATCH);
 
     if ( ! DOING_GDM_DEVELOPMENT &&
Index: gui/greeter/greeter.c
===================================================================
RCS file: /cvs/gnome/gdm2/gui/greeter/greeter.c,v
retrieving revision 1.103
diff -u -p -r1.103 greeter.c
--- gui/greeter/greeter.c	22 Nov 2005 07:49:43 -0000	1.103
+++ gui/greeter/greeter.c	23 Nov 2005 16:27:24 -0000
@@ -920,14 +920,12 @@ gdm_event (GSignalInvocationHint *ihint,
 int
 main (int argc, char *argv[])
 {
-  char *bg_color;
   struct sigaction hup;
   struct sigaction term;
   sigset_t mask;
   GIOChannel *ctrlch;
   GError *error;
   GreeterItemInfo *root;
-  const gchar *theme_name;
   char *theme_file;
   char *theme_dir;
   gchar *gdm_graphical_theme;
@@ -976,12 +974,8 @@ main (int argc, char *argv[])
   /* Load the background as early as possible so GDM does not leave  */
   /* the background unfilled.   The cursor should be a watch already */
   /* but just in case */
-  bg_color = gdm_config_get_string (GDM_KEY_GRAPHICAL_THEME_COLOR);
-  /* If a graphical theme color does not exist fallback to the plain color */
-  if (ve_string_empty (bg_color)) {
-    bg_color = gdm_config_get_string (GDM_KEY_BACKGROUND_COLOR);
-  }
-  setup_background_color (bg_color);
+  
+  setup_background (TRUE, gdm_wm_screens, gdm_wm_allscreens);
   greeter_session_init ();
 
   ve_signal_add (SIGHUP, greeter_reread_config, NULL);
