whenever the window manager sends a WM_PROTOCOLS client message to the application. If the protocol sent in the
client message matches the protocol passed to XmAddWMProtocolCallback(), the associated function is called.
In the source code we use the response() routine as the callback for the dialog buttons and the protocol. As a
result, the Close item invokes the same callback as the OK and Cancel buttons.
The form of this callback routine is the same as any other Motif callback. The final parameter is a Motif−defined
callback structure of some kind, where the reason field specifies why the callback was called. This field is provided
because the same callback function may be invoked by more than one widget. In our example, the response()
function's callback structure may have one of three different values for reason: XmCR_OK for the OK button,
XmCR_CANCEL for the Cancel button, or XmCR_PROTOCOLS for the Close button in the window menu. In Motif
1.1, XmCR_PROTOCOLS was not publicly defined, but this problem has been fixed in Motif 1.2. When the callback is
invoked for the protocol message, the event field of the callback structure is an XClientMessageEvent.
The widget parameter passed to response() also varies depending on whether the routine is called from the
dialog or from the Close button. When either OK or Cancel is pressed, the widget is the dialog itself. But the protocol
callback routines are really processed by special protocol widgets that are attached to VendorShells. A shell can ...