CLX provides the grab-keyboard and ungrab-keyboard functions for actively grabbing and releasing control of the keyboard.
|grab-keyboard||window &key :owner-p :sync-pointer-p :sync-keyboard-p :time||Function|
Actively grabs control of the keyboard. Further key events are reported only to the grabbing client. The request overrides any active keyboard grab by this client. grab-keyboard generates :focus-in and :focus-out events.
If :owner-p is nil, all generated key events are reported with respect to window. If :owner-p is true, then a generated key event that would normally be reported to this client is reported normally; otherwise the event is reported with respect to the window. Both :key-press and :key-release events are always reported, independent of any event selection made by the client.
If :sync-keyboard-p is nil, keyboard event processing continues normally (asynchronously); if the keyboard is currently frozen by this client, then processing of keyboard events is resumed. If :sync-keyboard-p is true, the keyboard (as seen via the protocol) appears to freeze, and no further keyboard events are generated by the server until the grabbing client issues a releasing allow-events request. Actual keyboard changes are not lost while the keyboard is frozen; they are simply queued for later processing.
If :sync-pointer-p is nil, pointer event processing is unaffected by activation of the grab. If :sync-pointer-p is true, the pointer (as seen via the protocol) appears to freeze, and no further pointer events are generated by the server until the grabbing client issues a releasing allow-events request. Actual pointer changes are not lost while the pointer is frozen; they are simply queued for later processing.
The grab can fail with a status of:
|ungrab-keyboard||display &key :time||Function|
Releases the keyboard if this client has it actively grabbed (from either grab-keyboard or grab-key ), and releases any queued events. The request has no effect if the specified time is earlier than the last-keyboard-grab time or is later than the current server time. An ungrab-keyboard is performed automatically if the event window for an active keyboard grab becomes not viewable.