XGrabKey(3X) XGrabKey(3X)NAME XGrabKey, XUngrabKey - grab keyboard keys SYNOPSIS XGrabKey (display, keycode, modifiers, grab-window, owner-events, pointer-mode, keyboard-mode) Display *display; int keycode; unsigned int modifiers; Window grab-window; Bool owner-events; int pointer-mode, keyboard-mode; XUngrabKey (display, keycode, modifiers, ungrab-window) Display *display; int keycode; unsigned int modifiers; Window ungrab-window; DESCRIPTION The XGrabKey function establishes a passive grab on the key- board. In the future, the keyboard is actively grabbed (as for XGrabKeyboard), the last-keyboard-grab time is set to the time at which the key was pressed (as transmitted in the KeyPress event), and the KeyPress event is reported if all of the following conditions are true: The keyboard is not grabbed and the specified key (which can itself be a modifier key) is logically pressed when the specified modifier keys are logically down, and no other modifier keys are logically down. Either the grab-window is an ancestor of (or is) the focus window, or the grab-window is a descendant of the focus window and contains the pointer. A passive grab on the same key combination does not ex- ist on any ancestor of grab-window. The interpretation of the remaining arguments is as for XGrabKeyboard. The active grab is terminated automatically when the logical state of the keyboard has the specified key released (independent of the logical state of the modifier keys). Note that the logical state of a device (as seen by client applications) may lag the physical state if device event processing is frozen. A modifiers argument of AnyModifier is equivalent to issuing the request for all possible modifier combinations (includ- ing the combination of no modifiers). It is not required November, 1990 1
XGrabKey(3X) XGrabKey(3X)that all modifiers specified have currently assigned Key- Codes. A keycode argument of AnyKey is equivalent to issu- ing the request for all possible keycodes. Otherwise, the specified keycode must be in the range specified by min_keycode and max_keycode in the connection setup, or a BadValue error results. If some other client has issued a XGrabKey with the same key combination on the same window, a BadAccess error results. When using AnyModifier or AnyKey, the request fails com- pletely, and a BadAccess error results (no grabs are esta- blished) if there is a conflicting grab for any combination. The XUngrabKey function releases the key combination on the specified window if it was grabbed by this client. It has no effect on an active grab. A modifiers of AnyModifier is equivalent to issuing the request for all possible modifier combinations (including the combination of no modifiers). A keycode argument of AnyKey is equivalent to issuing the re- quest for all possible keycodes. Arguments These functions accept the following arguments: display Specifies the connection to the X server. grab-window Specifies the window ID of the window associated with the keys to be grabbed. keycode Specifies the keycode or AnyKey. keyboard-mode Controls further processing of keyboard events. You can pass one of the following constants: GrabModeSync or GrabModeAsync. modifiers Specifies the set of keymasks or AnyModifier. If a mask is specified, it is the bitwise inclusive OR of these keymask bits: ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask. owner-events Specifies a Boolean value of either TRUE or FALSE that indicates whether keyboard events are to be re- ported as usual. pointer-mode Specifies further processing of pointer events. You 2 November, 1990
XGrabKey(3X) XGrabKey(3X)can pass one of the following constants: GrabMo- deSync or GrabModeAsync. ungrab-window Specifies the window ID of the window associated with the keys to be released. ERRORS BadAccess A client attempted to grab a key and button combina- tion already grabbed by another client. BadValue A numeric value falls outside the range of values accepted by the request. Unless a range is speci- fied for an argument, the full range defined by the argument's type is accepted. Any argument defined as a set of alternatives can generate this error. BadWindow A value for a Window argument does not name a de- fined window. The XGrabKey function can generate BadAccess, BadValue, and BadWindow errors. The XUngrabKey function can generate BadValue and BadWindow errors. SEE ALSO XGrabButton(3X), XGrabKeyboard(3X), XGrabPointer(3X)Xlib - C Language InterfaceNovember, 1990 3