Index: src/window.c
===================================================================
RCS file: /cvs/gnome/metacity/src/window.c,v
retrieving revision 1.325
diff -u -r1.325 window.c
--- src/window.c	28 Feb 2004 02:53:55 -0000	1.325
+++ src/window.c	1 Mar 2004 17:36:14 -0000
@@ -1063,7 +1063,13 @@
     g_object_unref (G_OBJECT (window->mini_icon));
 
   meta_icon_cache_free (&window->icon_cache);
-  
+
+  /* Avoid a race condition between the focusing of the mru window and the
+   * mouse entering the window beneath the one closed in sloppy/mouse focus
+   * modes.
+   */  
+  meta_display_increment_focus_sentinel (window->display);
+
   g_free (window->sm_client_id);
   g_free (window->wm_client_machine);
   g_free (window->startup_id);
@@ -1463,7 +1469,8 @@
   /* for all displays used in the queue, set a sentinel property on
    * the root window so that we can ignore EnterNotify events that
    * occur before the window maps occur.  This avoids a race
-   * condition. */
+   * condition.
+   */
   tmp = should_show;
   while (tmp != NULL)
     {
@@ -1477,6 +1484,23 @@
 
       tmp = tmp->next;
     }
+  /* There's also a potential race condition on window minimize.
+   * So we need to avoid that to, in the same manner.  As with the
+   * case above, this race condition is only for sloppy/mouse focus.
+   */
+  tmp = should_hide;
+  while (tmp != NULL)
+    {
+      MetaWindow *window = tmp->data;
+      
+      if (g_slist_find (displays, window->display) == NULL)
+        {
+          displays = g_slist_prepend (displays, window->display);
+          meta_display_increment_focus_sentinel (window->display);
+        }
+
+      tmp = tmp->next;
+    }
 
   g_slist_free (copy);
 
