mwette@mr-ed.jpl.nasa.gov (Matt Wette) (12/04/90)
The twm man page states that the "f.delete" command will send a `WM_DELETE_WINDOW' command to a client. I would like to get my Xt-coded client to receive and act on this message. Any help getting me going would be appreciated. Matt -- _________________________________________________________________ Matthew R. Wette | Jet Propulsion Laboratory, 198-326 mwette@csi.jpl.nasa.gov | 4800 Oak Grove Dr, Pasadena,CA 91109 -----------------------------------------------------------------
mwette@mr-ed.jpl.nasa.gov (Matt Wette) (12/19/90)
In article <1990Dec4.151218.8859@jato.jpl.nasa.gov> I wrote: >The twm man page states that the "f.delete" command will send a >`WM_DELETE_WINDOW' command to a client. I would like to get my >Xt-coded client to receive and act on this message. Any help >getting me going would be appreciated. Thanks to the responses I got, mostly from Per Hedeland (per@erix.ericsson.se) and his reference to an xperts posting by G. Earle (earle@poseur.jpl.nasa.gov). To get an Xt application to honor the twm `f.delete' function, include something like the following in your Xt client: static void delete_window(); static XtActionsRec toplevAct[] = { { "delete_window", delete_window } }; static Atom wm_delete_window; main(argc, argv) int argc; char *argv[]; { ... toplev = XtInitialize(NULL, "xappl", NULL, 0, &argc, argv); XtAddActions(toplevAct, XtNumber(toplevAct)); XtOverrideTranslations(toplev, XtParseTranslationTable( "<Message>WM_PROTOCOLS: delete_window()")); ... XtRealizeWidget(toplev); wm_delete_window = XInternAtom(dpy, "WM_DELETE_WINDOW", False); (void) XSetWMProtocols(dpy, XtWindow(toplev), &wm_delete_window, 1); ... } static void delete_window(w, evt, par, npar) Widget w; XEvent *evt; String *par; Cardinal *npar; { if (evt->type == ClientMessage && evt->xclient.data.l[0] != wm_delete_window) { XBell(XtDisplay(w)); exit(0); } XCloseDisplay(XtDisplay(w)); exit(0); } -- _________________________________________________________________ Matthew R. Wette | Jet Propulsion Laboratory, 198-326 mwette@csi.jpl.nasa.gov | 4800 Oak Grove Dr, Pasadena,CA 91109 -----------------------------------------------------------------