[comp.windows.x] Twm fix/improvement enclosed

tbray@watsol.waterloo.edu (Tim Bray) (03/13/89)

Another improvement from a satisfied twm user.  What follows is a shar
package of four diff -cb outputs relative to the twm distribution that
came with XV11R3.  I would prefer to do this via Tom LaStrange, but
either my mail doesn't get through to him or he's too busy to deal with
it (I know the feeling).  I'd like to echo the comment, already made by
somebody in this group, that twm is cleanly put together and a pleasure
to work on.  Also the DEBUG flag is very helpful in figuring out
anomalies.

These diffs do the following:

1. A partial fix to the twm problem (mentioned by several including
myself) that causes it to silently lose a few windows when a whole bunch
are mapped very quickly.  Twm as shipped contains a botched call to
XSync; fixing this partially resolves the problem.  Still outstanding;
when all the map events flood in, twm doesn't lose any, but the odd
window leaks through and pops up in a random location on the screen.
Haven't figured why yet.

2. A new bell/whistle.  I've added a twm variable StartIconified, which
takes a list of window names like AutoRaise et al.  Windows with this
attribute, when mapped, have their inital state in the wm_hints forced
to IconicState.  I put this in because GNUmacs doesn't have a -iconic
option, and xpostit sort of does but I'm not smart enough to figure out
how to make the plaid window come up ordinary but the PostItNotes be
iconified via the resource database.  Since then, I use it for other
windows too; it's arguable that you might want to make this decision in
the window manager anyhow.

Cheers, Tim Bray
New Oxford English Dictionary Project, University of Waterloo, Ont., Canada

# This is a shell archive.  Remove anything before this line,
# then unpack it by saving it in a file and typing "sh file".
#
# Wrapped by watdragon!tbray on Sun Mar 12 11:23:05 EST 1989
# Contents:  add_window.c.diffs gram.y.diffs lex.l.diffs list.c.diffs
 
echo x - add_window.c.diffs
sed 's/^@//' > "add_window.c.diffs" <<'@//E*O*F add_window.c.diffs//'
*** add_window.c	Tue Mar  7 17:35:18 1989
--- add_window.c~	Tue Mar  7 17:30:26 1989
***************
*** 190,199 ****
      else
  	tmp_win->title_height = TITLE_BAR_HEIGHT + BorderWidth;
  
