[comp.windows.x] Why doesn't xterm support icon bitmaps?

nobody@orca.WV.TEK.COM (-for inetd server command) (05/10/89)

From: dougb@mustang.WV.TEK.COM (Doug Becker;685-2062;61-277;;mustang)
Path: mustang!dougb

     Is there any reason xterm doesn't support icon bitmaps under 
X11, as it did in X10 (i.e. as in xterm -ib _bitmap_ and 
xterm*iconBitmap: _bitmap_)? As I understand it, this seems like a 
fairly simple proposition, with xterm needing only to construct the 
pixmap, then pass it to the window manager via XSetStandardProperties(). 

     The reason I ask is that there are a few people here who have 
become very attached to their X10 icon bitmaps, and who are reluctant 
to convert to X11 because of their apparent absence. Of course, firing 
up x10tox11 then calling the X10 version of xterm is one way to do it, 
but that doesn't really address the question :-). Is there perhaps a 
(tweaked) version of xterm floating around that *does* support
user-specified icon bitmaps?


                                                    --- Doug Becker


P.S.:  I also believe a quick "thank you" is due to Robert Scheifler, 
     Jim Fulton, Chris D. Peterson and all the other MIT "xperts" for 
     providing clear and very timely responses to questions posted here. 
     Regardless of whether or not their answers are part of their 
     "responsibilities," I for one am very thankful to have world-
     renowned experts in the field within such easy reach.

==================================DOUGLAS H. BECKER=============================
domain mailers:                           |
 dougb@{orca|shark|hammer}.WV.TEK.COM     | US Mail: Software Engineer, ITD
UUCP (avoid):                             |          Tektronix, Inc.
 {anywhere}!tektronix!tekecs!orca!dougb   |          P.O. Box 1000
ARPANET:                                  |          Mail Station 61-277
 dougb%orca.WV.TEK.COM@RELAY.CS.NET       |          Wilsonville, OR 97070-1000
    CompuServe:        GEnie:             |          U.S.A.
       72711,1753         D.BECKER10      |
==========================================+=====================================

bob@monster.cis.ohio-state.edu (Bob Sutterfield) (05/10/89)

In article <3284@orca.WV.TEK.COM> nobody@orca.WV.TEK.COM (-for inetd server command) writes:
   The reason I ask is that there are a few people here who have
   become very attached to their X10 icon bitmaps, and who are
   reluctant to convert to X11 because of their apparent absence.

Similarly, some here are emotionally dependent upon their X10 xterm
active icons, wherein they keep watch over goings-on that they have
put aside for a while.  This would be another nice feature to
reinstate, if anyone wants to bother.

moraes@csri.toronto.EDU (Mark Moraes) (05/11/89)

We had a similar problem here - a lot of people wanted their icon
pixmaps, and their icon geometry, and didn't appreciate being told to
use -xrm. Eventually, I added two options to the toolkit for -ip
(iconPixmap) and -ig (iconGeometry). They've been seen to work for
people around here on Sun3s running SunOS3.5.

Since adding these to Xt would change a standard interface, this fix is
most certainly not official, and is unlikely to become official. Fair
warning - keep the old source RCS'ed or suchlike in case this interferes
with official fixes.

Adding them to the toolkit does mean that all toolkit applications get
these options, once you recompile half the world.

I've tried to keep the change as small as possible - the code for the
StrToPixmap converter is straight from Xmu.

I've documented the two options in the xterm manual, which as far as i
can tell is the only place the official Xt options are documented.
(and the Xt programming manual, I guess)

Reasons:
	icongeometry option is handy and consistent with the popular X
method for specifying locations - using xrm is more cumbersome.

	iconpixmap is handy when using the application in another
situation, where you want to tell a difference from it's normal mode
of operation - for example, we have a simple application called xspell
which invokes ispell -a in an xterm (and a small awk script to
postprocess the output of ispell and make it more readable), which
many of us like leaving around on the desktop iconified. It's handy to
be able to specify the pixmap in the script. Similarly, I know people
who start up rn in an xterm, mail in an xterm, etc.

*** /tmp/,RCSt1a23158	Fri Jan 20 01:12:09 1989
--- Converters.c	Fri Jan 20 01:11:13 1989
***************
*** 104,109
  static void CvtStringToInt();
  static void CvtStringToShort();
  static void CvtStringToUnsignedChar();
  static void CvtStringToPixel();
  
  /*ARGSUSED*/

--- 104,110 -----
  static void CvtStringToInt();
  static void CvtStringToShort();
  static void CvtStringToUnsignedChar();
+ static void CvtStringToPixmap();
  static void CvtStringToPixel();
  
  /*ARGSUSED*/
