Common Desktop Environment: Desktop KornShell User's Guide

Responding to a Window Manager Close Notice

When the user selects Close from the Window Manager menu for an application, the application is terminated unless it has arranged to "catch" the Close notification. If the application does not catch the notification, then multiple windows managed by the application all disappear and application data may be left in an undesirable state. To avoid this, dtksh provides for catching and handling the Close notification. The application must:

The following code illustrates this processing.

# This is the `callback' invoked when the user selects 
# the `Close' menu item 
WMCallback() 
{
echo "User has selected the Close menu item" 
} 
# Create the toplevel application shell 
XtInitialize TOPLEVEL test Dtksh $0 "$@" 
XtDisplay DISPLAY $TOPLEVEL  
# Request notification when the user selects the `Close' 
# menu item
XmInternAtom DELETE_ATOM $DISPLAY "WM_DELETE_WINDOW" false
XmAddWMProtocolCallback $TOPLEVEL $DELETE_ATOM "WMCallback"  
# Ask Motif to not automatically close down your 
# application window 

XtSetValues $TOPLEVEL deleteResponse:DO_NOTHING