Index: src/screen.c
===================================================================
RCS file: /cvs/gnome/metacity/src/screen.c,v
retrieving revision 1.135
diff -u -r1.135 screen.c
--- src/screen.c	20 Jan 2005 16:41:29 -0000	1.135
+++ src/screen.c	17 Feb 2005 13:41:01 -0000
@@ -2201,6 +2201,7 @@
       MetaWindow *w = tmp->data;
 
       if (w->screen == screen)
+        w->showing_desktop_immunity = FALSE;
         meta_window_queue_calc_showing (w);
       
       tmp = tmp->next;
Index: src/window.c
===================================================================
RCS file: /cvs/gnome/metacity/src/window.c,v
retrieving revision 1.377
diff -u -r1.377 window.c
--- src/window.c	12 Feb 2005 07:34:30 -0000	1.377
+++ src/window.c	17 Feb 2005 13:41:02 -0000
@@ -142,37 +142,6 @@
     return TRUE;
 }
 
-/* window is the window that's newly mapped provoking
- * the possible change
- */
-static void
-maybe_leave_show_desktop_mode (MetaWindow *window)
-{
-  gboolean is_desktop_or_dock;
-
-  if (!window->screen->active_workspace->showing_desktop)
-    return;
-
-  /* If the window is a transient for the dock or desktop, don't
-   * leave show desktop mode when the window opens. That's
-   * so you can e.g. hide all windows, manipulate a file on
-   * the desktop via a dialog, then unshow windows again.
-   */
-  is_desktop_or_dock = FALSE;
-  is_desktop_or_dock_foreach (window,
-                              &is_desktop_or_dock);
-
-  meta_window_foreach_ancestor (window, is_desktop_or_dock_foreach,
-                                &is_desktop_or_dock);
-
-  if (!is_desktop_or_dock)
-    {
-      meta_screen_minimize_all_on_active_workspace_except (window->screen,
-                                                           window);
-      meta_screen_unshow_desktop (window->screen);      
-    }
-}
-
 MetaWindow*
 meta_window_new (MetaDisplay *display,
                  Window       xwindow,
@@ -434,6 +403,7 @@
   window->shaded = FALSE;
   window->initially_iconic = FALSE;
   window->minimized = FALSE;
+  window->showing_desktop_immunity = FALSE;
   window->iconic = FALSE;
   window->mapped = attrs->map_state != IsUnmapped;
   /* if already mapped, no need to worry about focus-on-first-time-showing */
@@ -716,8 +686,11 @@
   /* Sync stack changes */
   meta_stack_thaw (window->screen->stack);
 
-  /* disable show desktop mode unless we're a desktop component */
-  maybe_leave_show_desktop_mode (window);
+  /* if we are in "showing desktop" mode then any new windows are immune */
+  if (window->screen->active_workspace->showing_desktop)
+    {
+      window->showing_desktop_immunity = TRUE;
+    }
   
   meta_window_queue_calc_showing (window);
 
@@ -1224,7 +1197,7 @@
 
   if (showing &&      
       workspace_of_window && workspace_of_window->showing_desktop &&
-      !is_desktop_or_dock)
+      !window->showing_desktop_immunity && !is_desktop_or_dock)
     {
       meta_verbose ("We're showing the desktop on the workspace(s) that window %s is on\n",
                     window->desc);
@@ -2225,9 +2198,6 @@
 
   window->net_wm_user_time = timestamp;
 
-  /* disable show desktop mode unless we're a desktop component */
-  maybe_leave_show_desktop_mode (window);
- 
   /* Get window on current workspace */
   if (!meta_window_located_on_workspace (window,
                                          window->screen->active_workspace))
Index: src/window.h
===================================================================
RCS file: /cvs/gnome/metacity/src/window.h,v
retrieving revision 1.114
diff -u -r1.114 window.h
--- src/window.h	11 Feb 2005 19:20:44 -0000	1.114
+++ src/window.h	17 Feb 2005 13:41:02 -0000
@@ -125,6 +125,9 @@
   /* Minimize is the state controlled by the minimize button */
   guint minimized : 1;
 
+  /* Whether the window has earned immunity from showing desktop mode */
+  guint showing_desktop_immunity : 1;
+
   /* Whether the window is mapped; actual server-side state
    * see also unmaps_pending
    */
