[comp.windows.x] Icon Titles in Twm

relph@presto.ig.com (John M. Relph) (02/15/91)

  Here's an interesting patch for Twm.  I disliked seeing the titles
beneath icons, so I've added two options one can use in one's ".twmrc"
file to control the display of icon titles.

  "NoIconTitle" alone specifies that no icon titles are to be displayed.
  "NoIconTitle" followed by a "{ list of windows }" means only those
	windows' icons get no titles.
  "IconTitle { list of windows }" means those icons get titles no
	matter what. 

  I hope you like it.

	-- John

---- cut here ----
*** add_window.c.ORIG	Wed Feb 13 21:20:22 1991
--- add_window.c	Wed Feb 13 22:00:30 1991
***************
*** 248,253 ****
--- 248,264 ----
  	(short)LookInList(Scr->IconifyByUn, tmp_win->full_name,
  	    &tmp_win->class);
  
+     tmp_win->no_icon_title = Scr->NoIconTitle;
+     if (Scr->NoIconTitle)
+     {
+       if ((short)LookInList(Scr->IconTitle, tmp_win->full_name,
+ 			    &tmp_win->class))
+ 	tmp_win->no_icon_title = FALSE;
+     }
+     if ((short)LookInList(Scr->NoIconTitleList, tmp_win->full_name,
+ 			  &tmp_win->class))
+       tmp_win->no_icon_title = TRUE;
+ 
      if (LookInList(Scr->WindowRingL, tmp_win->full_name, &tmp_win->class)) {
  	if (Scr->Ring) {
  	    tmp_win->ring.next = Scr->Ring->ring.next;
*** events.c.ORIG	Wed Feb 13 20:03:49 1991
--- events.c	Wed Feb 13 20:47:09 1991
***************
*** 879,888 ****
      if (Tmp_win->icon_not_ours)
  	return;
  
!     Tmp_win->icon_w_width = XTextWidth(Scr->IconFont.font,
  	Tmp_win->icon_name, strlen(Tmp_win->icon_name));
  
-     Tmp_win->icon_w_width += 6;
      if (Tmp_win->icon_w_width < Tmp_win->icon_width)
      {
  	Tmp_win->icon_x = (Tmp_win->icon_width - Tmp_win->icon_w_width)/2;
--- 879,892 ----
      if (Tmp_win->icon_not_ours)
  	return;
  
!     if (! Tmp_win->no_icon_title) {
!       Tmp_win->icon_w_width = XTextWidth(Scr->IconFont.font,
  	Tmp_win->icon_name, strlen(Tmp_win->icon_name));
+       Tmp_win->icon_w_width += 6;
+     }
+     else
+       Tmp_win->icon_w_width = 0;
  
      if (Tmp_win->icon_w_width < Tmp_win->icon_width)
      {
  	Tmp_win->icon_x = (Tmp_win->icon_width - Tmp_win->icon_w_width)/2;
***************
*** 901,908 ****
  
      y = 0;
  
!     Tmp_win->icon_w_height = Tmp_win->icon_height + Scr->IconFont.height + 4;
!     Tmp_win->icon_y = Tmp_win->icon_height + Scr->IconFont.height;
  
      XResizeWindow(dpy, Tmp_win->icon_w, Tmp_win->icon_w_width,
  	Tmp_win->icon_w_height);
--- 905,918 ----
  
      y = 0;
  
!     if (! Tmp_win->no_icon_title) {
!       Tmp_win->icon_w_height = Tmp_win->icon_height + Scr->IconFont.height + 4;
!       Tmp_win->icon_y = Tmp_win->icon_height + Scr->IconFont.height;
!     }
!     else {
!       Tmp_win->icon_w_height = Tmp_win->icon_height + Scr->IconFont.height + 4;
!       Tmp_win->icon_y = Tmp_win->icon_height + Scr->IconFont.height;
!     }
  
      XResizeWindow(dpy, Tmp_win->icon_w, Tmp_win->icon_w_width,
  	Tmp_win->icon_w_height);
***************
*** 1006,1012 ****
  	    FBF(Tmp_win->iconc.fore, Tmp_win->iconc.back,
  		Scr->IconFont.font->fid);
  
! 	    XDrawString (dpy, Tmp_win->icon_w,
  		Scr->NormalGC,
  		Tmp_win->icon_x, Tmp_win->icon_y,
  		Tmp_win->icon_name, strlen(Tmp_win->icon_name));
--- 1016,1023 ----
  	    FBF(Tmp_win->iconc.fore, Tmp_win->iconc.back,
  		Scr->IconFont.font->fid);
  
! 	    if (! Tmp_win->no_icon_title)
! 	      XDrawString (dpy, Tmp_win->icon_w,
  		Scr->NormalGC,
  		Tmp_win->icon_x, Tmp_win->icon_y,
  		Tmp_win->icon_name, strlen(Tmp_win->icon_name));
*** gram.y.ORIG	Wed Feb 13 21:20:23 1991
--- gram.y	Wed Feb 13 21:17:46 1991
***************
*** 81,87 ****
  %token <num> ICONMGR_SHOW ICONMGR WINDOW_FUNCTION ZOOM ICONMGRS
  %token <num> ICONMGR_GEOMETRY ICONMGR_NOSHOW MAKE_TITLE
  %token <num> ICONIFY_BY_UNMAPPING DONT_ICONIFY_BY_UNMAPPING 
! %token <num> NO_TITLE AUTO_RAISE NO_HILITE ICON_REGION 
  %token <num> META SHIFT LOCK CONTROL WINDOW TITLE ICON ROOT FRAME 
  %token <num> COLON EQUALS SQUEEZE_TITLE DONT_SQUEEZE_TITLE
  %token <num> START_ICONIFIED NO_TITLE_HILITE TITLE_HILITE
--- 81,87 ----
  %token <num> ICONMGR_SHOW ICONMGR WINDOW_FUNCTION ZOOM ICONMGRS
  %token <num> ICONMGR_GEOMETRY ICONMGR_NOSHOW MAKE_TITLE
  %token <num> ICONIFY_BY_UNMAPPING DONT_ICONIFY_BY_UNMAPPING 
! %token <num> NO_TITLE AUTO_RAISE NO_HILITE ICON_REGION
  %token <num> META SHIFT LOCK CONTROL WINDOW TITLE ICON ROOT FRAME 
  %token <num> COLON EQUALS SQUEEZE_TITLE DONT_SQUEEZE_TITLE
  %token <num> START_ICONIFIED NO_TITLE_HILITE TITLE_HILITE
***************
*** 88,94 ****
  %token <num> MOVE RESIZE WAIT SELECT KILL LEFT_TITLEBUTTON RIGHT_TITLEBUTTON 
  %token <num> NUMBER KEYWORD NKEYWORD CKEYWORD CLKEYWORD FKEYWORD FSKEYWORD 
  %token <num> SKEYWORD DKEYWORD JKEYWORD WINDOW_RING WARP_CURSOR ERRORTOKEN
! %token <num> NO_STACKMODE
  %token <ptr> STRING 
  
  %type <ptr> string
--- 88,94 ----
  %token <num> MOVE RESIZE WAIT SELECT KILL LEFT_TITLEBUTTON RIGHT_TITLEBUTTON 
  %token <num> NUMBER KEYWORD NKEYWORD CKEYWORD CLKEYWORD FKEYWORD FSKEYWORD 
  %token <num> SKEYWORD DKEYWORD JKEYWORD WINDOW_RING WARP_CURSOR ERRORTOKEN
! %token <num> NO_STACKMODE ICON_TITLE NO_ICON_TITLE
  %token <ptr> STRING 
  
  %type <ptr> string
***************
*** 134,139 ****
--- 134,143 ----
  		  win_list
  		| ICONIFY_BY_UNMAPPING	{ if (Scr->FirstTime) 
  		    Scr->IconifyByUnmapping = TRUE; }
+ 		| NO_ICON_TITLE		{ list = &Scr->NoIconTitleList; }
+ 		  win_list
+ 		| NO_ICON_TITLE		{ if (Scr->FirstTime)
+ 						Scr->NoIconTitle = TRUE; }
  		| LEFT_TITLEBUTTON string EQUALS action { 
  					  GotTitleButton ($2, $4, False);
  					}
***************
*** 163,168 ****
--- 167,174 ----
  		| string fullkey	{ GotKey($1, $2); }
  		| button full		{ GotButton($1, $2); }
  		| DONT_ICONIFY_BY_UNMAPPING { list = &Scr->DontIconify; }
+ 		  win_list
+ 		| ICON_TITLE		{ list = &Scr->IconTitle; }
  		  win_list
  		| ICONMGR_NOSHOW	{ list = &Scr->IconMgrNoShow; }
  		  win_list
*** icons.c.ORIG	Wed Feb 13 20:03:49 1991
--- icons.c	Wed Feb 13 20:52:30 1991
***************
*** 476,485 ****
  	attributes.background_pixmap = pm;
      }
  
!     tmp_win->icon_w_width = XTextWidth(Scr->IconFont.font,
  	tmp_win->icon_name, strlen(tmp_win->icon_name));
! 
!     tmp_win->icon_w_width += 6;
      if (tmp_win->icon_w_width < tmp_win->icon_width)
      {
  	tmp_win->icon_x = (tmp_win->icon_width - tmp_win->icon_w_width)/2;
--- 476,489 ----
  	attributes.background_pixmap = pm;
      }
  
!     if (! tmp_win->no_icon_title) {
!       tmp_win->icon_w_width = XTextWidth(Scr->IconFont.font,
  	tmp_win->icon_name, strlen(tmp_win->icon_name));
!       tmp_win->icon_w_width += 6;
!     }
!     else
!       tmp_win->icon_w_width = 0;
!     
      if (tmp_win->icon_w_width < tmp_win->icon_width)
      {
  	tmp_win->icon_x = (tmp_win->icon_width - tmp_win->icon_w_width)/2;
***************
*** 490,497 ****
      {
  	tmp_win->icon_x = 3;
      }
!     tmp_win->icon_y = tmp_win->icon_height + Scr->IconFont.height;
!     tmp_win->icon_w_height = tmp_win->icon_height + Scr->IconFont.height + 4;
  
      event_mask = 0;
      if (tmp_win->wmhints && tmp_win->wmhints->flags & IconWindowHint)
--- 494,507 ----
      {
  	tmp_win->icon_x = 3;
      }
!     if (! tmp_win->no_icon_title) {
!       tmp_win->icon_y = tmp_win->icon_height + Scr->IconFont.height;
!       tmp_win->icon_w_height = tmp_win->icon_height + Scr->IconFont.height + 4;
!     }
!     else {
!       tmp_win->icon_y = tmp_win->icon_height;
!       tmp_win->icon_w_height = tmp_win->icon_height;
!     }
  
      event_mask = 0;
      if (tmp_win->wmhints && tmp_win->wmhints->flags & IconWindowHint)
*** parse.c.ORIG	Wed Feb 13 20:03:49 1991
--- parse.c	Wed Feb 13 21:18:12 1991
***************
*** 474,479 ****
--- 474,480 ----
      { "iconmgr",		ICONMGR, 0 },
      { "iconregion",		ICON_REGION, 0 },
      { "icons",			ICONS, 0 },
+     { "icontitle",		ICON_TITLE, 0 },
      { "interpolatemenucolors",	KEYWORD, kw0_InterpolateMenuColors },
      { "l",			LOCK, 0 },
      { "left",			JKEYWORD, J_LEFT },
***************
*** 500,505 ****
--- 501,507 ----
      { "nograbserver",		KEYWORD, kw0_NoGrabServer },
      { "nohighlight",		NO_HILITE, 0 },
      { "noiconmanagers",		KEYWORD, kw0_NoIconManagers },
+     { "noicontitle",		NO_ICON_TITLE, 0 },
      { "nomenushadows",		KEYWORD, kw0_NoMenuShadows },
      { "noraiseondeiconify",	KEYWORD, kw0_NoRaiseOnDeiconify },
      { "noraiseonmove",		KEYWORD, kw0_NoRaiseOnMove },
*** screen.h.ORIG	Wed Feb 13 20:03:49 1991
--- screen.h	Wed Feb 13 20:56:43 1991
***************
*** 171,176 ****
--- 171,178 ----
      name_list *DontSqueezeTitleL;	/* windows of which not to squeeze */
      name_list *WindowRingL;	/* windows in ring */
      name_list *WarpCursorL;	/* windows to warp cursor to on deiconify */
+     name_list *NoIconTitleList;	/* list of windows with no icon titles */
+     name_list *IconTitle;	/* list of windows with icon titles */
  
      GC NormalGC;		/* normal GC for everything */
      GC MenuGC;			/* gc for menus */
***************
*** 240,245 ****
--- 242,248 ----
      short FirstTime;		/* first time we've read .twmrc */
      short CaseSensitive;	/* be case-sensitive when sorting names */
      short WarpUnmapped;		/* allow warping to unmapped windows */
+     short NoIconTitle;		/* Don't display title below icon */
  
      FuncKey FuncKeyRoot;
  } ScreenInfo;
*** twm.c.ORIG	Wed Feb 13 20:03:49 1991
--- twm.c	Wed Feb 13 20:57:55 1991
***************
*** 295,300 ****
--- 295,302 ----
  	Scr->DontSqueezeTitleL = NULL;
  	Scr->WindowRingL = NULL;
  	Scr->WarpCursorL = NULL;
+ 	Scr->NoIconTitleList = NULL;
+ 	Scr->IconTitle = NULL;
  	/* remember to put an initialization in InitVariables also
  	 */
  
***************
*** 544,549 ****
--- 546,553 ----
      FreeList(&Scr->DontSqueezeTitleL);
      FreeList(&Scr->WindowRingL);
      FreeList(&Scr->WarpCursorL);
+     FreeList(&Scr->NoIconTitleList);
+     FreeList(&Scr->IconTitle);
  
      NewFontCursor(&Scr->FrameCursor, "top_left_arrow");
      NewFontCursor(&Scr->TitleCursor, "top_left_arrow");
***************
*** 628,633 ****
--- 632,638 ----
      Scr->HaveFonts = FALSE;		/* i.e. not loaded yet */
      Scr->CaseSensitive = TRUE;
      Scr->WarpUnmapped = FALSE;
+     Scr->NoIconTitle = FALSE;
  
      /* setup default fonts; overridden by defaults from system.twmrc */
  #define DEFAULT_NICE_FONT "variable"
*** twm.h.ORIG	Wed Feb 13 21:20:23 1991
--- twm.h	Wed Feb 13 20:45:48 1991
***************
*** 254,259 ****
--- 254,260 ----
      short highlight;		/* should highlight this window */
      short stackmode;		/* honor stackmode requests */
      short iconify_by_unmapping;	/* unmap window to iconify it */
+     short no_icon_title;	/* do not display title of icon */
      short iconmgr;		/* this is an icon manager window */
      short transient;		/* this is a transient window */
      short titlehighlight;	/* should I highlight the title bar */
*** twm.man.ORIG	Wed Feb 13 21:20:40 1991
--- twm.man	Wed Feb 13 22:06:49 1991
***************
*** 491,496 ****
--- 491,500 ----
  the icon bitmap in the file ``xterm.icon''.  If \fBForceIcons\fP is
  specified, this bitmap will be used even if the client has requested its
  own icon pixmap.
+ .IP "\fBIconTitle\fP { \fIwin-list\fP }" 8
+ This variable specifies a list of windows that should have their names
+ displayed below their icons when iconified
+ (as would be the case if \fBNoIconTitle\fP had not been set).
  .IP "\fBInterpolateMenuColors\fP" 8
  This variable indicates that menu entry colors should be interpolated between
  entry specified colors.  In the example below:
***************
*** 574,579 ****
--- 578,587 ----
  current \fBBorderTileForeground\fP and \fBBorderTileBackground\fP colors.
  .IP "\fBNoIconManagers\fP" 8
  This variable indicates that no icon manager should be created.
+ .IP "\fBNoIconTitle [{ \fIwin-list\fP }]\fP" 8
+ This variable indicates that windows should not have titles displayed
+ when iconified.  If the optional \fIwin-list\fP is provided, only
+ those windows will not have titles displayed when iconified.
  .IP "\fBNoMenuShadows\fP" 8
  This variable indicates that menus should not have drop shadows drawn behind
  them.  This is typically used with slower servers since it speeds up menu

toml@marvin.Solbourne.COM (Tom LaStrange) (02/15/91)

}   Here's an interesting patch for Twm.  I disliked seeing the titles
} beneath icons, so I've added two options one can use in one's ".twmrc"
} file to control the display of icon titles.
} 
}   "NoIconTitle" alone specifies that no icon titles are to be displayed.
}   "NoIconTitle" followed by a "{ list of windows }" means only those
} 	windows' icons get no titles.
}   "IconTitle { list of windows }" means those icons get titles no
} 	matter what. 


This is also available in tvtwm.  I'm pretty sure that even the variables
that control it are named the same.

--
Tom LaStrange        toml@Solbourne.COM