[comp.windows.x] Vendor Shell and WM_DELETE_WINDOW

jlv@ebt-inc.uucp (Jeffrey L. Vogel) (12/19/90)

I am trying to trap WM_DELETE_WINDOW messages.
My application uses the Motif 1.1 widget set, but, the part of the
code which will be doing the trapping actually does not use
any Motif widgets, just Xt Shell widgets.

The following code creates an Xt topLevelShellWidgetClass, and
registers callbacks for both XtNdestroyCallback and the 
WM_DELETE_WINDOW protocol.

It works fine.  When I ask for a delete request with either twm or mwm,
I get notified with a call to "HandleProperty".
"HandleDestroy", the destroy callback, is never called, because the
window is not deleted, as expected.

This program is compiled and linked without libXm.a.


   #include <X11/Intrinsic.h>
   #include <X11/Shell.h>
   #include <X11/StringDefs.h>

   static Arg shellargs[] = {
      {XtNmappedWhenManaged, (XtArgVal) False},
      {XtNborderWidth, (XtArgVal) 3},
      {XtNallowShellResize, (XtArgVal) False},
      {XtNwidth, (XtArgVal) 200},
      {XtNheight, (XtArgVal) 200} ,
/*      {XmNdeleteResponse, (XtArgVal) XmDO_NOTHING}   see below */
   };

   ...


   widget = XtAppCreateShell("foo", pg->inqClass(),
			     topLevelShellWidgetClass,
			     display, shellargs, XtNumber(shellargs));
   XtRealizeWidget(widget);

   delete_atom = XInternAtom(display, "WM_DELETE_WINDOW", FALSE);
   XSetWMProtocols(display, XtWindow(widget),
                   &delete_atom, 1);
   XtAddEventHandler(widget, 0, TRUE, HandleProperty, NULL);
   XtAddCallback(widget, XtNdestroyCallback, HandleDestroy, NULL);
   XtMapWidget(widget);

   XtAppMainLoop(context);

   ...


However, when I add this module to the rest of my code, which does
use Motif widgets (and links with libXm.a), all of a sudden, I find that
in addition to HandleProperty being called, HandleDestroy is
also being called.
This tells me that somehow, the widget is being destroyed, but I don't
know who is reponsible.

Further research shows that Motif redefines the vendorShell widget, which
topLevelShell is derived from.  I assume that the Motif vendor shell widget is 
responsible.  So, I uncommented the commented line above in shellargs, which
should tell the motif vendor shell not to destroy my widget.
Still, my widget was being destroyed and HandleDestroy was being called.


HELP ME:
  1) I either need to find out how to prevent the Motif vendor shell
     from redefining the Xt vendor shell, OR,

  2) I need to find out how to control the Motif Vendor Shell so that
     it does not destroy my widget, OR,

  3) I need to be told that my hypothesis is wrong and that I am doing
     something else wrong.

--------------------------------------------------------------------
| Jeff Vogel                    |  Lead Engineer                   |
| jlv%ebt-inc@uunet.uu.net      |  EBT Inc.                        |
| uunet!ebt-inc!jlv             |  One Richmond Square             |
| 401-421-9550                  |  Providence, RI 02906 	   |       






From jlv Tue Dec 18 07:27:21 1990
To: tcl
Subject: X Source


I decided I needed the X Source on-line.
Already since we removed it, I've logged onto brown about 5 times to
read X Source code.

SO, for the time being, I have installed X SOurce on my machine.
I kept it at the minimum, removing things like Postscript files.

-jeff


From jlv Tue Dec 18 07:31:15 1990
To: VERKADE@CTSS.CO.UK (Herman Verkade)
In-reply-to: VERKADE@CTSS.CO.UK's message of 16 Dec 90 20:10:56 GMT
Subject: Print Screen source code needed

   From: VERKADE@CTSS.CO.UK (Herman Verkade)
   Newsgroups: comp.windows.x
   Date: 16 Dec 90 20:10:56 GMT
   Organization: CompuThoughts Software Solutions (UK) Ltd.

   Has anybody got some source code which captures part of the screen and creates
   a dump in postscript or whatever other format?

   Herman Verkade
   CompuThoughts Software Solutions (UK) Ltd.


You might look at the source code for xwd, which dumps a screen into
x window sump format, and xpr, which can convert xwd to postscript.

--------------------------------------------------------------------
| Jeff Vogel                    |  Lead Engineer                   |
| jlv%ebt-inc@uunet.uu.net      |  EBT Inc.                        |
| uunet!ebt-inc!jlv             |  One Richmond Square             |
| 401-421-9550                  |  Providence, RI 02906 	   |