[comp.windows.x] Modifications to twm

clyde@ut-emx.UUCP (Head UNIX Hacquer) (12/29/88)

I got tired of having my xman icons pop up in the upper left hand
corner of my screen, so I made some changes to twm to specify default
icon geometries.  Actually, I'm tired of clients which don't do window
manager hints, but these fixes take care of it.

The diffs are fairly small (~200 lines), so I'm putting them in this
message.  Based upon the version of twm distributed in the X11R3 contrib
tree.
----------------- cut here -----------------------
*** events.c.orig	Wed Dec 28 17:40:24 1988
--- events.c	Wed Dec 28 17:42:52 1988
***************
*** 638,641 ****
--- 638,642 ----
      XSizeHints hints;
      int zoom_save;
+     int x, y;
  
  #ifdef DEBUG
***************
*** 672,695 ****
  		    if (tmp_win->wmhints->flags & IconPositionHint)
  		    {
- 			int x, y;
- 
  			x = tmp_win->wmhints->icon_x;
  			y = tmp_win->wmhints->icon_y;
- 
- 			if (x > MyDisplayWidth)
- 			    x = MyDisplayWidth - tmp_win->icon_w_width -
- 				(2 * BorderWidth);
- 
- 			if (y > MyDisplayHeight)
- 			    y = MyDisplayHeight - tmp_win->icon_height -
- 				IconFont.height - 4 - (2 * BorderWidth);
- 
- 
- 			XMoveWindow(dpy, tmp_win->icon_w, x, y);
  		    }
  		    else
  		    {
! 			XMoveWindow(dpy, tmp_win->icon_w, 0, 0);
  		    }
  
  		    tmp_win->iconified = TRUE;
--- 673,707 ----
  		    if (tmp_win->wmhints->flags & IconPositionHint)
  		    {
  			x = tmp_win->wmhints->icon_x;
  			y = tmp_win->wmhints->icon_y;
  		    }
  		    else
  		    {
! 			char	*ico;
! 
! 			x = y = 0;
! 			ico = (char *)LookInNameList(ICON_GEOMETRY,
! 				tmp_win->icon_name);
! 			if (ico != NULL)
! 			{
! 				int	i, junk;
! 
! 				i = XParseGeometry(ico, &x, &y, &junk, &junk);
! 				if ((i & XValue) == 0)
! 					x = 0;
! 				if ((i & YValue) == 0)
! 					y = 0;
! 			}
  		    }
+ 
+ 		   if (x > MyDisplayWidth)
+ 		       x = MyDisplayWidth - tmp_win->icon_w_width -
+ 			(2 * BorderWidth);
+ 
+ 		   if (y > MyDisplayHeight)
+ 		       y = MyDisplayHeight - tmp_win->icon_height -
+ 				IconFont.height - 4 - (2 * BorderWidth);
+ 
+ 		    XMoveWindow(dpy, tmp_win->icon_w, x, y);
  
  		    tmp_win->iconified = TRUE;
*** gram.y.orig	Wed Dec 28 17:40:32 1988
--- gram.y	Wed Dec 28 17:43:28 1988
***************
*** 80,84 ****
  %token <num> ICONIFY_BY_UNMAPPING DONT_ICONIFY_BY_UNMAPPING
  %token <num> WARPCURSOR NUMBER BORDERWIDTH TITLE_FONT REVERSE_VIDEO
! %token <num> RESIZE_FONT NO_TITLE AUTO_RAISE FORCE_ICON NO_HILITE
  %token <num> MENU_FONT ICON_FONT UNKNOWN_ICON ICONS ICON_DIRECTORY
  %token <num> META SHIFT CONTROL WINDOW TITLE ICON ROOT FRAME
--- 80,84 ----
  %token <num> ICONIFY_BY_UNMAPPING DONT_ICONIFY_BY_UNMAPPING
  %token <num> WARPCURSOR NUMBER BORDERWIDTH TITLE_FONT REVERSE_VIDEO
! %token <num> RESIZE_FONT NO_TITLE AUTO_RAISE FORCE_ICON NO_HILITE ICON_GEOMETRY
  %token <num> MENU_FONT ICON_FONT UNKNOWN_ICON ICONS ICON_DIRECTORY
  %token <num> META SHIFT CONTROL WINDOW TITLE ICON ROOT FRAME
***************
*** 235,238 ****
--- 235,240 ----
  		| MONOCHROME 		{ color = MONOCHROME; }
  		  color_list
