Index: src/window.c
===================================================================
RCS file: /cvs/gnome/metacity/src/window.c,v
retrieving revision 1.242
diff -u -r1.242 window.c
--- src/window.c	4 Nov 2002 00:19:08 -0000	1.242
+++ src/window.c	5 Nov 2002 14:22:54 -0000
@@ -6047,6 +6047,42 @@
       new_x = meta_window_find_nearest_vertical_edge (window, new_x);
       new_y = meta_window_find_nearest_horizontal_edge (window, new_y);
     }
+  else
+    {
+      /* Attract the windows to the edges when they are near them */
+      int edge;
+      MetaFrameGeometry fgeom;
+      MetaRectangle work_area;
+
+      if (window->frame)
+        meta_frame_calc_geometry (window->frame, &fgeom);
+      
+      meta_window_get_work_area (window, TRUE, &work_area);
+
+#define EDGE_ATTRACTION 5
+      
+      /* Left edge */
+      edge = work_area.x + (window->frame ? fgeom.left_width : 0);
+      if (ABS(new_x - edge) < EDGE_ATTRACTION)
+	new_x = edge;
+
+      /* Right edge */
+      edge = (work_area.x + work_area.width) - (window->rect.width + (window->frame ? fgeom.right_width : 0));
+      if (ABS(new_x - edge) < EDGE_ATTRACTION)
+	new_x = edge;
+
+      /* Top edge */
+      edge = work_area.y + (window->frame ? fgeom.top_height : 0);
+      if (ABS(new_y - edge) < EDGE_ATTRACTION)
+	new_y = edge;
+      
+      /* Bottom edge */
+      edge = (work_area.y + work_area.height) - (window->rect.height + (window->frame ? fgeom.bottom_height : 0));
+      if (ABS(new_y - edge) < EDGE_ATTRACTION)
+	new_y = edge;
+#undef EDGE_ATTRACTION
+    }
+      
 
   /* Force a move regardless of time if a certain delta is exceeded,
    * so we don't get too out of sync with reality when dropping frames
