arthur@media.uucp (Art Poley) (09/14/90)
This is most likely something that should be added to the Frequently Asked Questions list. The question being, How does one implement a destroy function similar to SunView's notify_interpose_destroy_func? This function would be called whenever the user quits the window (most likely from the window menu). Note that the implementation should work on a variety of window managers (mwm, twm, etc.). I've noticed that mwm seems to send an XClientMessageEvent to the application. The client message has an Atom name of WM_PROTOCOLS (found via XGetAtomName on the message_type field of the message). Twm, on the other hand, notes within its documentation that twm will send a WM_DELETE_WINDOW if the application has requested it through the WM_PROTOCOLS property. How does one do this? I'd appreciate anyones comments on how one goes about registering a destroy function. Thanks! -- -------------------------------------------------------------------------- Art Poley - Media Cybernetics Phone: (301)495-3305 (5964 FAX) Internet: arthur%media@uunet.uu.net UUCP: {uunet,hqda-ai}!media!arthur
rodman@hpcvlx.cv.hp.com (Steve Roderick) (09/29/90)
/ hpcvlx:comp.windows.x.motif / arthur@media.uucp (Art Poley) / 12:02 pm Sep 13, 1990 / This is most likely something that should be added to the Frequently Asked Questions list. The question being, How does one implement a destroy function similar to SunView's notify_interpose_destroy_func? This function would be called whenever the user quits the window (most likely from the window menu). Note that the implementation should work on a variety of window managers (mwm, twm, etc.). I've noticed that mwm seems to send an XClientMessageEvent to the application. The client message has an Atom name of WM_PROTOCOLS (found via XGetAtomName on the message_type field of the message). Twm, on the other hand, notes within its documentation that twm will send a WM_DELETE_WINDOW if the application has requested it through the WM_PROTOCOLS property. How does one do this? I'd appreciate anyones comments on how one goes about registering a destroy function. Thanks! -- -------------------------------------------------------------------------- Art Poley - Media Cybernetics Phone: (301)495-3305 (5964 FAX) Internet: arthur%media@uunet.uu.net UUCP: {uunet,hqda-ai}!media!arthur ----------
rodman@hpcvlx.cv.hp.com (Steve Roderick) (09/29/90)
OOPS, screwed up the last response! SORRY!
I just solved this same problem, actually others solved it for me.
topLevel = XtInitialize();
XtAddEventHandler(topLevel, StructureNotifyMask, TRUE, DestroyFunc, NULL);
void DestroyFunc(w, client_datam event)
Widget w;
caddr_t client_data;
XEvent *event;
{
if (event->type == WM_PROTOCOL && event->xclient.data[0] ==
WM_DESTROY_WINDOW)
/* WE ARE GONE */;
}
you better verify the atom names (I'm not positive on them)
WM_PROTOCOL == 33 && WM_DESTROY_WINDOW == 0x0064 (for sure)
(not sure on names)
may also need event->xclient.data.l[0] == 0x0064
------
Stephen Roderick
rodman@hpcvlx.cv.hp.com
(I just call 'em as I see 'em)
------