***************
*** 257,262
  };
  
  
  /*ARGSUSED*/
  static void CvtStringToPixel(args, num_args, fromVal, toVal)
      XrmValuePtr args;

--- 258,267 -----
  };
  
  
+ #ifndef BITMAPDIR
+ #define BITMAPDIR "/usr/include/X11/bitmaps"
+ #endif
+ 
  /*ARGSUSED*/
  static void CvtStringToPixmap(args, num_args, fromVal, toVal)
      XrmValuePtr args;
***************
*** 258,263
  
  
  /*ARGSUSED*/
  static void CvtStringToPixel(args, num_args, fromVal, toVal)
      XrmValuePtr args;
      Cardinal    *num_args;

--- 263,324 -----
  #endif
  
  /*ARGSUSED*/
+ static void CvtStringToPixmap(args, num_args, fromVal, toVal)
+     XrmValuePtr args;
+     Cardinal    *num_args;
+     XrmValuePtr	fromVal;
+     XrmValuePtr	toVal;
+ {
+     static Pixmap pixmap;
+     char *name = (char *)fromVal->addr;
+     Screen *screen;
+     static char* bitmap_file_path = NULL;
+     char filename[MAXPATHLEN];
+     static XColor bgColor = {0, 0, 0, 0};
+     static XColor fgColor = {0, ~0, ~0, ~0};
+     int width, height, xhot, yhot;
+ 
+     if (*num_args != 1)
+      XtErrorMsg("wrongParameters","cvtStringToPixmap","XtToolkitError",
+              "String to pixmap conversion needs screen argument",
+               (String *)NULL, (Cardinal *)NULL);
+ 
+     screen = *((Screen **) args[0].addr);
+ 
+     if (bitmap_file_path == NULL) {
+ 	XrmName xrm_name[2];
+ 	XrmClass xrm_class[2];
+ 	XrmRepresentation rep_type;
+ 	XrmValue value;
+ 	xrm_name[0] = XrmStringToName( "bitmapFilePath" );
+ 	xrm_name[1] = NULL;
+ 	xrm_class[0] = XrmStringToClass( "BitmapFilePath" );
+ 	xrm_class[1] = NULL;
+ 	if (XrmQGetResource( XtDatabase(DisplayOfScreen(screen)),
+ 			     xrm_name, xrm_class, &rep_type, &value )
+ 	    && rep_type == XrmStringToQuark(XtRString))
+ 	    bitmap_file_path = value.addr;
+ 	else
+ 	    bitmap_file_path = BITMAPDIR;
+     }
+ 
+     if ( name[0] == '/' || name[0] == '.' )
+  	strcpy( filename, name );
+     else
+ 	sprintf( filename, "%s/%s", bitmap_file_path, name );
+ 
+     if (XReadBitmapFile( DisplayOfScreen(screen), RootWindowOfScreen(screen),
+ 			 filename, &width, &height, &pixmap, &xhot, &yhot )
+ 	!= BitmapSuccess) {
+ 	XtStringConversionWarning( name, "Pixmap" );
+ 	return;
+     }
+ 
+     done(&pixmap, Pixmap);
+ }
+ 
+ 
+ /*ARGSUSED*/
  static void CvtStringToPixel(args, num_args, fromVal, toVal)
      XrmValuePtr args;
      Cardinal    *num_args;
***************
*** 828,833
  	screenConvertArg, XtNumber(screenConvertArg));
      Add(XtQString,  XtQInt,         CvtStringToInt,	    NULL, 0);
      Add(XtQString,  XtQPosition,    CvtStringToShort,       NULL, 0);
      Add(XtQString,  XtQPixel,       CvtStringToPixel,       
  	colorConvertArgs, XtNumber(colorConvertArgs));
      Add(XtQString,  XtQShort,       CvtStringToShort,       NULL, 0);

--- 889,896 -----
  	screenConvertArg, XtNumber(screenConvertArg));
      Add(XtQString,  XtQInt,         CvtStringToInt,	    NULL, 0);
      Add(XtQString,  XtQPosition,    CvtStringToShort,       NULL, 0);
+     Add(XtQString,  XtQPixmap,      CvtStringToPixmap,      
+ 	screenConvertArg, XtNumber(screenConvertArg));
      Add(XtQString,  XtQPixel,       CvtStringToPixel,       
  	colorConvertArgs, XtNumber(colorConvertArgs));
      Add(XtQString,  XtQShort,       CvtStringToShort,       NULL, 0);
