Index: src/stack.c
===================================================================
RCS file: /cvs/gnome/metacity/src/stack.c,v
retrieving revision 1.69
diff -p -u -r1.69 stack.c
--- src/stack.c	28 Feb 2004 23:58:40 -0000	1.69
+++ src/stack.c	29 Feb 2004 00:06:06 -0000
@@ -366,37 +366,14 @@ compute_layer (MetaWindow *window)
       window->type == META_WINDOW_MENU ||
       window->type == META_WINDOW_TOOLBAR)
     {
-      if (window->xtransient_for != None &&
-          !window->transient_parent_is_root_window)
-        {
-          MetaStackLayer ancestor_max;
-
-          ancestor_max = get_maximum_layer_of_ancestor (window);
-          
-          if (ancestor_max > window->layer)
-            {
-              meta_topic (META_DEBUG_STACK,
-                          "Promoting window %s from layer %d to %d due to transiency\n",
-                          window->desc, window->layer, ancestor_max);
-              window->layer = ancestor_max;
-            }
-        }
-      else
+      if (window->xtransient_for == None ||
+          window->transient_parent_is_root_window)
         {
           /* We only do the group thing if the dialog is NOT transient for
            * a particular window. Imagine a group with a normal window, a dock,
            * and a dialog transient for the normal window; you don't want the dialog
            * above the dock if it wouldn't normally be.
            */
-
-          /* FIXME when promoting a window here,
-           * it's necessary to promote its transient children
-           * (or other windows constrained to be above it)
-           * as well, but we aren't handling that, and it's
-           * somewhat hard to fix.
-           *
-           * http://bugzilla.gnome.org/show_bug.cgi?id=96140
-           */
           
           MetaStackLayer group_max;
           
@@ -716,13 +693,25 @@ static void
 ensure_above (MetaWindow *above,
               MetaWindow *below)
 {  
+  if ((above->type == META_WINDOW_DIALOG ||
+       above->type == META_WINDOW_MODAL_DIALOG ||
+       above->type == META_WINDOW_UTILITY ||
+       above->type == META_WINDOW_MENU ||
+       above->type == META_WINDOW_TOOLBAR) &&
+      above->layer < below->layer)
+    {
+      meta_topic (META_DEBUG_STACK,
+		  "Promoting window %s from layer %d to %d due to contraint\n",
+		  above->desc, above->layer, below->layer);
+      above->layer = below->layer;
+    }
+
   if (above->stack_position < below->stack_position)
     {
       /* move above to below->stack_position bumping below down the stack */
       meta_window_set_stack_position (above, below->stack_position);
       g_assert (below->stack_position + 1 == above->stack_position);
     }
-
   meta_topic (META_DEBUG_STACK, "%s above at %d > %s below at %d\n",
               above->desc, above->stack_position,
               below->desc, below->stack_position);
@@ -936,6 +925,7 @@ meta_stack_ensure_sorted (MetaStack *sta
                           w->desc, old_layer, w->layer);
               
               stack->need_resort = TRUE;
+              stack->need_constrain = TRUE;
               /* don't need to constrain as constraining
                * purely operates in terms of stack_position
                * not layer
@@ -948,7 +938,8 @@ meta_stack_ensure_sorted (MetaStack *sta
       stack->need_relayer = FALSE;
     }
 
-  /* Update stack_position to reflect transiency constraints */
+  /* Update stack_position and layer to reflect transiency
+     constraints */
   constrain_stacking (stack);
   
   /* Sort stack->sorted with layers having priority over stack_position
