Index: constraints.c
===================================================================
RCS file: /cvs/gnome/metacity/src/constraints.c,v
retrieving revision 1.6
diff -p -u -r1.6 constraints.c
--- constraints.c	12 Mar 2003 03:56:01 -0000	1.6
+++ constraints.c	12 Mar 2003 04:48:05 -0000
@@ -1020,12 +1020,14 @@ update_position_limits (MetaWindow      
   int nw_x, nw_y;
   int se_x, se_y;
 
-  nw_x = info->work_area_screen.x;
-  nw_y = info->work_area_screen.y;
+  nw_x = MIN(info->work_area_xinerama.x, info->work_area_screen.x);
+  nw_y = MIN(info->work_area_xinerama.y, info->work_area_screen.y);
 
   /* find bottom-right corner of workarea */
-  se_x = info->work_area_screen.x + info->work_area_screen.width;
-  se_y = info->work_area_screen.y + info->work_area_screen.height;
+  se_x = MAX(info->work_area_xinerama.x + info->work_area_xinerama.width,
+	     info->work_area_screen.x + info->work_area_screen.width);
+  se_y = MAX(info->work_area_xinerama.y + info->work_area_xinerama.height,
+	     info->work_area_screen.y + info->work_area_screen.height);
 
   /* If we have a micro-screen or huge frames maybe nw/se got
    * swapped
@@ -1093,13 +1095,16 @@ meta_window_constrain (MetaWindow       
       info.fgeom.right_width = 0;
     }
 
-  meta_window_get_work_area_current_xinerama (window, &info.work_area_xinerama);
-  meta_window_get_work_area_all_xineramas (window, &info.work_area_screen);
-
   info.window = window;
   info.xinerama = meta_screen_get_xinerama_for_window (window->screen,
                                                        window);
 
+  meta_window_get_work_area_for_xinerama (window,
+                                          info.xinerama->number,
+                                          &info.work_area_xinerama);
+  meta_window_get_work_area_all_xineramas (window, &info.work_area_screen);
+
+
   /* Init info->nw_x etc. */
   update_position_limits (window, &info);
 
@@ -1116,14 +1121,22 @@ meta_window_constrain (MetaWindow       
       !window->maximized &&
       !window->fullscreen)
     {
-      int x, y;
-
+      MetaRectangle placed_rect = current;
+      
       meta_window_place (window, orig_fgeom, current.x, current.y,
-                         &x, &y);
+                         &placed_rect.x, &placed_rect.y);
+
+      /* xinerama may have changed, so update xinerama information */
+      info.xinerama = meta_screen_get_xinerama_for_rect (window->screen,
+							 &placed_rect);
+      meta_window_get_work_area_for_xinerama (window,
+                                              info.xinerama->number,
+                                              &info.work_area_xinerama);
+      update_position_limits (window, &info);
 
       constrain_move (window, &info, &current,
-                      x - current.x,
-                      y - current.y,
+                      placed_rect.x - current.x,
+                      placed_rect.y - current.y,
                       new);
       current = *new;
 
