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:
Define a procedure to handle the Close notification
Request notification when Close is selected
Override the response, so the application is not shut down
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