From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX"  1-AUG-1989 16:45
To:	MRGATE::"ARISIA::EVERHART"
Subj:	changing terminal and icon titles under decwindows

Message-Id:  <8908012009.AA03573@crdgw1.ge.com>
Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Tue,  1 AUG 89 12:48:44 PDT
Received: from icdc.llnl.gov by KL.SRI.COM with TCP; Tue, 1 Aug 89 12:33:48 PDT
Date: Tue, 1 Aug 89 12:32 PDT
From: SHECTMAN@seti.llnl.gov
Subject: changing terminal and icon titles under decwindows
To: info-vax@kl.sri.COM
X-Vms-To: IN::"info-vax@kl.sri.com"

the following brief c program changes the title area of the
terminal window and its icon under decwindows.  I dont know
where it originated, I got it from a guy who got it from a
gal who got it from a bulletin board from somewhere supposedly.

The only caveat is that your system runs decwindows and has 
the appropriate includes in the directory decw$include:  


CHANGE_TITLE.c
=============================================================
/* modifies window title of DecTerm windows */

#include <decw$include/Xlib.h>
#include <string.h>
#include <stdio.h>

Display * dpy;
int	screen;
Window  root;

Window	get_parent();

main(argc, argv)
    int argc;
    char **argv;
{

int	dummy;
Window	topwin;
Window	cur_focus;

if (argc < 2)
    error_exit("Must suply a name.",1);

dpy = XOpenDisplay("");
if (dpy == NULL)
    error_exit("Cannot open display.",1);

screen = DefaultScreen(dpy);
root = RootWindow(dpy, screen);

XGetInputFocus(dpy, &cur_focus, &dummy);
if ((cur_focus == NULL) || (cur_focus == root))
    error_exit("The window must have input focus.",1);

topwin = get_parent(get_parent(cur_focus));

if ((topwin == root) || (topwin == NULL))
    error_exit("Window with input focus most likely not a terminal window.",1);

XStoreName(dpy, topwin, argv[1]);
XSetIconName(dpy,topwin,argv[1]);
XCloseDisplay(dpy);

return(1);
}



Window get_parent(win)

Window win;
{

Window parent;
Window * child;
int    nchildren;
Window root;
char   pname[80];

if (XQueryTree (dpy, win, &root, &parent, &child, &nchildren))
    return(parent);
else
    error_exit("XQueryTree failed.",1);
}

error_exit(str, code)

char	*str;
int	code;
{
fprintf(stderr,str);
exit(code);
}