+ 		| ICON_GEOMETRY		{ list = ICON_GEOMETRY; }
+ 		  geometry_list
  		| DEFAULT_FUNCTION action { DefaultFunction.func = $2;
  					  if ($2 == F_MENU)
***************
*** 337,340 ****
--- 339,352 ----
  
  win_entry	: string		{ if (FirstTime) AddToList(list, $1, 0); }
+ 		;
+ 
+ geometry_list	: LB geometry_entries RB
+ 		;
+ 
+ geometry_entries :	/* Empty */
+ 		| geometry_entries geometry_entry
+ 		;
+  
+ geometry_entry	: string string { if (FirstTime) AddToList(list, $1, $2); }
  		;
  
*** lex.l.orig	Wed Dec 28 17:40:41 1988
--- lex.l	Wed Dec 28 17:43:38 1988
***************
*** 184,187 ****
--- 184,188 ----
  [Nn][Oo][Ss][Aa][Vv][Ee][Uu][Nn][Dd][Ee][Rr] { return NO_SAVEUNDER; }
  [Rr][Aa][Nn][Dd][Oo][Mm][Pp][Ll][Aa][Cc][Ee][Mm][Ee][Nn][Tt] { return RANDOM_PLACEMENT; }
+ [Ii][Cc][Oo][Nn][Gg][Ee][Oo][Mm][Ee][Tt][Rr][Yy]  { return (ICON_GEOMETRY); }
  {qstring}			{ yylval.ptr = yytext; return STRING; }
  {number}			{ (void)sscanf(yytext, "%d", &yylval.num);
*** list.c.orig	Wed Dec 28 17:40:49 1988
--- list.c	Wed Dec 28 17:43:56 1988
***************
*** 56,59 ****
--- 56,60 ----
  name_list *AutoRaise = NULL;	/* list of window names to auto-raise */
  name_list *Icons = NULL;	/* list of window names and icons */
+ name_list *IconGeometries = 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 */
***************
*** 133,136 ****
--- 134,143 ----
  	DontIconify = nptr;
  	break;
+ 
+     case ICON_GEOMETRY:
+ 	nptr->next = IconGeometries;
+ 	nptr->ptr = ptr;
+ 	IconGeometries = nptr;
+ 	break;
      }
  }
***************
*** 182,185 ****
--- 189,196 ----
      case ICONS:
  	l = Icons;
+ 	break;
+ 
+     case ICON_GEOMETRY:
+ 	l = IconGeometries;
  	break;
  
*** twm.man.orig	Wed Dec 28 17:40:58 1988
--- twm.man	Wed Dec 28 17:44:14 1988
***************
*** 203,206 ****
--- 203,227 ----
  in conjunction with the \fBDontIconifyByUnmapping\fP list.  The default
  is to iconify by unmapping the window and mapping a seperate icon window.
+ .IP "\fBIconGeometry\fP { \fIlist\fP }" 20
+ This variable is a list of window names and default icon geometries.
+ For example:
+ .EX 0
+ \fBIconGeometry\fP
+ {
+    "xman"	"0x0+100+150"
+    "xload"	"0x0+700+100"
+ }
+ .EE
+ The names "xman" and "xload" are added to a list that is searched
+ when the client window is reparented by \fItwm\fP.
+ This list is searched only if the client does not provide a window manager
+ hint for icon positioning  (e.g. xman, xmh).
+ The
+ .I icon
+ names specified are just the first portion of the name to match.  In the
+ above example, "xman" would match "xman_SunOS" and also "xman blob".
+ The client 
+ .I icon
+ names are checked against those specified in this list.
  .IP "\fBIconManagerDontShow\fP { \fIlist\fP }" 20
  This variable is a list of window names that will not be displayed 
-- 
Shouter-To-Dead-Parrots @ Univ. of Texas Computation Center; Austin, Texas  
	clyde@emx.utexas.edu; ...!cs.utexas.edu!ut-emx!clyde

"You really have to take a broad perspective when giving pat answers
 to other people's problems."  - Eyebeam

kit@ATHENA.MIT.EDU (Chris D. Peterson) (12/30/88)

> I got tired of having my xman icons pop up in the upper left hand
> corner of my screen, so I made some changes to twm to specify default
> icon geometries.  Actually, I'm tired of clients which don't do window
> manager hints, but these fixes take care of it.

All toolkit applications, xman included "do" window manager hints, the 
way you specify the location of the icon is through the following resources.

iconX	and 	iconY

% xman -xrm "iconX:+100" -xrm "iconY:+200" -iconic

If your window manager is looking at icon hints then this should pop
up the window as an icon in the position specified.

						Chris D. Peterson     
						MIT X Consortium /
						Project Athena 

Net:	kit@athena.mit.edu		
Phone: (617) 253 - 1326			
USMail: MIT - Room E40-321
	77 Massachusetts Ave.		
	Cambridge, MA 02139		

clyde@ut-emx.UUCP (Head UNIX Hacquer) (01/03/89)

In article <8812292010.AA03135@DORA.MIT.EDU>, kit@ATHENA.MIT.EDU (Chris D. Peterson) writes:
> 
> All toolkit applications, xman included "do" window manager hints, the 
> way you specify the location of the icon is through the following resources.
> 
> iconX	and 	iconY
> 
> % xman -xrm "iconX:+100" -xrm "iconY:+200" -iconic
> 
> If your window manager is looking at icon hints then this should pop
> up the window as an icon in the position specified.
> 
> 						Chris D. Peterson     
> 						MIT X Consortium/Project Athena 
> 
Well, I tried that and twm didn't handle it right.  I know that what I've
done is a kludge at best, but I don't have the time to properly correct twm
right now.  I would prefer to use resources as Chris shows above, but that
line above results in the xman icon sitting in the upper left corner of
my screen (I'm running X11R3 with twm from the contrib sources
under SUN OS 4.0).

If anyone has an elegant (and working) solution, I would be happy to use it.

[
Lines to make our stupid inews happy...
Lines to make our stupid inews happy...
Lines to make our stupid inews happy...
]
	-Clyde Hoover
-- 
Shouter-To-Dead-Parrots @ Univ. of Texas Computation Center; Austin, Texas  
	clyde@emx.utexas.edu; ...!cs.utexas.edu!ut-emx!clyde

"You really have to take a broad perspective when giving pat answers
 to other people's problems."  - Eyebeam