[comp.windows.x] Traversing a X11 window tree

chris@bwilab3.UUCP (Chris Curtin) (09/22/90)

Hi,
  I am looking for a way to figure out the window id of an xterm or hpterm
window. What I would like to do is XLIB graphics in the hpterm window or
create a child window with the hpterm as its parent window.

  I have used xwininfo to observe the window tree, but am not sure how to
traverse the tree, or really how to know when I have found the window tree
of the hpterm.

  I am running Motif window manager and using hpterm, but information about
how to do it with an xterm would be very helpful.

Thanks in advance.

Chris Curtin

 ..uunet!gatech!galbp!bwilab3!chris 

mouse@LARRY.MCRCIM.MCGILL.EDU (09/23/90)

> I am looking for a way to figure out the window id of an xterm or
> hpterm window.  What I would like to do is XLIB graphics in the
> hpterm window or create a child window with the hpterm as its parent
> window.

> I have used xwininfo to observe the window tree, but am not sure how
> to traverse the tree, or really how to know when I have found the
> window tree of the hpterm.

Traversing the tree is relatively easy.  You start with the root window
and do an XQueryTree on it to get the window IDs of its children, then
recurse down the tree.

How to tell when you have the window you want is the sticky part.
Finding an hpterm window is presumably not that hard; the really
difficult part is trying to tell *which* hpterm window you want.
Presumably you want the window from within which your program was
started - but such a window may not even exist, and if it does, the
association between it and anything you have access to is spread
through a half-dozen places, most of which you do not have access to.

I notice that xterm creates an environment variable WINDOWID which is,
at least in a simple test I just ran, the ID of the xterm window (in
decimal, interestingly); hpterm may do something similar.  Of course,
this cannot be entirely trusted, because the user may change or destroy
the variable, but it may be of some use.

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu

ekberg@ti-csl.csc.ti.COM (09/24/90)

There are programs of the form xls* that can be very useful - the one you need
is xlswins.  This program generates an indented list of the window hierarchy
showing the window ID and it's name (if it has one).  When you obtain the
window ID you are looking for, use xwininfo to get more information about it.

  -- tom (aisle C-4Q), ekberg@csc.ti.com