next up previous contents index
Next: 1. Full Application Modal Up: 4. Diverting User Input Previous: 1. Introduction   Contents   Index

2. The Grab Layer and the Grab List

XtRemoveGrabTo be compatible with M*TIF's grab concept, LESSTIF maintains its own grab list somewhat paralleling that inside the Xt Intrinsics. Whenever LESSTIF removes a grab from a widget by calling XtRemoveGrab() it puts back on all the widgets that are on its own list after the widget just removed.

LESSTIF manages the grabs on a per-display basis, thus you can find each grab list in the instance variable modals within the instance record of a XmScreen widget. The number of entries allocated for the list is stored in the maxModals instance member, whereas the numModals member - as usual - indicates how many entries currently are in use.

LTAddGrabLTRemoveGrabTwo pure internal functions work on the private grab lists:
\begin{itemlist}
\item \code{LTAddGrab()} adds a new widget to the grab list as ...
... and puts
back on all the widgets that were after it on the list.
\end{itemlist}

Because the grab lists are mainly used to achieve dialog modality, and dialogs are eventually special shells, you can find the implementation of LTAddGrab() and LTRemoveGrab() in (LESSTIF_ROOT)/libXm/Vendor.c.

Two additional functions - although not mentioned in the official documentation - are visible outside the Vendor.c module and provide access to M*TIF's grab layer (the interface functions are needed by the drag & drop mechanism and the menu system):


void _XmAddGrab(Widget wid, Boolean exclusive, Boolean spring_loaded);
void _XmRemoveGrab(Widget wid);

XtAddGrabXtRemoveGrab_XmAddGrab_XmRemoveGrabThey both can be used just the same way as their counterparts from the Xt Intrinsics. It is very important never to use XtAddGrab() or XtRemoveGrab() as this will put LESSTIF's grab list out of sync with the Xt grab list.

Each entry of LESSTIF's grab list stores detailed information about a single grab:


typedef struct _XmModalDataRec {
    Widget                 wid;
    XmVendorShellExtObject ve;
    XmVendorShellExtObject grabber;
    Boolean                exclusive;
    Boolean                springLoaded;
} XmModalDataRec, *XmModalData;

The members wid, exclusive, and springLoaded of the XmModalDataRec structure record the values of the function parameters from the call to LTAddGrab() or _XmAddGrab(). This way, whenever removing a grab, LESSTIF can restore the grabs that were on the list after that grab.

When working with primary application modal dialogs, LESSTIF needs to remember such dialogs in grabber so it can remove, later on, any additional grabs it had to add in order to achieve the primary application modality. The grabber member, as well as ve, is not an ordinary widget ID but rather links to a so-called extension object of a vendor shell. I'll discuss this below in more detail.



Subsections
next up previous contents index
Next: 1. Full Application Modal Up: 4. Diverting User Input Previous: 1. Introduction   Contents   Index
Danny Backx
2000-12-13