jerryl@is.Morgan.COM (Jerry Liebelson) (05/08/91)
Reply-To: jerryl@is.morgan.com ------------------------------------------------------------------------------ Hi - When I use a callback for the WM_DELETE_WINDOW protocol, the routine gets invoked ok. But how can I tell the window manager not to actually delete the window. Say I wanted to throw up a dialog box asking the user if he really wanted to quit? The ICCCM manual (section 5.2.2 seems to imply such optional behavior). Shown below is the code that I use (Motif 1.1/X11R4 patchlevel 18/SunOS 4.11). |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| | Jerry Liebelson | EMAIL: jerryl@is.morgan.com | | Information Systems | uunet!is.morgan.com!jerryl | | Morgan Stanley, Inc. | VOICE: (212) 703-2409 | | 1633 Broadway 36th Floor | FAX: (212) 703-2371 | | New York, NY 10019 | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #include <Xm/MwmUtil.h> #ifndef XA_WM_PROTOCOLS #define XA_WM_PROTOCOLS "WM_PROTOCOLS" #endif #ifndef XA_WM_DELETE_WINDOW #define XA_WM_DELETE_WINDOW "WM_DELETE_WINDOW" #endif #endif void Quit(); static Atom WmDeleteWindowAtom, WmProtocolsAtom; /* GLOBAL */ Widget AppShell; /* ... */ main() { XtAppContext appContext; /* ... */ AppShell = XtAppInitialize ( &appContext, appClass, NULL, 0, &argc, argv, NULL, NULL, 0 ); /* ... */ WmDeleteWindowAtom = XInternAtom (XtDisplay(AppShell), XA_WM_DELETE_WINDOW, False); WmProtocolsAtom = XInternAtom (XtDisplay(AppShell), XA_WM_PROTOCOLS, False); XmAddProtocolCallback(AppShell, WmProtocolsAtom, WmDeleteWindowAtom, Quit, NULL); /* ... */ } void Quit(widget, clientData, event) Widget widget; XtPointer *clientData; XEvent *event; { fprintf(stderr, "In Quit()\n"); }