Index: metacity/ChangeLog
===================================================================
RCS file: /export/cvs/head/metacity/ChangeLog,v
retrieving revision 1.982
diff -p -u -5 -r1.982 ChangeLog
--- metacity/ChangeLog	9 Feb 2005 16:07:56 -0000	1.982
+++ metacity/ChangeLog	11 Feb 2005 09:43:52 -0000
@@ -1,5 +1,11 @@
+2005-02-11 Leena Gunda  <leena.gunda@wipro.com>
+
+	* src/constraints.c: (get_outermost_onscreen_positions),
+	(constraint_onscreen_move_func): When placing a new window, 
+	constrain it within the strut/screen area. Fixes bug #156699.
+
 2005-02-08  Aidan Delaney  <adelaney@cs.may.ie>
 
 	Removed useless function call.  #166730
 
 	* src/tabpopup.c: (outline_window_expose): Removed unused
Index: metacity/src/constraints.c
===================================================================
RCS file: /export/cvs/head/metacity/src/constraints.c,v
retrieving revision 1.21
diff -p -u -5 -r1.21 constraints.c
--- metacity/src/constraints.c	23 Feb 2004 01:48:29 -0000	1.21
+++ metacity/src/constraints.c	11 Feb 2005 09:43:53 -0000
@@ -400,13 +400,17 @@ get_outermost_onscreen_positions (MetaWi
               stmp = stmp->next;
             }
           
           tmp = tmp->next;
         }
-      
-      *leftmost_x_p = *leftmost_x_p - current.width + 
-        MIN (TITLEBAR_LENGTH_ONSCREEN, current.width);
+    
+      if (window->placed || 
+          (!window->placed && !window->calc_placement))
+        { 
+          *leftmost_x_p = *leftmost_x_p - current.width + 
+            MIN (TITLEBAR_LENGTH_ONSCREEN, current.width);
+        }
     }
   
   tmp = workspaces;
   if (rightmost_x_p)
     {
@@ -431,13 +435,17 @@ get_outermost_onscreen_positions (MetaWi
               stmp = stmp->next;
             }
           
           tmp = tmp->next;
         }
-      
-      *rightmost_x_p = *rightmost_x_p - 
-        MIN (TITLEBAR_LENGTH_ONSCREEN, current.width);
+     
+      if (window->placed ||
+          (!window->placed && !window->calc_placement))
+        { 
+          *rightmost_x_p = *rightmost_x_p - 
+            MIN (TITLEBAR_LENGTH_ONSCREEN, current.width);
+        }
     }
 
   tmp = workspaces;
   if (topmost_y_p)
     {
@@ -630,11 +638,15 @@ constraint_onscreen_move_func    (MetaWi
   get_outermost_onscreen_positions (window, info, orig, *x_delta, *y_delta,
                                     &leftmost_x, &rightmost_x,
                                     &topmost_y, &bottommost_y);
 
   min_delta = topmost_y - orig->y;
-  max_delta = bottommost_y - orig->y;
+
+  if (!window->placed && window->calc_placement)
+    max_delta = bottommost_y - orig->y - orig->height;
+  else
+    max_delta = bottommost_y - orig->y;
 
   /* Note that min delta (top left) has priority over
    * max delta (bottom right) to facilitate keeping
    * titlebar on the screen
    */
@@ -642,11 +654,15 @@ constraint_onscreen_move_func    (MetaWi
     *y_delta = max_delta;
   if (*y_delta < min_delta)
     *y_delta = min_delta;
 
   min_delta = leftmost_x - orig->x;
-  max_delta = rightmost_x - orig->x;
+
+  if (!window->placed && window->calc_placement)
+    max_delta = rightmost_x - orig->x - orig->width;
+  else
+    max_delta = rightmost_x - orig->x;
 
   if (*x_delta > max_delta)
     *x_delta = max_delta;
   if (*x_delta < min_delta)
     *x_delta = min_delta;
