Keywords: LessTif

Next: 2. The Grab Layer Up: 4. Diverting User Input Previous: 4. Diverting User Input Contents Index

# 1. Introduction

XtDispatchEventA ``grab'' is a mechanism that changes the way in which user input events - from the mouse or the keyboard - are reported. In addition to the Xlib grabs, which change the handling of user input within the X server (and which I'm not going to discuss here), the Xt Intrinsics add a second grab layer: the ``Xt grabs''. They are similar to the Xlib grabs in that they change the way user input events are reported. But the Xt grabs work entirely within an application and therefore do not affect other applications using the same X server: the central event dispatch function XtDispatchEvent() is mainly responsible for the Xt grab mechanism.

Without going too much into the dirty details, it is important to know that the Xt Intrinsics maintain a grab list. If this list is not empty, only the widgets on the list, as well as their child widgets, will receive input events. Widgets can be added to the end of the grab list either as exclusive or non-exclusive. Only the widgets on the list from the most recently added exclusive widget to the end will receive input events. This way, adding a widget to the grab list exclusively will keep any user input events away from the widgets (and their children) that were already on the list. In the end, the grab list treats the widgets as a cascade. When you remove a widget from the list, all widgets that were added after it are removed, too.

M*TIF uses a different approach to the grab mechanism. Whereas the Intrinsics' concept of a grab cascade is sensible for a set of cascading menus, it isn't for modal dialogs. If there are two modal dialogs visible, popping down the older one should not remove the younger one from the grab list. Unfortunately, to achieve the desired grab behaviour M*TIF uses a completely undocumented grab layer, so the usual omnipotent disclaimer applies: continue reading at your own risk. All knowledge about M*TIF's grab layer results from investigations done on the ``living subject'' with the help of a nice test program that can pretty-print various data trees to the console. The test program lives in (LESSTIF_ROOT)/testXm/extobj/test2.c.

Next: 2. The Grab Layer Up: 4. Diverting User Input Previous: 4. Diverting User Input Contents Index