Index: src/keybindings.c
===================================================================
RCS file: /cvs/gnome/metacity/src/keybindings.c,v
retrieving revision 1.98
diff -p -u -r1.98 keybindings.c
--- src/keybindings.c	24 Jun 2004 20:47:31 -0000	1.98
+++ src/keybindings.c	6 Aug 2004 23:15:59 -0000
@@ -2753,7 +2753,7 @@ handle_toggle_desktop (MetaDisplay    *d
                        XEvent         *event,
                        MetaKeyBinding *binding)
 {
-  if (screen->showing_desktop)
+  if (meta_screen_showing_desktop_on_current_workspace (screen))
     {
       meta_screen_unshow_desktop (screen);
       meta_workspace_focus_default_window (screen->active_workspace, NULL);
Index: src/screen.c
===================================================================
RCS file: /cvs/gnome/metacity/src/screen.c,v
retrieving revision 1.126
diff -p -u -r1.126 screen.c
--- src/screen.c	31 Jul 2004 19:56:10 -0000	1.126
+++ src/screen.c	6 Aug 2004 23:15:59 -0000
@@ -534,13 +534,12 @@ meta_screen_new (MetaDisplay *display,
 
   screen->active_workspace = NULL;
   screen->workspaces = NULL;
+  screen->show_desktop_workspaces = NULL;
   screen->rows_of_workspaces = 1;
   screen->columns_of_workspaces = -1;
   screen->vertical_workspaces = FALSE;
   screen->starting_corner = META_SCREEN_TOPLEFT;
 
-  screen->showing_desktop = FALSE;
-
   screen->compositor_windows = NULL;
   screen->damage_region = None;
   screen->root_picture = None;
@@ -2165,12 +2164,12 @@ meta_screen_resize (MetaScreen *screen,
   meta_screen_foreach_window (screen, meta_screen_resize_func, 0);
 }
 
-static void
-update_showing_desktop_hint (MetaScreen *screen)
+void
+meta_screen_update_showing_desktop_hint (MetaScreen *screen)
 {
   unsigned long data[1];
 
-  data[0] = screen->showing_desktop ? 1 : 0;  
+  data[0] = meta_screen_showing_desktop_on_current_workspace (screen) ? 1 : 0;
       
   meta_error_trap_push (screen->display);
   XChangeProperty (screen->display->xdisplay, screen->xroot,
@@ -2183,10 +2182,10 @@ update_showing_desktop_hint (MetaScreen 
 static void
 queue_windows_showing (MetaScreen *screen)
 {
-  GSList *windows;
-  GSList *tmp;
+  GList *windows;
+  GList *tmp;
 
-  windows = meta_display_list_windows (screen->display);
+  windows = screen->active_workspace->windows;
 
   tmp = windows;
   while (tmp != NULL)
@@ -2198,18 +2197,16 @@ queue_windows_showing (MetaScreen *scree
       
       tmp = tmp->next;
     }
-
-  g_slist_free (windows);
 }
 
 void
-meta_screen_minimize_all_except (MetaScreen *screen,
-                                 MetaWindow *keep)
+meta_screen_minimize_all_on_active_workspace_except (MetaScreen *screen,
+                                                     MetaWindow *keep)
 {
-  GSList *windows;
-  GSList *tmp;
-  
-  windows = meta_display_list_windows (screen->display);
+  GList *windows;
+  GList *tmp;
+
+  windows = screen->active_workspace->windows;
   
   tmp = windows;
   while (tmp != NULL)
@@ -2223,21 +2220,20 @@ meta_screen_minimize_all_except (MetaScr
       
       tmp = tmp->next;
     }
-  
-  g_slist_free (windows);
 }
 
 void
 meta_screen_show_desktop (MetaScreen *screen)
 {
-  if (screen->showing_desktop)
+  if (meta_screen_showing_desktop_on_current_workspace (screen))
     return;
 
-  screen->showing_desktop = TRUE;
+  screen->show_desktop_workspaces =
+    g_slist_prepend (screen->show_desktop_workspaces, screen->active_workspace);
 
   queue_windows_showing (screen);
 
-  update_showing_desktop_hint (screen);
+  meta_screen_update_showing_desktop_hint (screen);
 
   meta_workspace_focus_top_window (screen->active_workspace, NULL);
 }
@@ -2245,15 +2241,30 @@ meta_screen_show_desktop (MetaScreen *sc
 void
 meta_screen_unshow_desktop (MetaScreen *screen)
 {
-  if (!screen->showing_desktop)
+  if (!meta_screen_showing_desktop_on_current_workspace (screen))
     return;
 
-  screen->showing_desktop = FALSE;
-  
+  screen->show_desktop_workspaces =
+    g_slist_remove (screen->show_desktop_workspaces, screen->active_workspace);
+
   queue_windows_showing (screen);
 
-  update_showing_desktop_hint (screen);
+  meta_screen_update_showing_desktop_hint (screen);
+}
+
+gboolean
+meta_screen_showing_desktop_for (MetaScreen *screen, 
+                                 MetaWorkspace *workspace)
+{
+  return g_slist_find (screen->show_desktop_workspaces, workspace) != NULL;
 }
+
+gboolean
+meta_screen_showing_desktop_on_current_workspace (MetaScreen *screen)
+{
+  return meta_screen_showing_desktop_for (screen, screen->active_workspace);
+}
+
 
 #ifdef HAVE_STARTUP_NOTIFICATION
 static gboolean startup_sequence_timeout (void *data);
Index: src/screen.h
===================================================================
RCS file: /cvs/gnome/metacity/src/screen.h,v
retrieving revision 1.57
diff -p -u -r1.57 screen.h
--- src/screen.h	24 Jun 2004 20:02:46 -0000	1.57
+++ src/screen.h	6 Aug 2004 23:15:59 -0000
@@ -76,7 +76,8 @@ struct _MetaScreen
   MetaWorkspace *active_workspace;
 
   GList *workspaces;
-  
+  GSList *show_desktop_workspaces;
+
   MetaStack *stack;
 
   MetaCursor current_cursor;
@@ -108,7 +109,6 @@ struct _MetaScreen
   
   guint keys_grabbed : 1;
   guint all_keys_grabbed : 1;
-  guint showing_desktop : 1;
   
   int closing;
 
@@ -197,12 +197,18 @@ void meta_screen_resize (MetaScreen *scr
                          int         width,
                          int         height);
 
-void     meta_screen_minimize_all_except (MetaScreen *screen,
-                                          MetaWindow *keep);
+void     meta_screen_minimize_all_on_active_workspace_except (MetaScreen *screen,
+                                                              MetaWindow *keep);
 
 /* Show/hide the desktop (temporarily hide all windows) */
 void     meta_screen_show_desktop        (MetaScreen *screen);
 void     meta_screen_unshow_desktop      (MetaScreen *screen);
+
+/* Whether or not the destkop is being shown for the current active_workspace */
+gboolean meta_screen_showing_desktop_for (MetaScreen *screen, 
+                                          MetaWorkspace *workspace);
+gboolean meta_screen_showing_desktop_on_current_workspace (MetaScreen *screen);
+void     meta_screen_update_showing_desktop_hint          (MetaScreen *screen);
 
 void     meta_screen_apply_startup_properties (MetaScreen *screen,
                                                MetaWindow *window);
Index: src/window.c
===================================================================
RCS file: /cvs/gnome/metacity/src/window.c,v
retrieving revision 1.335
diff -p -u -r1.335 window.c
--- src/window.c	5 Aug 2004 17:48:39 -0000	1.335
+++ src/window.c	6 Aug 2004 23:15:59 -0000
@@ -158,7 +158,7 @@ maybe_leave_show_desktop_mode (MetaWindo
 {
   gboolean is_desktop_or_dock;
 
-  if (!window->screen->showing_desktop)
+  if (!meta_screen_showing_desktop_on_current_workspace (window->screen))
     return;
 
   /* If the window is a transient for the dock or desktop, don't
@@ -175,7 +175,8 @@ maybe_leave_show_desktop_mode (MetaWindo
 
   if (!is_desktop_or_dock)
     {
-      meta_screen_minimize_all_except (window->screen, window);
+      meta_screen_minimize_all_on_active_workspace_except (window->screen,
+                                                           window);
       meta_screen_unshow_desktop (window->screen);      
     }
 }
@@ -1270,7 +1271,7 @@ window_should_be_showing (MetaWindow  *w
                                 &is_desktop_or_dock);
 
   if (showing &&      
-      window->screen->showing_desktop &&
+      meta_screen_showing_desktop_on_current_workspace (window->screen) &&
       !is_desktop_or_dock)
     {
       meta_verbose ("Window %s is on current workspace, but we're showing the desktop\n",
Index: src/workspace.c
===================================================================
RCS file: /cvs/gnome/metacity/src/workspace.c,v
retrieving revision 1.59
diff -p -u -r1.59 workspace.c
--- src/workspace.c	6 Aug 2004 18:13:55 -0000	1.59
+++ src/workspace.c	6 Aug 2004 23:15:59 -0000
@@ -276,6 +276,16 @@ meta_workspace_activate_with_focus (Meta
 
   set_active_space_hint (workspace->screen);
 
+  /* If the "show desktop" mode is active for either the old workspace
+   * or the new one *but not both*, then update the
+   * _net_showing_desktop hint
+   */
+  if (meta_screen_showing_desktop_for (workspace->screen, old) ^
+      meta_screen_showing_desktop_for (workspace->screen, workspace))
+    {
+      meta_screen_update_showing_desktop_hint (workspace->screen);
+    }
+
   if (old == NULL)
     return;
 
