Index: src/keybindings.c
===================================================================
RCS file: /cvs/gnome/metacity/src/keybindings.c,v
retrieving revision 1.105
diff -p -u -r1.105 keybindings.c
--- src/keybindings.c	15 Oct 2004 22:43:52 -0000	1.105
+++ src/keybindings.c	16 Oct 2004 18:31:49 -0000
@@ -2805,7 +2805,7 @@ handle_toggle_desktop (MetaDisplay    *d
                        XEvent         *event,
                        MetaKeyBinding *binding)
 {
-  if (screen->showing_desktop)
+  if (screen->active_workspace->showing_desktop)
     {
       meta_screen_unshow_desktop (screen);
       meta_workspace_focus_default_window (screen->active_workspace, 
Index: src/screen.c
===================================================================
RCS file: /cvs/gnome/metacity/src/screen.c,v
retrieving revision 1.130
diff -p -u -r1.130 screen.c
--- src/screen.c	4 Oct 2004 20:32:59 -0000	1.130
+++ src/screen.c	16 Oct 2004 18:31:49 -0000
@@ -539,8 +539,6 @@ meta_screen_new (MetaDisplay *display,
   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;
@@ -2166,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] = screen->active_workspace->showing_desktop ? 1 : 0;
       
   meta_error_trap_push (screen->display);
   XChangeProperty (screen->display->xdisplay, screen->xroot,
@@ -2184,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)
@@ -2199,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)
@@ -2224,35 +2220,34 @@ 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 (screen->active_workspace->showing_desktop)
     return;
-
-  screen->showing_desktop = TRUE;
-
+  
+  screen->active_workspace->showing_desktop = TRUE;
+  
   queue_windows_showing (screen);
-
-  update_showing_desktop_hint (screen);
+  
+  meta_screen_update_showing_desktop_hint (screen);
 }
 
 void
 meta_screen_unshow_desktop (MetaScreen *screen)
 {
-  if (!screen->showing_desktop)
+  if (!screen->active_workspace->showing_desktop)
     return;
 
-  screen->showing_desktop = FALSE;
-  
+  screen->active_workspace->showing_desktop = FALSE;
+
   queue_windows_showing (screen);
 
-  update_showing_desktop_hint (screen);
+  meta_screen_update_showing_desktop_hint (screen);
 }
+
 
 #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	16 Oct 2004 18:31:49 -0000
@@ -76,7 +76,7 @@ struct _MetaScreen
   MetaWorkspace *active_workspace;
 
   GList *workspaces;
-  
+
   MetaStack *stack;
 
   MetaCursor current_cursor;
@@ -108,7 +108,6 @@ struct _MetaScreen
   
   guint keys_grabbed : 1;
   guint all_keys_grabbed : 1;
-  guint showing_desktop : 1;
   
   int closing;
 
@@ -197,12 +196,15 @@ 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);
+
+/* Update whether the destkop is being shown for the current active_workspace */
+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.349
diff -p -u -r1.349 window.c
--- src/window.c	13 Oct 2004 18:54:46 -0000	1.349
+++ src/window.c	16 Oct 2004 18:31:49 -0000
@@ -158,7 +158,7 @@ maybe_leave_show_desktop_mode (MetaWindo
 {
   gboolean is_desktop_or_dock;
 
-  if (!window->screen->showing_desktop)
+  if (!window->screen->active_workspace->showing_desktop)
     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);      
     }
 }
@@ -1265,7 +1266,7 @@ window_should_be_showing (MetaWindow  *w
                                 &is_desktop_or_dock);
 
   if (showing &&      
-      window->screen->showing_desktop &&
+      window->screen->active_workspace->showing_desktop &&
       !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.65
diff -p -u -r1.65 workspace.c
--- src/workspace.c	4 Oct 2004 21:09:08 -0000	1.65
+++ src/workspace.c	16 Oct 2004 18:31:49 -0000
@@ -67,6 +67,8 @@ meta_workspace_new (MetaScreen *screen)
   workspace->right_struts = NULL;
   workspace->top_struts = NULL;
   workspace->bottom_struts = NULL;
+
+  workspace->showing_desktop = FALSE;
   
   return workspace;
 }
@@ -283,11 +285,19 @@ meta_workspace_activate_with_focus (Meta
   if (workspace->screen->active_workspace == workspace)
     return;
 
+  /* Note that old can be NULL; e.g. when starting up */
   old = workspace->screen->active_workspace;
   
   workspace->screen->active_workspace = workspace;
 
   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 (old && old->showing_desktop ^ workspace->showing_desktop)
+    meta_screen_update_showing_desktop_hint (workspace->screen);
 
   if (old == NULL)
     return;
Index: src/workspace.h
===================================================================
RCS file: /cvs/gnome/metacity/src/workspace.h,v
retrieving revision 1.19
diff -p -u -r1.19 workspace.h
--- src/workspace.h	4 Oct 2004 20:32:59 -0000	1.19
+++ src/workspace.h	16 Oct 2004 18:31:49 -0000
@@ -49,6 +49,8 @@ struct _MetaWorkspace
   GSList *top_struts;
   GSList *bottom_struts;
   guint work_areas_invalid : 1;
+
+  guint showing_desktop : 1;
 };
 
 MetaWorkspace* meta_workspace_new           (MetaScreen    *screen);
