[comp.windows.x.motif] WM closing sub-top-level windows

andrew@sparky.uwaterloo.ca (Andrew MacLean) (06/22/91)

I am creating an X11 R3 client using the motif toolkit. This client
will contain many top level widgets, each being independent of the 
other with the one main window. (ie:


                      ----------
                      |        |
                      | main   |
                      | window |
          /-----------|        |-----------\
          |           ----------            |
          |                |                |
          |                |                |
          |                |                |
          |                |                |
     ----------       ----------         ----------
     |        |       |        |         |        |
     | sub    |       | sub    |         | sub    |
     | window |       | window |         | window |
     |        |       |        |         |        |
     ----------       ----------         ----------


The problem that I am having is that since each is its own window,
they each can be killed by the window manager using the pulldown
menu option 'Quit window'. (Note. I am using the olwm, and am also
therefore using the Open Look server on a Sparc 1+.)

Is there any way (in R3) to have the window manager tell my main program
that one of the sub-top-level windows has been closed? If there isn't,
is there a way to remove the quit option from the window frame surrounding
the sub-top-level window?

Just to inform you of the options I have tried, I have tried the following:

	XtAddEventHandler(widget, StructureNotifyMask, False, destroy_proc, NULL);

I tried this, because it apparently traps Destroy_Window events. Unfortunately
it did not inform my procedure of the destroy request.

Next I tried.
	XmAddProtocolCallback(widget, WM_DELETE_WINDOW, destroy_proc, NULL);

yet after close examination of the manual, I reaslized that this is an
option implemented in R4.

Any help would be greatly appreciated.
Thanks in advance.
andrew
-- 
Andrew MacLean
Civil Engineering
University of Waterloo
andrew@sparky.uwaterloo.ca

jdart@telesoft.com (Jon Dart @pulsar) (06/26/91)

If you are using mwm, you can remove the Close item from the
window manager menu by settting the XmNmwmFunctions resource
on the shell widget.  I'm not sure about other window managers.

As for getting notified when top-level windows are destroyed,
I believe you are on the right track using XmAddProtocolCallback.
It is true that this does not exist in X11R3, but the same effect
can be accomplished by using XChangeProperties.  You need to
add WM_DELETE_WINDOW to the WM_PROTOCOLS property on the shell
window.  You must also install an event handler to process
ConfigureNotify events on the shell window.  


-- 
Jon Dart              | 5959 Cornerstone Ct. W., | jdart@telesoft.com
Sr. Software Engineer | San Diego, CA 92121      | ..uscd.edu!
TeleSoft, Inc.        | (619)-457-2700           | telesoft.com!jdart

carroll@cs.uiuc.edu (Alan M. Carroll) (06/27/91)

In article <1991Jun26.040858.23338@telesoft.com>, jdart@telesoft.com (Jon Dart @pulsar) writes:
> As for getting notified when top-level windows are destroyed,
> I believe you are on the right track using XmAddProtocolCallback.

I've already replied by email, but I wanted to follow up this posting
because I believe that it is the wrong approach. What I recommened to
the original poster is to tap into the destroy widget callback. You
pass what you need to the callback or use the XmNuserData resource to
allow the callback to get to the right information. This has the added
benefit that if for some reason your program decides to toast off the
window, it just has to do an XtDestroyWidget(), knowning that teh
callback will take care of the details. I have a working program that
uses this method, and it has turned out very well.

-- 
Alan. Carroll          <-- Another casualty of applied metaphysics
Epoch Development Team   
Urbana Il.               "I hate shopping with the reality-impaired" - Susan