Index: metacity/ChangeLog
===================================================================
RCS file: /export/cvs/gnome-2.0/metacity/ChangeLog,v
retrieving revision 1.615
diff -p -u -5 -r1.615 ChangeLog
--- metacity/ChangeLog	2003/02/05 15:11:46	1.615
+++ metacity/ChangeLog	2003/02/08 11:14:28
@@ -1,5 +1,11 @@
+2003-02-08  Arvind Samptur  <arvind.samptur@wipro.com>
+	* src/stack.c : (meta_window_is_modal_with_no_grandparent) :
+	A modal window is transient for the whole group if its
+	transient parent has no transient parent. Urgh :/
+	#100343.
+
 2003-02-05  Abel Cheung  <maddog@linux.org.hk>
 
 	* configure.in: Added "en_GB" and "nl" to ALL_LINGUAS.
 
 2003-02-05  Akira TAGOH  <tagoh@gnome.gr.jp>
Index: metacity/src/stack.c
===================================================================
RCS file: /export/cvs/gnome-2.0/metacity/src/stack.c,v
retrieving revision 1.61
diff -p -u -5 -r1.61 stack.c
--- metacity/src/stack.c	2003/01/25 16:58:43	1.61
+++ metacity/src/stack.c	2003/02/08 11:14:29
@@ -30,10 +30,11 @@
 #include "workspace.h"
 
 #include <X11/Xatom.h>
 
 static void meta_stack_sync_to_server (MetaStack *stack);
+static gboolean meta_window_is_modal_with_no_grandparent (MetaWindow *window);
 
 MetaStack*
 meta_stack_new (MetaScreen *screen)
 {
   MetaStack *stack;
@@ -529,13 +530,14 @@ add_constraint (Constraint **constraints
            w->type == META_WINDOW_TOOLBAR ||            \
            w->type == META_WINDOW_MENU ||               \
            w->type == META_WINDOW_UTILITY)
 
 #define WINDOW_TRANSIENT_FOR_WHOLE_GROUP(w)             \
-         ((w->xtransient_for == None ||                 \
+         (((w->xtransient_for == None ||                \
            w->transient_parent_is_root_window) &&       \
-          WINDOW_HAS_TRANSIENT_TYPE (w))
+          WINDOW_HAS_TRANSIENT_TYPE (w)) ||             \
+          meta_window_is_modal_with_no_grandparent (w))
 
 #define WINDOW_IN_STACK(w) (w->stack_position >= 0)
 
 static void
 create_constraints (Constraint **constraints,
@@ -586,12 +588,14 @@ create_constraints (Constraint **constra
               if (!(meta_window_is_ancestor_of_transient (w, group_window)) &&
                   !WINDOW_TRANSIENT_FOR_WHOLE_GROUP (group_window))  /* note */;/*note*/
 #else
               /* better way I think, so transient-for-group are constrained
                * only above non-transient-type windows in their group
+               * Modal dialog will always be on top of the group
                */
-              if (!WINDOW_HAS_TRANSIENT_TYPE (group_window))
+              if (!WINDOW_HAS_TRANSIENT_TYPE (group_window) ||
+                   w->type == META_WINDOW_MODAL_DIALOG)
 #endif
                 {
                   meta_topic (META_DEBUG_STACK, "Constraining %s above %s as it's transient for its group\n",
                               w->desc, group_window->desc);
                   add_constraint (constraints, w, group_window);
@@ -1543,6 +1547,28 @@ meta_window_set_stack_position (MetaWind
   window->stack_position = position;
 
   meta_topic (META_DEBUG_STACK,
               "Window %s had stack_position set to %d\n",
               window->desc, window->stack_position);
+}
+
+static
+gboolean meta_window_is_modal_with_no_grandparent (MetaWindow *window)
+{
+
+  if (window->xtransient_for != None &&
+      !window->transient_parent_is_root_window &&
+       window->type == META_WINDOW_MODAL_DIALOG) 
+    {
+          MetaWindow *parent;
+
+          parent = meta_display_lookup_x_window (window->display, window->xtransient_for);
+
+          if (parent && WINDOW_IN_STACK (parent))  {
+            if (parent->xtransient_for == None || 
+                parent->transient_parent_is_root_window) {
+                  return TRUE;
+             }
+          }
+   }
+   return FALSE;
 }
