[4882] in Athena Bugs

home help back first fref pref prev next nref lref last post

Xaw/TextPop.c should set TransientFor on PopUps

daemon@ATHENA.MIT.EDU (Jonathan I. Kamens)
Mon May 7 15:35:28 1990

Date: Mon, 7 May 90 15:35:06 -0400
From: "Jonathan I. Kamens" <jik@pit-manager.MIT.EDU>
To: xbugs@expo.lcs.mit.edu
Cc: bugs@ATHENA.MIT.EDU

			  X Window System Bug Report
			    xbugs@expo.lcs.mit.edu


VERSION:
    R4

CLIENT MACHINE and OPERATING SYSTEM:
    NA

DISPLAY TYPE:
    NA

WINDOW MANAGER:
    mwm

AREA:
    Xaw -- TextPop.c

SYNOPSIS:
    The functions in TextPop.c which create PopUp widgets for Text
    widgets should set TransientFor so the PopUps are associated with
    the correct window.

DESCRIPTION:
    Transient PopUp are associated with a shell widget for which they
    are transient.  This association leads to two features of window
    manager behavior:

	1. When the shell widget is iconified, the PopUp is iconified
	   with it.
	2. When the PopUp is popped up, the shell widget is raised (by
	   some window managers) so that it is directly below the
	   PopUp in the stacking order.

    However, the PopUp widgets created by the functions in TextPop.c
    do not have TransientFor explicitly set, so they default to the
    top-most shell in the program.  This is bad.

REPEAT BY:
    Run xmh, under mwm.  Open a "compose message" window, and lay it
    over the main xmh window.  Hit M-i to do "insert file".  Note how
    the main xmh window pops up on top of the composition window.

SAMPLE FIX:
    Apply the following patch to TextPop.c.  This patch explicitly
    sets TransientFor for the dialog widgets used by the Text widget
    to the closest ancestor which is a shell.  I reached the
    conclusion that this is the Right Thing To Do after talking about
    it with Ralph Swick for a while....

---cut here---
*** TextPop.c.orig	Mon Feb 12 01:29:46 1990
--- TextPop.c	Mon May  7 18:20:48 1990
***************
*** 76,81 ****
--- 76,82 ----
  static void InitializeSearchWidget(), SetResource(), SetSearchLabels();
  static void DoReplaceOne(), DoReplaceAll();
  static Widget CreateDialog();
+ static Widget GetShell();
  static Boolean DoSearch(), SetResourceByName(), Replace();
  static String GetString();
  
***************
*** 1228,1234 ****
  void (*func)();
  {
    Widget popup, form;
!   Arg args[4];
    Cardinal num_args;
  
    num_args = 0;
--- 1229,1235 ----
  void (*func)();
  {
    Widget popup, form;
!   Arg args[5];
    Cardinal num_args;
  
    num_args = 0;
***************
*** 1236,1241 ****
--- 1237,1243 ----
    XtSetArg(args[num_args], XtNgeometry, NULL); num_args++;
    XtSetArg(args[num_args], XtNallowShellResize, TRUE); num_args++;
    XtSetArg(args[num_args], XtNsaveUnder, TRUE); num_args++;
+   XtSetArg(args[num_args], XtNtransientFor, GetShell(parent)); num_args++;
    popup = XtCreatePopupShell(name, transientShellWidgetClass, 
  			     parent, args, XtNumber(args) );
    
***************
*** 1244,1247 ****
--- 1246,1267 ----
  
    (*func) (form, ptr, parent);
    return(popup);
+ }
+ 
+ /*	Function Name: GetShell
+  * 	Description: Walks up the widget hierarchy to find the
+  * 		nearest shell widget.
+  * 	Arguments: w - the widget whose parent shell should be returned.
+  * 	Returns: The shell widget among the ancestors of w that is the
+  * 		fewest levels up in the widget hierarchy.
+  */
+ 
+ static Widget
+ GetShell(w)
+ Widget w;
+ {
+   while (w && (! XtIsShell(w)))
+     w = XtParent(w);
+ 
+   return (w);
  }
---cut here---

Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik@Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8495			      Home: 617-782-0710

home help back first fref pref prev next nref lref last post