From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX"  8-NOV-1990 21:09:04.57
To:	MRGATE::"ARISIA::EVERHART"
CC:	
Subj:	Re: ICON Names

Received:  by crdgw1.ge.com (5.57/GE 1.76)
	 id AA24173; Thu, 8 Nov 90 20:56:44 EST
Received: From UCBVAX.BERKELEY.EDU by CRVAX.SRI.COM with TCP; Thu,  8 NOV 90 06:37:52 PDT
Received: by ucbvax.Berkeley.EDU (5.63/1.42)
	id AA16772; Thu, 8 Nov 90 06:25:37 -0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews
	for info-vax@kl.sri.com (info-vax@kl.sri.com)
	(contact usenet@ucbvax.Berkeley.EDU if you have questions)
Date: 8 Nov 90 14:07:47 GMT
From: swrinde!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!ohstpy!miavx1!pemurray@ucsd.edu  (Peter Murray)
Subject: Re: ICON Names
Message-Id: <2814.27392067@miavx1.acs.muohio.edu>
References: <42840@mips.mips.COM>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com

In article <42840@mips.mips.COM>, robishaw@mips.COM (Gary Robishaw - Loral Rolm Mil-Spec) writes:
> Does anyone out there know how to set
> the icon name from the DCL line? I saw
> something about the title bar that
> had some vague references to the icon.
> (At least I couldn't make it work [:) )

This is a copy of a C program that was posted to the net a few weeks ago.
I compiled it under 5.3-1 and 5.4 and had no problems.  I did have to link
in some libraries to make it run.  You may need this .COM file or not:

$ LINK  SYS$INPUT/OPT
icon
SYS$SHARE:VAXCRTL/SHARE
SYS$SHARE:DECW$XLIBSHR/SHARE
SYS$SHARE:DECW$DWTLIBSHR/SHARE
$ EXIT


And now, here's the source for ICON.C ...
/*
**
**  FACILITY:
**
**      wmpropsII-- set window manager properities for the window with input
**      focus. Based on a program written at Digital.
**
**  ABSTRACT:
**
**      Given two strings, changes the window name and icon name for the window
**	with input focus. [icon only version - jmi]
**
**  AUTHORS:
**
**      M. Erik Husby
**      Access Technology, Inc.
**      Two Natick Executive Park
**      Natick, MA. 01760
**      (508)655-9191
**
**      Modified by J.M. Ivler  jmi@dac.mdcbbs.com
**            Douglas Aircraft
**            (213) 497-5147
**
**
**      No Rights reserved.  This program may be freely copied and distributed.
**
**      No promise is made that it works.
**
**
**
**  CREATION DATE:     Friday 16-JUN-1989 09:03 AM
**
**  MODIFICATION HISTORY:
**
**   21-Jul-1989    jmi     icon only (to be used with the set host)
**
**--
**/

/*
**
**  INCLUDE FILES
**
**/

#include <decw$include:xlib.h>
#include <decw$include:xutil.h>
#include <decw$include:xatom.h>
#include <stdio.h>

/*
**++
**  FUNCTIONAL DESCRIPTION:
**
**      Given a string, changes the name of the window with input focus.
**
**  FORMAL PARAMETERS:
**
**      On the command line, the first string is the window name, the second
**      is the icon name.
**
**    ***** Changed... only supports the name of the ICON *****
**
**
**  IMPLICIT INPUTS:
**
**      none
**
**  IMPLICIT OUTPUTS:
**
**      none
**
**  FUNCTION VALUE:
**
**      none
**
**  SIDE EFFECTS:
**
**      Your palms get hairy... (just kidding :-) )
**
**--
**/
main(argc, argv)
int     argc;
char    *argv[];
{
    Display *dpy;
    Window  winCurrent;
    Window  winTop;
    Window  get_parent( Display *, Window);
    int dummy;
    void TranslateEscapes( char *, char *);
    char azIcon[512];

    if ((dpy = XOpenDisplay("")) != NULL) {

        /* Find the window with input focus. */
        XGetInputFocus(dpy, &winCurrent, &dummy);
        if ( !( (winCurrent == NULL) ||
                (winCurrent == RootWindow(dpy, DefaultScreen(dpy)) ) ) ){

            /* Now find the parent of its parent which will be the window   */
            /* created by the window manager around the window's shell. */
            winTop = get_parent(dpy, get_parent(dpy, winCurrent));
            if (!( (winTop == NULL) ||
                   (winTop == RootWindow(dpy, DefaultScreen(dpy)) ) ) ) {

                /* This changes the icon name. */
                TranslateEscapes(azIcon, argv[1]);
                XChangeProperty(
                    dpy,               /* The display containing the window. */
                    winTop,            /* The window whose property to be changed. */
                    XA_WM_ICON_NAME,   /* The property to be changed. */
                    XA_STRING,         /* The type of the property. */
                    8,                 /* Property is 8bit items. */
                    PropModeReplace,   /* The type of change being done. */
                    azIcon,            /* Address of string. */
                    strlen(azIcon)    /* Length of string. */
                    );
            }
            else {
                printf("Window with input focus most likely not a terminal window\n");
            }
        }
        else {
            printf("No window with input focus!\n");
        }

        /* Close the display. */
        XCloseDisplay(dpy);
    }
    else {
        printf("Can't open display\n");
    }
}
/*
**++
**  FUNCTIONAL DESCRIPTION:
**
**      Gets the parent window of the specified window.  Returns NULL if no
**      parent.
**
**
**  FORMAL PARAMETERS:
**
**      The window in question.
**
**  IMPLICIT INPUTS:
**
**      none
**
**  IMPLICIT OUTPUTS:
**
**      none
**
**  FUNCTION VALUE:
**
**      The parent window if one exists.
**
**  SIDE EFFECTS:
**
**      none
**
**--
**/
static Window   get_parent( Display *dpy, Window winChild)
{
    Window winParent;
    Window *winChildren;
    int nChildren;
    Window winRoot;

    XQueryTree( dpy, winChild, &winRoot, &winParent, &winChildren, &nChildren);
    return winParent;
}
/*
**++
**  FUNCTIONAL DESCRIPTION:
**
**
**      TranslateEscapes -- copys a string translating escape sequences.
**
**  FORMAL PARAMETERS:
**
**      The source string and the destination string.
**
**  IMPLICIT INPUTS:
**
**      none
**
**  IMPLICIT OUTPUTS:
**
**      none
**
**  FUNCTION VALUE:
**
**      none
**
**  SIDE EFFECTS:
**
**      none
**
**--
**/
void TranslateEscapes(
    char *pDst,
    char *pSrc)
{

    while (*pSrc) {
        if (*pSrc == '\\') {
            pSrc++;
            if (*pSrc == 'n') {
                *pDst = '\n';
            }
            else if (*pSrc == 't') {
                *pDst = '\t';

            }
            else if (*pSrc == 't') {
                *pDst = '\t';
            }
            else if (*pSrc == 'v') {
                *pDst = '\v';
            }
            else if (*pSrc == 'b') {
                *pDst = '\b';
            }
            else if (*pSrc == 'r') {
                *pDst = '\r';
            }
            else if (*pSrc == 'f') {
                *pDst = '\f';
            }
            else if (*pSrc == '\\') {
                *pDst = '\\';
            }
            else if (*pSrc == '\'') {
                *pDst = '\'';
            }
            else if (*pSrc == '"') {
                *pDst = '\"';
            }
            else {
                *pDst = *pSrc;
            }
        }
        else {
            *pDst = *pSrc;
        }
        pDst++;
        pSrc++;
    }
    /* And finally the null byte */
    *pDst = *pSrc;
}

-- 
Peter Murray	                         176 Thompson Hall, Oxford, Ohio  45056
ACS Consultant                                           pemurray@miavx1.bitnet
APSVAX/APSTWR/APSRISC Manager                     pmurray@apsvax.aps.muohio.edu
Miami University                       NeXT Mail:  pmurray@next4.acs.muohio.edu

