From:	SMTP%"tihor@acf4.NYU.EDU"  9-NOV-1990 13:50:06.75
To:	tihor@acf4.NYU.EDU
CC:	
Subj:	Re: ICON Names

Received: from acf4.NYU.EDU by ACF7.NYU.EDU with SMTP; 
          Fri, 9 Nov 1990 13:49:56 EST
Received: by acf4.NYU.EDU (5.61/1.34)
	id AA18314; Fri, 9 Nov 90 13:46:58 -0500
Date: Fri, 9 Nov 90 13:46:58 -0500
From: tihor@acf4.NYU.EDU (Stephen Tihor)
Message-Id: <9011091846.AA18314@acf4.NYU.EDU>
To: tihor@acf4.NYU.EDU
Subject: Re: ICON Names
Newsgroups: comp.os.vms
In-Reply-To: article <2814.27392067@miavx1.acs.muohio.edu> of 8 Nov 90 09:07 EST

/* acf4:comp.os.vms / pemurray@miavx1.acs.muohio.edu (Peter Murray) /  9:07 am  Nov  8, 1990 */
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
/* ---------- */