*** /tmp/,RCSt1a23158	Fri Jan 20 01:12:14 1989
--- Initialize.c	Fri Jan 20 01:11:18 1989
***************
*** 62,67
  {"-foreground",	"*foreground",	XrmoptionSepArg,	(caddr_t) NULL},
  {"-geometry",	".geometry",	XrmoptionSepArg,	(caddr_t) NULL},
  {"-iconic",	".iconic",	XrmoptionNoArg,		(caddr_t) "on"},
  {"-name",	".name",	XrmoptionSepArg,	(caddr_t) NULL},
  {"-reverse",	"*reverseVideo", XrmoptionNoArg,	(caddr_t) "on"},
  {"-rv",		"*reverseVideo", XrmoptionNoArg,	(caddr_t) "on"},

--- 62,74 -----
  {"-foreground",	"*foreground",	XrmoptionSepArg,	(caddr_t) NULL},
  {"-geometry",	".geometry",	XrmoptionSepArg,	(caddr_t) NULL},
  {"-iconic",	".iconic",	XrmoptionNoArg,		(caddr_t) "on"},
+ {"-igeometry",	".iconGeometry",XrmoptionSepArg,	(caddr_t) NULL},
+ {"-ipixmap",	".iconPixmap",	XrmoptionSepArg,	(caddr_t) NULL},
+ #if 0
+ /* These are clearer, but the above two meanless typing and faster matching */
+ {"-icongeometry", ".iconGeometry",XrmoptionSepArg,	(caddr_t) NULL},
+ {"-iconpixmap",	".iconPixmap",	XrmoptionSepArg,	(caddr_t) NULL},
+ #endif
  {"-name",	".name",	XrmoptionSepArg,	(caddr_t) NULL},
  {"-reverse",	"*reverseVideo", XrmoptionNoArg,	(caddr_t) "on"},
  {"-rv",		"*reverseVideo", XrmoptionNoArg,	(caddr_t) "on"},
*** /tmp/,RCSt1a23158	Fri Jan 20 01:12:18 1989
--- Shell.c	Fri Jan 20 01:11:25 1989
***************
*** 416,421
  
  static XtResource topLevelResources[]=
  {
  	{ XtNiconName, XtCIconName, XtRString, sizeof(caddr_t),
  	    Offset(topLevel.icon_name), XtRString, (caddr_t) NULL},
  	{ XtNiconic, XtCIconic, XtRBoolean, sizeof(Boolean),

--- 416,423 -----
  
  static XtResource topLevelResources[]=
  {
+ 	{ XtNiconGeometry, XtCGeometry, XtRString, sizeof(caddr_t), 
+ 	    Offset(topLevel.icon_geometry), XtRString, (caddr_t) NULL},
  	{ XtNiconName, XtCIconName, XtRString, sizeof(caddr_t),
  	    Offset(topLevel.icon_name), XtRString, (caddr_t) NULL},
  	{ XtNiconic, XtCIconic, XtRBoolean, sizeof(Boolean),
***************
*** 650,655
  	    w->topLevel.icon_name = XtNewString(w->core.name);
  	} else {
  	    w->topLevel.icon_name = XtNewString(w->topLevel.icon_name);
  	}
  }
  

--- 652,673 -----
  	    w->topLevel.icon_name = XtNewString(w->core.name);
  	} else {
  	    w->topLevel.icon_name = XtNewString(w->topLevel.icon_name);
+ 	}
+ 	if(w->topLevel.icon_geometry != NULL) {
+ 	    int ix, iy, iw, ih;
+ 	    int bitmask;
+ 
+ 	    for(ix = 0; XtScreen(w) != ScreenOfDisplay(XtDisplay(w), ix); ix++)
+ 	    	;
+ 
+ 	    bitmask = XGeometry(XtDisplay(w), ix, w->topLevel.icon_geometry,
+ 	    	"", 0, 0, 0, 0, 0, &ix, &iy, &iw, &ih);
+ 
+ 	    if (bitmask & (XValue | YValue)) {
+ 	    	w->wm.wm_hints.flags |= IconPositionHint;
+ 		w->wm.wm_hints.icon_x = ix;
+ 		w->wm.wm_hints.icon_y = iy;
+ 	    }
  	}
  }
  
*** /tmp/,RCSt1a23158	Fri Jan 20 01:12:22 1989
--- Shell.h	Fri Jan 20 01:11:28 1989
***************
*** 83,88
  #define XtNinitialState	"initialState"
  #define XtCInitialState	"InitialState"
  #define XtNgeometry	"geometry"
  #define XtCGeometry	"Geometry"
  #define XtNminWidth	"minWidth"
  #define XtCMinWidth	"MinWidth"

--- 83,89 -----
  #define XtNinitialState	"initialState"
  #define XtCInitialState	"InitialState"
  #define XtNgeometry	"geometry"
+ #define XtNiconGeometry "iconGeometry"
  #define XtCGeometry	"Geometry"
  #define XtNminWidth	"minWidth"
  #define XtCMinWidth	"MinWidth"
