--- metacity/src/display.h	Wed Sep  4 09:45:46 2002
+++ metacity_new/src/display.h	Sun Sep 15 09:07:38 2002
@@ -251,6 +251,7 @@ struct _MetaDisplay
 
 gboolean      meta_display_open                (const char  *name);
 void          meta_display_close               (MetaDisplay *display);
+void          meta_display_update_layers       (MetaDisplay *display);
 MetaScreen*   meta_display_screen_for_root     (MetaDisplay *display,
                                                 Window       xroot);
 MetaScreen*   meta_display_screen_for_x_screen (MetaDisplay *display,
--- metacity/src/display.c	Wed Sep  4 09:45:46 2002
+++ metacity_new/src/display.c	Sun Sep 15 09:34:04 2002
@@ -576,6 +576,46 @@ meta_display_list_windows (MetaDisplay *
 }
 
 void
+meta_display_update_layers (MetaDisplay *display)
+{
+  GSList *tmp;
+  GSList *frozen_stacks;
+
+  frozen_stacks = NULL;
+  tmp = meta_display_list_windows (display);
+  while (tmp != NULL)
+    {
+      MetaWindow *window = tmp->data;
+     
+      if (window == NULL ||
+          window->type == META_WINDOW_DESKTOP ||
+          window->type == META_WINDOW_DOCK)
+        continue;
+
+      /* we end up freezing the same stack a lot of times,
+       * but doesn't hurt anything. have to handle
+       * groups that span 2 screens.
+       */
+      meta_stack_freeze (window->screen->stack);
+      frozen_stacks = g_slist_prepend (frozen_stacks, window->screen->stack);
+
+      meta_stack_update_layer (window->screen->stack,
+                               window);
+
+      tmp = tmp->next;
+    }
+
+  tmp = frozen_stacks;
+  while (tmp != NULL)
+    {
+      meta_stack_thaw (tmp->data);
+      tmp = tmp->next;
+    }
+
+  g_slist_free (frozen_stacks);
+} 
+
+void
 meta_display_close (MetaDisplay *display)
 {
   GSList *tmp;
--- metacity/src/window.c	Wed Sep  4 08:14:52 2002
+++ metacity_new/src/window.c	Sun Sep 15 09:04:58 2002
@@ -829,9 +829,7 @@ meta_window_free (MetaWindow  *window)
        */
 
       meta_stack_freeze (window->screen->stack);
-      group = meta_window_get_group (window);
-      if (group)
-        meta_group_update_layers (group);
+      meta_display_update_layers (window->display);
       meta_stack_thaw (window->screen->stack);
     }
     
@@ -1695,11 +1693,7 @@ meta_window_make_fullscreen (MetaWindow 
       window->fullscreen = TRUE;
 
       meta_stack_freeze (window->screen->stack);
-      group = meta_window_get_group (window);
-      if (group)
-        meta_group_update_layers (group);
-      else
-        meta_stack_update_layer (window->screen->stack, window);
+      meta_display_update_layers (window->display);
       
       meta_window_raise (window);
       meta_stack_thaw (window->screen->stack);
@@ -1733,11 +1727,7 @@ meta_window_unmake_fullscreen (MetaWindo
       window->fullscreen = FALSE;
 
       meta_stack_freeze (window->screen->stack);
-      group = meta_window_get_group (window);
-      if (group)
-        meta_group_update_layers (group);
-      else
-        meta_stack_update_layer (window->screen->stack, window);      
+      meta_display_update_layers (window->display);
       meta_stack_thaw (window->screen->stack);
       
       meta_window_move_resize (window,
--- metacity/src/stack.c	Sun Aug 25 02:24:23 2002
+++ metacity_new/src/stack.c	Sun Sep 15 09:09:26 2002
@@ -291,6 +291,38 @@ group_member_is_fullscreen (MetaWindow *
   return retval;
 }
 
+static gboolean
+display_member_is_fullscreen (MetaWindow *window)
+{
+  GSList *members;
+  GSList *tmp;
+  gboolean retval;
+
+  if (window->fullscreen)
+    return TRUE;
+
+  members = meta_display_list_windows (window->display);
+
+  retval = FALSE;
+  tmp = members;
+  while (tmp != NULL)
+    {
+      MetaWindow *w = tmp->data;
+
+      if ((w->type != META_WINDOW_DESKTOP ||
+          w->type != META_WINDOW_DOCK) &&
+          w->fullscreen)
+        {
+          retval = TRUE;
+          break;
+        }
+
+      tmp = tmp->next;
+    }
+
+  return retval;
+}
+
 static void
 compute_layer (MetaWindow *window)
 {
@@ -310,7 +342,7 @@ compute_layer (MetaWindow *window)
       break;
       
     default:
-      if (group_member_is_fullscreen (window))
+      if (display_member_is_fullscreen (window))
         window->layer = META_LAYER_FULLSCREEN;
       else
         window->layer = META_LAYER_NORMAL;