-     /* Force initial iconic state if required */
-     if (LookInList(START_ICONIFIED, tmp_win->full_name, &tmp_win->class))
-       tmp_win->wmhints->initial_state = IconicState;
- 
      if (HandlingEvents && dont_know && !RandomPlacement)
      {
  	if (!(tmp_win->wmhints && tmp_win->wmhints->flags & StateHint &&
--- 190,195 ----
***************
*** 206,212 ****
  	    while (TRUE)
  	    {
  		XUngrabServer(dpy);
! 		XSync(dpy, False);
  		XGrabServer(dpy);
  		XQueryPointer(dpy, Root, &JunkRoot, &JunkChild,
  		    &JunkX, &JunkY, &AddingX, &AddingY, &JunkMask);
--- 202,208 ----
  	    while (TRUE)
  	    {
  		XUngrabServer(dpy);
! 		XSync(dpy);
  		XGrabServer(dpy);
  		XQueryPointer(dpy, Root, &JunkRoot, &JunkChild,
  		    &JunkX, &JunkY, &AddingX, &AddingY, &JunkMask);
@//E*O*F add_window.c.diffs//
chmod u=rw,g=r,o=r add_window.c.diffs
 
echo x - gram.y.diffs
sed 's/^@//' > "gram.y.diffs" <<'@//E*O*F gram.y.diffs//'
*** gram.y	Tue Mar  7 16:32:31 1989
--- gram.y~	Tue Feb 28 09:19:46 1989
***************
*** 88,94 ****
  %token <num> ICON_FOREGROUND ICON_BACKGROUND ICON_BORDER_COLOR
  %token <num> NO_RAISE_ON_MOVE NO_RAISE_ON_DEICONIFY NO_RAISE_ON_RESIZE
  %token <num> COLOR MONOCHROME NO_TITLE_FOCUS FUNCTION F_FUNCTION
! %token <num> BORDER_TILE_FOREGROUND BORDER_TILE_BACKGROUND START_ICONIFIED
  %token <ptr> STRING
  
  %type <ptr> string
--- 88,94 ----
  %token <num> ICON_FOREGROUND ICON_BACKGROUND ICON_BORDER_COLOR
  %token <num> NO_RAISE_ON_MOVE NO_RAISE_ON_DEICONIFY NO_RAISE_ON_RESIZE
  %token <num> COLOR MONOCHROME NO_TITLE_FOCUS FUNCTION F_FUNCTION
! %token <num> BORDER_TILE_FOREGROUND BORDER_TILE_BACKGROUND
  %token <ptr> STRING
  
  %type <ptr> string
***************
*** 223,230 ****
  		  win_list
  		| NO_TITLE		{ if (FirstTime) NoTitlebar = TRUE; }
  		| AUTO_RAISE		{ list = AUTO_RAISE; }
- 		  win_list
- 		| START_ICONIFIED	{ list = START_ICONIFIED; }
  		  win_list
  		| MENU string		{ root = GetRoot($2); }
  		  menu
--- 223,228 ----
@//E*O*F gram.y.diffs//
chmod u=rw,g=r,o=r gram.y.diffs
 
echo x - lex.l.diffs
sed 's/^@//' > "lex.l.diffs" <<'@//E*O*F lex.l.diffs//'
*** lex.l	Tue Mar  7 16:40:39 1989
--- lex.l~	Tue Feb 28 09:19:46 1989
***************
*** 137,144 ****
  [Rr][Ee][Vv][Ee][Rr][Ss][Ee][Vv][Ii][Dd][Ee][Oo] { return (REVERSE_VIDEO); }
  [Nn][Oo][Tt][Ii][Tt][Ll][Ee]	{ return (NO_TITLE); }
  [Aa][Uu][Tt][Oo][Rr][Aa][Ii][Ss][Ee]	{ return (AUTO_RAISE); }
- [Ss][Tt][Aa][Rr][Tt][Ii][Cc][Oo][Nn][Ii][Ff][Ii][Ee][Dd] { 
- 			       return (START_ICONIFIED); }
  [Ff][Oo][Rr][Cc][Ee][Ii][Cc][Oo][Nn][Ss]	{ return (FORCE_ICON); }
  [Dd][Ee][Ff][Aa][Uu][Ll][Tt][Ff][Uu][Nn][Cc][Tt][Ii][Oo][Nn] {
  			       return (DEFAULT_FUNCTION); }
--- 137,142 ----
@//E*O*F lex.l.diffs//
chmod u=rw,g=r,o=r lex.l.diffs
 
echo x - list.c.diffs
sed 's/^@//' > "list.c.diffs" <<'@//E*O*F list.c.diffs//'
*** list.c	Tue Mar  7 16:43:25 1989
--- list.c~	Tue Feb 28 09:19:48 1989
***************
*** 54,60 ****
  
  name_list *NoTitle = NULL;	/* list of window names with no title bar */
  name_list *AutoRaise = NULL;	/* list of window names to auto-raise */
- name_list *StartIconified = NULL; /* list of windows to start out iconified */
  name_list *Icons = NULL;	/* list of window names and icons */
  name_list *NoHighlight = NULL;	/* list of windows no to highlight */
  name_list *DontIconify = NULL;	/* don't iconify by unmapping */
--- 54,59 ----
***************
*** 116,127 ****
  	AutoRaise = nptr;
  	break;
  
-     case START_ICONIFIED:
- 	nptr->next = StartIconified;
- 	nptr->ptr = (char *)TRUE;
- 	StartIconified = nptr;
- 	break;
- 
      case NO_TITLE:
  	nptr->next = NoTitle;
  	nptr->ptr = (char *)TRUE;
--- 115,120 ----
***************
*** 180,189 ****
  
      case AUTO_RAISE:
  	l = AutoRaise;
- 	break;
- 
-     case START_ICONIFIED:
- 	l = StartIconified;
  	break;
  
      case NO_TITLE:
--- 173,178 ----
@//E*O*F list.c.diffs//
chmod u=rw,g=r,o=r list.c.diffs
 
echo Inspecting for damage in transit...
temp=/tmp/shar$$; dtemp=/tmp/.shar$$
trap "rm -f $temp $dtemp; exit" 0 1 2 3 15
cat > $temp <<\!!!
      32     100     983 add_window.c.diffs
      30     122    1053 gram.y.diffs
      13      53     594 lex.l.diffs
      40     159    1029 list.c.diffs
     115     434    3659 total
!!!
wc  add_window.c.diffs gram.y.diffs lex.l.diffs list.c.diffs | sed 's=[^ ]*/==' | diff -b $temp - >$dtemp
if [ -s $dtemp ]
then echo "Ouch [diff of wc output]:" ; cat $dtemp
else echo "No problems found."
fi
exit 0

reif@hcx9.UCF.EDU (03/14/89)

/* Written 11:47 am  Mar 12, 1989 by tbray@watsol.UUCP in hcx9:comp.windows.x */
/* ---------- "Twm fix/improvement enclosed" ---------- */
Another improvement from a satisfied twm user.  What follows is a shar
package of four diff -cb outputs relative to the twm distribution that
came with XV11R3.  I would prefer to do this via Tom LaStrange, but
either my mail doesn't get through to him or he's too busy to deal with
it (I know the feeling).  I'd like to echo the comment, already made by
somebody in this group, that twm is cleanly put together and a pleasure
to work on.  Also the DEBUG flag is very helpful in figuring out
anomalies.

These diffs do the following:

1. A partial fix to the twm problem (mentioned by several including
myself) that causes it to silently lose a few windows when a whole bunch
are mapped very quickly.  Twm as shipped contains a botched call to
XSync; fixing this partially resolves the problem.  Still outstanding;
when all the map events flood in, twm doesn't lose any, but the odd
window leaks through and pops up in a random location on the screen.
Haven't figured why yet.

2. A new bell/whistle.  I've added a twm variable StartIconified, which
takes a list of window names like AutoRaise et al.  Windows with this
attribute, when mapped, have their inital state in the wm_hints forced
to IconicState.  I put this in because GNUmacs doesn't have a -iconic
option, and xpostit sort of does but I'm not smart enough to figure out
how to make the plaid window come up ordinary but the PostItNotes be
iconified via the resource database.  Since then, I use it for other
windows too; it's arguable that you might want to make this decision in
the window manager anyhow.

Cheers, Tim Bray
New Oxford English Dictionary Project, University of Waterloo, Ont., Canada

# This is a shell archive.  Remove anything before this line,
# then unpack it by saving it in a file and typing "sh file".
#
# Wrapped by watdragon!tbray on Sun Mar 12 11:23:05 EST 1989
# Contents:  add_window.c.diffs gram.y.diffs lex.l.diffs list.c.diffs
 
echo x - add_window.c.diffs
sed 's/^@//' > "add_window.c.diffs" <<'@//E*O*F add_window.c.diffs//'
*** add_window.c	Tue Mar  7 17:35:18 1989
--- add_window.c~	Tue Mar  7 17:30:26 1989
***************
*** 190,199 ****
      else
  	tmp_win->title_height = TITLE_BAR_HEIGHT + BorderWidth;
  
-     /* Force initial iconic state if required */
-     if (LookInList(START_ICONIFIED, tmp_win->full_name, &tmp_win->class))
-       tmp_win->wmhints->initial_state = IconicState;
- 
      if (HandlingEvents && dont_know && !RandomPlacement)
      {
  	if (!(tmp_win->wmhints && tmp_win->wmhints->flags & StateHint &&
--- 190,195 ----
***************
*** 206,212 ****
  	    while (TRUE)
  	    {
  		XUngrabServer(dpy);
! 		XSync(dpy, False);
  		XGrabServer(dpy);
  		XQueryPointer(dpy, Root, &JunkRoot, &JunkChild,
  		    &JunkX, &JunkY, &AddingX, &AddingY, &JunkMask);
--- 202,208 ----
  	    while (TRUE)
  	    {
  		XUngrabServer(dpy);
! 		XSync(dpy);
  		XGrabServer(dpy);
  		XQueryPointer(dpy, Root, &JunkRoot, &JunkChild,
  		    &JunkX, &JunkY, &AddingX, &AddingY, &JunkMask);
@//E*O*F add_window.c.diffs//
chmod u=rw,g=r,o=r add_window.c.diffs
 
echo x - gram.y.diffs
sed 's/^@//' > "gram.y.diffs" <<'@//E*O*F gram.y.diffs//'
*** gram.y	Tue Mar  7 16:32:31 1989
--- gram.y~	Tue Feb 28 09:19:46 1989
***************
*** 88,94 ****
  %token <num> ICON_FOREGROUND ICON_BACKGROUND ICON_BORDER_COLOR
  %token <num> NO_RAISE_ON_MOVE NO_RAISE_ON_DEICONIFY NO_RAISE_ON_RESIZE
  %token <num> COLOR MONOCHROME NO_TITLE_FOCUS FUNCTION F_FUNCTION
! %token <num> BORDER_TILE_FOREGROUND BORDER_TILE_BACKGROUND START_ICONIFIED
  %token <ptr> STRING
  
  %type <ptr> string
--- 88,94 ----
  %token <num> ICON_FOREGROUND ICON_BACKGROUND ICON_BORDER_COLOR
  %token <num> NO_RAISE_ON_MOVE NO_RAISE_ON_DEICONIFY NO_RAISE_ON_RESIZE
  %token <num> COLOR MONOCHROME NO_TITLE_FOCUS FUNCTION F_FUNCTION
! %token <num> BORDER_TILE_FOREGROUND BORDER_TILE_BACKGROUND
  %token <ptr> STRING
  
  %type <ptr> string
***************
*** 223,230 ****
  		  win_list
  		| NO_TITLE		{ if (FirstTime) NoTitlebar = TRUE; }
  		| AUTO_RAISE		{ list = AUTO_RAISE; }
- 		  win_list
- 		| START_ICONIFIED	{ list = START_ICONIFIED; }
  		  win_list
  		| MENU string		{ root = GetRoot($2); }
  		  menu
--- 223,228 ----
@//E*O*F gram.y.diffs//
chmod u=rw,g=r,o=r gram.y.diffs
 
echo x - lex.l.diffs
sed 's/^@//' > "lex.l.diffs" <<'@//E*O*F lex.l.diffs//'
*** lex.l	Tue Mar  7 16:40:39 1989
--- lex.l~	Tue Feb 28 09:19:46 1989
***************
*** 137,144 ****
  [Rr][Ee][Vv][Ee][Rr][Ss][Ee][Vv][Ii][Dd][Ee][Oo] { return (REVERSE_VIDEO); }
  [Nn][Oo][Tt][Ii][Tt][Ll][Ee]	{ return (NO_TITLE); }
  [Aa][Uu][Tt][Oo][Rr][Aa][Ii][Ss][Ee]	{ return (AUTO_RAISE); }
- [Ss][Tt][Aa][Rr][Tt][Ii][Cc][Oo][Nn][Ii][Ff][Ii][Ee][Dd] { 
- 			       return (START_ICONIFIED); }
  [Ff][Oo][Rr][Cc][Ee][Ii][Cc][Oo][Nn][Ss]	{ return (FORCE_ICON); }
  [Dd][Ee][Ff][Aa][Uu][Ll][Tt][Ff][Uu][Nn][Cc][Tt][Ii][Oo][Nn] {
  			       return (DEFAULT_FUNCTION); }
--- 137,142 ----
@//E*O*F lex.l.diffs//
chmod u=rw,g=r,o=r lex.l.diffs
 
echo x - list.c.diffs
sed 's/^@//' > "list.c.diffs" <<'@//E*O*F list.c.diffs//'
*** list.c	Tue Mar  7 16:43:25 1989
--- list.c~	Tue Feb 28 09:19:48 1989
***************
*** 54,60 ****
  
  name_list *NoTitle = NULL;	/* list of window names with no title bar */
  name_list *AutoRaise = NULL;	/* list of window names to auto-raise */
- name_list *StartIconified = NULL; /* list of windows to start out iconified */
  name_list *Icons = NULL;	/* list of window names and icons */
  name_list *NoHighlight = NULL;	/* list of windows no to highlight */
  name_list *DontIconify = NULL;	/* don't iconify by unmapping */
--- 54,59 ----
***************
*** 116,127 ****
  	AutoRaise = nptr;
  	break;
  
-     case START_ICONIFIED:
- 	nptr->next = StartIconified;
- 	nptr->ptr = (char *)TRUE;
- 	StartIconified = nptr;
- 	break;
- 
      case NO_TITLE:
  	nptr->next = NoTitle;
  	nptr->ptr = (char *)TRUE;
--- 115,120 ----
***************
*** 180,189 ****
  
      case AUTO_RAISE:
  	l = AutoRaise;
- 	break;
- 
-     case START_ICONIFIED:
- 	l = StartIconified;
  	break;
  
      case NO_TITLE:
--- 173,178 ----
@//E*O*F list.c.diffs//
chmod u=rw,g=r,o=r list.c.diffs
 
echo Inspecting for damage in transit...
temp=/tmp/shar$$; dtemp=/tmp/.shar$$
trap "rm -f $temp $dtemp; exit" 0 1 2 3 15
cat > $temp <<\!!!
      32     100     983 add_window.c.diffs
      30     122    1053 gram.y.diffs
      13      53     594 lex.l.diffs
      40     159    1029 list.c.diffs
     115     434    3659 total
!!!
wc  add_window.c.diffs gram.y.diffs lex.l.diffs list.c.diffs | sed 's=[^ ]*/==' | diff -b $temp - >$dtemp
if [ -s $dtemp ]
then echo "Ouch [diff of wc output]:" ; cat $dtemp
else echo "No problems found."
fi
exit 0
/* End of text from hcx9:comp.windows.x */

envbvs@epb5.lbl.gov (Brian V. Smith) (03/14/89)

In article 6618, Tim Bray enclosed some fixes for twm.
He left out one small thing: the definition in gram.h of START_ICONIFIED.
Here is the diff -c for that file, suitable for running through patch:

*** gram.h.orig	Mon Mar 13 21:47:19 1989
--- gram.h	Mon Mar 13 21:45:10 1989
***************
*** 106,109
  # define F_FUNCTION 355
  # define BORDER_TILE_FOREGROUND 356
  # define BORDER_TILE_BACKGROUND 357
! # define STRING 358

--- 106,110 -----
  # define F_FUNCTION 355
  # define BORDER_TILE_FOREGROUND 356
  # define BORDER_TILE_BACKGROUND 357
! # define START_ICONIFIED 358
! # define STRING 359

toml@hpfcdq.HP.COM (Tom LaStrange) (03/15/89)

> Another improvement from a satisfied twm user.  What follows is a shar
> package of four diff -cb outputs relative to the twm distribution that
> came with XV11R3.  I would prefer to do this via Tom LaStrange, but
> either my mail doesn't get through to him or he's too busy to deal with
> it (I know the feeling).

Sorry for not responding. I did get your mail.  I have been busy.

> 2. A new bell/whistle.  I've added a twm variable StartIconified, which
> takes a list of window names like AutoRaise et al.  Windows with this
> attribute, when mapped, have their inital state in the wm_hints forced
> to IconicState.  I put this in because GNUmacs doesn't have a -iconic
> option, and xpostit sort of does but I'm not smart enough to figure out
> how to make the plaid window come up ordinary but the PostItNotes be
> iconified via the resource database.  Since then, I use it for other
> windows too; it's arguable that you might want to make this decision in
> the window manager anyhow.

OK, I've put your stuff into the "official" version,  but I think there
may be a problem.

> -     /* Force initial iconic state if required */
> -     if (LookInList(START_ICONIFIED, tmp_win->full_name, &tmp_win->class))
> -       tmp_win->wmhints->initial_state = IconicState;

You are assuming here that tmp_win->wmhints points to something.  This
will likely cause problems if you run a client that does not specify
wmhints.

--
Tom LaStrange

Hewlett Packard Co.               ARPA: toml%hpfcla@hplabs.hp.com
Graphics Technology Division      UUCP: hplabs!hpfcla!toml
Fort Collins, CO