Index: libnautilus-private/nautilus-icon-container.c
===================================================================
--- libnautilus-private/nautilus-icon-container.c	(Revision 14632)
+++ libnautilus-private/nautilus-icon-container.c	(Arbeitskopie)
@@ -307,6 +307,56 @@ icon_is_positioned (const NautilusIcon *
 	return icon->x != ICON_UNPOSITIONED_VALUE && icon->y != ICON_UNPOSITIONED_VALUE;
 }
 
+static void
+get_canvas_size_for_monitor (NautilusIconContainer *container,
+			     int monitor,
+			     int *x,
+			     int *y,
+			     int *width,
+			     int *height)
+{
+	GdkScreen *screen;
+	GdkRectangle monitor_geometry;
+	double pixels_per_unit;	
+	int container_x, container_y, container_width, container_height;
+	int screen_width, screen_height;
+
+	pixels_per_unit = EEL_CANVAS (container)->pixels_per_unit;
+
+	screen = gtk_widget_get_screen (GTK_WIDGET (container));
+	screen_width = gdk_screen_get_width (screen);
+	screen_height = gdk_screen_get_height (screen);
+
+	gdk_screen_get_monitor_geometry (screen, monitor, &monitor_geometry);
+
+	container_x = MAX (monitor_geometry.x - container->details->left_margin, 0);
+	container_y = MAX (monitor_geometry.y - container->details->top_margin, 0);
+
+	container_width = monitor_geometry.width;
+	container_width -= MAX (container->details->left_margin - monitor_geometry.x, 0);
+	container_width -= MAX (container->details->right_margin - (screen_width - (monitor_geometry.x + monitor_geometry.width)), 0);
+
+	container_height = monitor_geometry.height;
+	container_height -= MAX (container->details->top_margin - monitor_geometry.y, 0);
+	container_height -= MAX (container->details->bottom_margin - (screen_height - (monitor_geometry.y + monitor_geometry.height)), 0);
+
+	if (x != NULL) {
+		*x = container_x / pixels_per_unit;
+	}
+
+	if (y != NULL) {
+		*y = container_y / pixels_per_unit;
+	}
+
+	if (width != NULL) {
+		*width = container_width / pixels_per_unit;
+	}
+
+	if (height != NULL) {
+		*height = container_height / pixels_per_unit;
+	}
+}
+
 
 /* x, y are the top-left coordinates of the icon. */
 static void
@@ -314,11 +364,13 @@ icon_set_position (NautilusIcon *icon,
 		   double x, double y)
 {	
 	NautilusIconContainer *container;
+	GdkScreen *screen;
 	double pixels_per_unit;	
-	int container_left, container_top, container_right, container_bottom;
 	int x1, x2, y1, y2;
-	int container_x, container_y, container_width, container_height;
+	int container_left, container_right, container_top, container_bottom;
+	int container_width, container_height;
 	EelDRect icon_bounds;
+	int monitor;
 	int item_width, item_height;
 	int height_above, height_below, width_left, width_right;
 	int min_x, max_x, min_y, max_y;
@@ -334,33 +386,21 @@ icon_set_position (NautilusIcon *icon,
 	}
 
 	if (nautilus_icon_container_get_is_fixed_size (container)) {
-		/*  FIXME: This should be:
-		    
-		container_x = GTK_WIDGET (container)->allocation.x;
-		container_y = GTK_WIDGET (container)->allocation.y;
-		container_width = GTK_WIDGET (container)->allocation.width;
-		container_height = GTK_WIDGET (container)->allocation.height;
-
-		But for some reason the widget allocation is sometimes not done
-		at startup, and the allocation is then only 45x60. which is
-		really bad.
-
-		For now, we have a cheesy workaround:
-		*/
-		container_x = 0;
-		container_y = 0;
-		container_width = gdk_screen_width () - container_x
-			- container->details->left_margin
-			- container->details->right_margin;
-		container_height = gdk_screen_height () - container_y
-			- container->details->top_margin
-			- container->details->bottom_margin;
-		pixels_per_unit = EEL_CANVAS (container)->pixels_per_unit;
 		/* Clip the position of the icon within our desktop bounds */
-		container_left = container_x / pixels_per_unit;
-		container_top =  container_y / pixels_per_unit;
-		container_right = container_left + container_width / pixels_per_unit;
-		container_bottom = container_top + container_height / pixels_per_unit;
+		pixels_per_unit = EEL_CANVAS (container)->pixels_per_unit;
+
+		screen = gtk_widget_get_screen (GTK_WIDGET (container));
+
+		monitor = gdk_screen_get_monitor_at_point (screen,
+							   x * pixels_per_unit,n+							   y * pixels_per_unit);
+
+		get_canvas_size_for_monitor (container, monitor,
+					     &container_left, &container_top,
+					     &container_width, &container_height);
+
+		container_right = container_left + container_width;
+		container_bottom = container_top + container_height;
 
 		icon_get_bounding_box (icon, &x1, &y1, &x2, &y2,
 				       BOUNDS_USAGE_FOR_ENTIRE_ITEM);