*** /tmp/,RCSt1a23158	Fri Jan 20 01:12:24 1989
--- ShellP.h	Fri Jan 20 01:11:31 1989
***************
*** 225,230
  typedef struct {
  	char	   *icon_name;
  	Boolean	    iconic;
  } TopLevelShellPart;
  
  typedef  struct {

--- 225,231 -----
  typedef struct {
  	char	   *icon_name;
  	Boolean	    iconic;
+ 	char	   *icon_geometry;
  } TopLevelShellPart;
  
  typedef  struct {
*** /tmp/,RCSt1a23561	Fri Jan 20 02:27:29 1989
--- xterm.man	Fri Jan 20 02:27:08 1989
***************
*** 368,373
  .B \-iconic
  This option indicates that \fIxterm\fP should ask the window manager to 
  start it as an icon rather than as the normal window.
  .SH "X DEFAULTS"
  The program understands all of the core X Toolkit resource names and
  classes as well as:

--- 368,389 -----
  .B \-iconic
  This option indicates that \fIxterm\fP should ask the window manager to 
  start it as an icon rather than as the normal window.
+ .TP 8
+ .B \-igeometry \fIgeometry\fP
+ Specifies the prefered size and position of the application when iconified.
+ It is not necessarily obeyed by all window managers. It corresponds to the
+ .B "iconGeometry (\fPclass\fB IconGeometry)"
+ resource.
+ .TP 8
+ .B \-ipixmap \fIpixmapfile\fP
+ This option specifies the pixmap the window manager should use as an icon
+ for the application. 
+ It is not necessarily obeyed by all window managers. It corresponds to the
+ .B "iconPixmap (\fPclass\fB IconPixmap)"
+ resource. The 
+ .I pixmapfile
+ is the name of a file containing an X bitmap that can be loaded by the
+ window manager.
  .SH "X DEFAULTS"
  The program understands all of the core X Toolkit resource names and
  classes as well as:
***************
*** 371,380
  .SH "X DEFAULTS"
  The program understands all of the core X Toolkit resource names and
  classes as well as:
- .TP 8
- .B "iconGeometry (\fPclass\fB IconGeometry)"
- Specifies the prefered size and position of the application when iconified.
- It is not necessarily obeyed by all window managers.
  .TP 8
  .B "termName (\fPclass\fB TermName)"
  Specifies the terminal type name to be set in the TERM environment variable.

--- 387,392 -----
  .SH "X DEFAULTS"
  The program understands all of the core X Toolkit resource names and
  classes as well as:
  .TP 8
  .B "termName (\fPclass\fB TermName)"
  Specifies the terminal type name to be set in the TERM environment variable.

dave@cs.wisc.edu (Dave Cohrs) (05/14/89)

In article <3284@orca.WV.TEK.COM> dougb@mustang.WV.TEK.COM (Doug Becker) writes:
>     Is there any reason xterm doesn't support icon bitmaps under 
>X11, as it did in X10 (i.e. as in xterm -ib _bitmap_ and 
>xterm*iconBitmap: _bitmap_)?

There are at least two solutions to this that require no hacking:

1) use twm and tell it what you want your icon for xterm to be
2) When you start xterm, give it an "-xrm *iconPixmap: /some/filename"
   option.

These work with xterm and twm under X.V11R3.  I can't say what happens
with other window mgrs.

--
Dave Cohrs
+1 608 262-6617                        UW-Madison Computer Sciences Department
dave@cs.wisc.edu                       ...!{harvard,rutgers,ucbvax}!uwvax!dave

marco@buengc.BU.EDU (Marco Zelada) (05/14/89)

In article <BOB.89May10003636@monster.cis.ohio-state.edu> Bob Sutterfield <bob@cis.ohio-state.edu> writes:
>In article <3284@orca.WV.TEK.COM> nobody@orca.WV.TEK.COM (-for inetd server command) writes:
>   The reason I ask is that there are a few people here who have
>   become very attached to their X10 icon bitmaps, and who are
>   reluctant to convert to X11 because of their apparent absence.

	My problem with X11 is the window manager uwm. Is it possible to get uwm
under X11 to use the same kind of titlebars it used under X10 ?

	Is there any other window manager that is flexible enough for me to
configure it to work as close as possible to the X10 uwm ?

	Sorry if this sounds way to basic, but I am just getting started
at this.
-- 
______________________________________________________________________________
| Name:	Marco Zelada, VLSI CAD Engineer	  | Tel: 617 353 9882, Fax: 353 6322 |	
| Lab:	VLSI CAD Laboratory               | E-mail: marco@buengc.bu.edu      |	
| Dept: Electrical & Computer Engineering | US-Mail: 44 Cummington St.	     |
| Org:  Boston University                 |	     Boston MA, 02215	     |
------------------------------------------------------------------------------