[comp.windows.open-look] Closing Autonomous Windows

caughey@ale.UVic.CA (Dave Caughey) (06/12/91)

I have developed a number of X applications which spawn other
processes.  I would like to be able to control those spawned-processes'
windows from my applications.

For example, by clicking on a button, I spawn an xterm.  On subsequent
clicks, I would like to bring it to the front by calling XRaiseWindow,
or close it with XIconifyWindow.

Now, I presume that (one way) I can get the window ID of an autonomous
window is to have my application cal XGrabPointer, and then clicking on
the target window.

It seems that I could then call XIconifyWindow and thus close it.  The
routine returns a code indicating success in sending the message, but
nothing happens.

Now, O'Reilly states that "window managers may elect to receive this
message" (Vol 2, page 284).

So I have a couple questions:

	1) Does OLWM recognize such requests?
		If so, what am I doing wrong?
		If not, can it be made to?

	2) Does TWM?

	3) Am I way off-base in my approach to this problem?


The development environment is as follows: 
    OpenWindows 2.0, OLWM, SparcStation, and (sigh) DevGuide

Thanks much,
Dave
___________________________________________________________________________
Dave Caughey				Dept. of Elec. & Comp. Engineering
caughey@sirius.uvic.ca			P.O. Box 3055
					University of Victoria		  
"10 million lemmings can't be wrong"	Victoria, B.C., CANADA V8W 3P6     	

Stuart.Marks@Eng.Sun.COM (Stuart Marks) (06/15/91)

    Now, I presume that (one way) I can get the window ID of an autonomous
    window is to have my application cal XGrabPointer, and then clicking on
    the target window.
    
    It seems that I could then call XIconifyWindow and thus close it.  The
    routine returns a code indicating success in sending the message, but
    nothing happens.

The problem is that the window has been reparented.  I assume that you're
looking at the subwindow field of the button click event.  This window
will be the window manager's frame window, not the client's top-level
window.  In order for XIconifyWindow() to work, it must be called with the
client's top-level window, not the window manager's window.

A simple way to find the client's top-level window given the window
manager frame is to call XmuClientWindow(dpy, frame); it will return the
ID of the client's top-level window.  To use it, include <X11/Xmu/Xmu.h>
in your program and link with -lXmu.

Unfortunately, we don't ship the Xmu library with OpenWindows 2, though
perhaps we should have.  You'll have to get it from the MIT distribution.

s'marks

Stuart W. Marks			ARPA: smarks@eng.sun.com
Windows & Graphics Software	UUCP: sun!smarks
Sun Microsystems, Inc.