From:	SMTP%"dgm@cronus.colorado.edu" 25-MAY-1994 17:18:06.39
To:	EVERHART
CC:	
Subj:	RE: Reading the DECterm title bar Was: Changing the DECterm title bar

X-Newsgroups: comp.os.vms
Subject: RE: Reading the DECterm title bar Was: Changing the DECterm title bar
Message-ID: <1994May24.133258.1500@buckie.hsc.colorado.edu>
From: dgm@cronus.colorado.edu (Dom Maddalone)
Date: 24 May 94 13:32:57 MST
Reply-To: dgm@cronus.colorado.edu
Distribution: world
Organization: University Physicians, Inc., Denver, Colorado
Nntp-Posting-Host: athena.hsc.colorado.edu
Lines: 52
To: Info-VAX@CRVAX.SRI.COM
X-Gateway-Source-Info: USENET

In article <1994May24.111623.1498@buckie.hsc.colorado.edu>, dgm@cronus.colorado.edu (Dom Maddalone) writes:
>In article <2rfmju$66f@nntpd.lkg.dec.com>, kleinsorge@star.enet.dec.com (Fred Kleinsorge) writes:
>>
>>>On a close subject: is it possible to READ the current title?
>>
>>There is no way to do this on a DECterm.  As Jerry said, you can
>>write some X11 code to get it, if you can find the ID of the window.
>
>    This may do it if executed from the DECterm in question.
>

   Hey, V2.0 already.  This one won't stack dump.

#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>

main(int argc, char *argv[])
{
    Display       *display;
    Window         focus, root, parent, *children;
    int            revert_to, nchildren;
    XTextProperty  text_prop;
    register       status;

    if (!(display = XOpenDisplay(NULL))) {
	fprintf(stderr,"can't open display\n");
	exit(0);
    }

    XGetInputFocus(display,&focus,&revert_to);
    do {
        XGetWMName(display,focus,&text_prop);
	if (!text_prop.value) {
	    status = XQueryTree(display,focus,&root,&parent,&children,
		    &nchildren);
	    XFree(children);
	    if (!status) {
		printf("Bzzzt -- bad call to XQueryTree\n");
		exit(0);
	    }
	    focus = parent;
	}
    } while (!text_prop.value);

    XCloseDisplay(display);
    printf("%s\n",text_prop.value);
    exit(0);
}

  Dom Maddalone, dgm@cronus.colorado.edu
  System Administrator, University Physicians, Inc., Denver

