X Version 11, Release 7.7
Version 1.0
Copyright © 1995, 1996 X Consortium Inc., Silicon Graphics Inc., Hewlett-Packard Company, Digital Equipment Corporation
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the names of the X Consortium, Silicon Graphics Inc., Hewlett-Packard Company, and Digital Equipment Corporation shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization.
Table of Contents
I am grateful for all of the comments and suggestions I have received over the years. I could not possibly list everyone who has helped, but a few people have gone well above and beyond the call of duty and simply must be listed here.
My managers here at SGI, Tom Paquin (now at Netscape) and Gianni Mariani were wonderful. Rather than insisting on some relatively quick, specialized proprietary solution to the keyboard problems we were having, both Tom and Gianni understood the importance of solving them in a general way and for the community as a whole. That was a difficult position to take and it was even harder to maintain when the scope of the project expanded beyond anything we imagined was possible. Gianni and Tom were unflagging in their support and their desire to “do the right thing” despite the schedule and budget pressure that intervened from time to time.
Will Walker, at Digital Equipment Corporation, has been a longtime supporter of XKB. His help and input was essential to ensure that the extension as a whole fits and works together well. His focus was AccessX but the entire extension has benefited from his input and hard work. Without his unflagging good cheer and willingness to lend a hand, XKB would not be where it is today.
Matt Landau, at the X Consortium, stood behind XKB during some tough spots in the release and standardization process. Without Matt’s support, XKB would likely not be a standard for a long time to come. When it became clear that we had too much to do for the amount of time we had remaining, Matt did a fantastic job of finding people to help finish the work needed for standardization.
One of those people was George Sachs, at Hewlett-Packard, who jumped in to help out. His help was essential in getting the extension into this release. Another was Donna Converse, who helped figure out how to explain all of this stuff to someone who hadn’t had their head buried in it for years.
Amber Benson and Gary Aitken were simply phenomenal. They jumped into a huge and complicated project with good cheer and unbelievable energy. They were “up to speed” and contributing within days. I stand in awe of the amount that they managed to achieve in such a short time. Thanks to Gary and Amber, the XKB library specification is a work of art and a thousand times easier to use and more useful than it would otherwise be.
I truly cannot express my gratitude to all of you, without whom this would not have been possible.
Erik Fortune
Silicon Graphics, Inc.
5 February 1996
Table of Contents
This extension provides a number of new capabilities and controls for text keyboards.
The core X protocol specifies the ways that the Shift , Control and Lock modifiers and the modifiers bound to the Mode_switch or Num_Lock keysyms interact to generate keysyms and characters. The core protocol also allows users to specify that a key affects one or more modifiers. This behavior is simple and fairly flexible, but it has a number of limitations that make it difficult or impossible to properly support many common varieties of keyboard behavior. The limitations of core protocol support for keyboards include:
Use of a single, uniform, four-symbol mapping for all keyboard keys makes it difficult to properly support keyboard overlays, PC-style break keys or keyboards that comply with ISO9995 or a host of other national and international standards.
Use of a modifier to specify a second keyboard group has side-effects that wreak havoc with client grabs and X toolkit translations and limit us to two keyboard groups.
Poorly specified locking key behavior requires X servers to look for a few "magic" keysyms to determine which keys should lock when pressed. This leads to incompatibilities between X servers with no way for clients to detect implementation differences.
Poorly specified capitalization and control behavior requires modifications to X library source code to support new character sets or locales and can lead to incompatibilities between system-wide and X library capitalization behavior.
Limited interactions between modifiers specified by the core protocol make many common keyboard behaviors difficult or impossible to implement. For example, there is no reliable way to indicate whether or not using shift should "cancel" the lock modifier.
The lack of any explicit descriptions for indicators, most modifiers and other aspects of the keyboard appearance requires clients that wish to clearly describe the keyboard to a user to resort to a mishmash of prior knowledge and heuristics.
This extension makes it possible to clearly and explicitly specify most aspects of keyboard behavior on a per-key basis. It adds the notion of a numeric keyboard group to the global keyboard state and provides mechanisms to more closely track the logical and physical state of the keyboard. For keyboard control clients, this extension provides descriptions and symbolic names for many aspects of keyboard appearance and behavior. It also includes a number of keyboard controls designed to make keyboards more accessible to people with movement impairments.
The X Keyboard Extension essentially replaces the core protocol definition of a keyboard. The following sections describe the new capabilities of the extension and the effect of the extension on core protocol requests, events and errors.
This document uses the syntactic conventions, common types, and errors defined in sections two through four of the specification of the X Window System Protocol. This document assumes familiarity with the fundamental concepts of X, especially those related to the way that X handles keyboards. Readers who are not familiar with the meaning or use of keycodes, keysyms or modifiers should consult (at least) the first five chapters of the protocol specification of the X Window System before continuing.
Table of Contents
The core protocol description of keyboard state consists of eight modifiers ( Shift , Lock , Control , and Mod1 - Mod5 ). A modifier reports the state of one or modifier keys, which are similar to qualifier keys as defined by the ISO9995 standard:
Qualifier key | A key whose operation has no immediate effect, but which, for as long as it is held down, modifies the effect of other keys. A qualifier key may be, for example, a shift key or a control key. |
Whenever a modifier key is physically or logically depressed, the modifier it controls is set in the keyboard state. The protocol implies that certain modifier keys lock (i.e. affect modifier state after they have been physically released) but does not explicitly discuss locking keys or their behavior. The current modifier state is reported to clients in a number of core protocol events and can be determined using the QueryPointer request.
The XKB extension retains the eight "real" modifiers defined by the core protocol but extends the core protocol notion of keyboard state to include up to four keysym groups , as defined by the ISO9995 standard:
Group: | A logical state of a keyboard providing access to a collection of characters. A group usually contains a set of characters which logically belong together and which may be arranged on several shift levels within that group. |
For example, keyboard group can be used to select between multiple alphabets on a single keyboard, or to access less-commonly used symbols within a character set.
With the core protocol, there is no way to tell whether a modifier is set due to a lock or because the user is actually holding down a key; this can make for a clumsy user-interface as locked modifiers or group state interfere with accelerators and translations.
XKB adds explicit support for locking and latching modifiers and groups. Locked modifiers or groups apply to all future key events until they are explicitly changed. Latched modifiers or groups apply only to the next key event that does not change keyboard state.
The fundamental components of XKB keyboard state include:
The locked modifiers and group
The latched modifiers and group
The base modifiers and group (for which keys are physically or logically down)
The effective modifiers and group (the cumulative effect of the base, locked and latched modifier and group states).
State of the core pointer buttons.
The latched and locked state of modifiers and groups can be changed in response to keyboard activity or under application control using the XkbLatchLockState request. The base modifier, base group and pointer button states always reflect the logical state of the keyboard and pointer and change only in response to keyboard or pointer activity.
The effective modifiers and group report the cumulative effects of the base, latched and locked modifiers and group respectively, and cannot be directly changed. Note that the effective modifiers and effective group are computed differently.
The effective modifiers are simply the bitwise union of the base, latched and locked modifiers.
The effective group is the arithmetic sum of the base, latched and locked groups. The locked and effective keyboard group must fall in the range Group1 - Group4 , so they are adjusted into range as specified by the global GroupsWrap control as follows:
If the RedirectIntoRange flag is set, the four least significant bits of the groups wrap control specify the index of a group to which all illegal groups correspond. If the specified group is also out of range, all illegal groups map to Group1.
If the ClampIntoRange flag is set, out-of-range groups correspond to the nearest legal group. Effective groups larger than the highest supported group are mapped to the highest supported group; effective groups less than Group1 are mapped to Group1 . For example, a key with two groups of symbols uses Group2 type and symbols if the global effective group is either Group3 or Group4.
If neither flag is set, group is wrapped into range using integer modulus. For example, a key with two groups of symbols for which groups wrap uses Group1 symbols if the global effective group is Group3 or Group2 symbols if the global effective group is Group4.
The base and latched keyboard groups are unrestricted eight-bit integer values and are not affected by the GroupsWrap control.
Many events report the keyboard state in a single state field. Using XKB, a state field combines modifiers, group and the pointer button state into a single sixteen bit value as follows:
Bits 0 through 7 (the least significant eight bits) of the effective state comprise a mask of type KEYMASK which reports the state modifiers.
Bits 8 through 12 comprise a mask of type BUTMASK which reports pointer button state.
Bits 13 and 14 are interpreted as a two-bit unsigned numeric value and report the state keyboard group.
Bit 15 (the most significant bit) is reserved and must be zero.
It is possible to assemble a state field from any of the components of the XKB keyboard state. For example, the effective keyboard state would be assembled as described above using the effective keyboard group, the effective keyboard modifiers and the pointer button state.
In addition to the fundamental state components, XKB keeps track of and reports a number of state components which are derived from the fundamental components but stored and reported separately to make it easier to track changes in the keyboard state. These derived components are updated automatically whenever any of the fundamental components change but cannot be changed directly.
The first pair of derived state components control the way that passive grabs are activated and the way that modifiers are reported in core protocol events that report state. The server uses the ServerInternalModifiers , IgnoreLocksModifiers and IgnoreGroupLock controls, described in Server Internal Modifiers and Ignore Locks Behavior, to derive these two states as follows:
The lookup state is the state used to determine the symbols associated with a key event and consists of the effective state minus any server internal modifiers.
The grab state is the state used to decide whether a particular event triggers a passive grab and consists of the lookup state minus any members of the ignore locks modifiers that are not either latched or logically depressed. If the ignore group locks control is set, the grab state does not include the effects of any locked groups.
The core protocol does not provide any way to exclude certain modifiers from client events, so there is no way to set up a modifier which affects only the server.
The modifiers specified in the mask of the InternalMods control are not reported in any core protocol events, are not used to determine grabs and are not used to calculate compatibility state for XKB-unaware clients. Server internal modifiers affect only the action applied when a key is pressed.
The core protocol does not provide any way to exclude certain modifiers from grab calculations, so locking modifiers often have unanticipated and unfortunate side-effects. XKB provides another mask which can help avoid some of these problems.
The locked state of the modifiers specified in mask of the IgnoreLockMods control is not reported in most core protocol events and is not used to activate grabs. The only core events which include the locked state of the modifiers in the ignore locks mask are key press and release events that do not activate a passive grab and which do not occur while a grab is active. If the IgnoreGroupLock control is set, the locked state of the keyboard group is not considered when activating passive grabs.
Without XKB, the passive grab set by a translation (e.g. Alt<KeyPress>space ) does not trigger if any modifiers other than those specified by the translation are set, with the result that many user interface components do not react when either Num Lock or when the secondary keyboard group are active. The ignore locks mask and the ignore group locks control make it possible to avoid this behavior without exhaustively grabbing every possible modifier combination.
The core protocol interpretation of keyboard modifiers does not include direct support for multiple groups, so XKB reports the effective keyboard group to XKB-aware clients using some of the reserved bits in the state field of some core protocol events, as described in Computing A State Field from an XKB State.
This modified state field would not be interpreted correctly by XKB-unaware clients, so XKB provides a group compatibility mapping (see Group Compatibility Map) which remaps the keyboard group into a core modifier mask that has similar effects, when possible. XKB maintains three compatibility state components that are used to make non-XKB clients work as well as possible:
The compatibility state corresponds to the effective modifier and effective group state.
The compatibility lookup state is the core-protocol equivalent of the lookup state.
The compatibility grab state is the nearest core-protocol equivalent of the grab state.
Compatibility states are essentially the corresponding XKB state, but with keyboard group possibly encoded as one or more modifiers; Group Compatibility Map describes the group compatibility map, which specifies the modifier(s) that correspond to each keyboard group.
The compatibility state reported to XKB-unaware clients for any given core protocol event is computed from the modifier state that XKB-capable clients would see for that same event. For example, if the ignore group locks control is set and group 2 is locked, the modifier bound to Mode_switch is not reported in any event except (Device)KeyPress and (Device)KeyRelease events that do not trigger a passive grab.
Referring to clients as "XKB-capable is somewhat misleading in this context. The sample implementation of XKB invisibly extends the X library to use the keyboard extension if it is present. This means that most clients can take advantage of all of XKB without modification, but it also means that the XKB state can be reported to clients that have not explicitly requested the keyboard extension. Clients that directly interpret the state field of core protocol events or that interpret the keymap directly may be affected by some of the XKB differences; clients that use library or toolkit routines to interpret keyboard events automatically use all of the XKB features.
XKB-aware clients can query the keyboard state at any time or request immediate notification of a change to any of the fundamental or derived components of the keyboard state.
The core protocol specifies that certain keysyms, when bound to modifiers, affect the rules of keycode to keysym interpretation for all keys; for example, when Num_Lock is bound to some modifier, that modifier is used to choose shifted or unshifted state for the numeric keypad keys. The core protocol does not provide a convenient way to determine the mapping of modifier bits, in particular Mod1 through Mod5 , to keysyms such as Num_Lock and Mode_switch . Clients must retrieve and search the modifier map to determine the keycodes bound to each modifier, and then retrieve and search the keyboard mapping to determine the keysyms bound to the keycodes. They must repeat this process for all modifiers whenever any part of the modifier mapping is changed.
XKB provides a set of sixteen named virtual modifiers, each of which can be bound to any set of the eight "real" modifiers ( Shift , Lock , Control and Mod1 - Mod5 as reported in the keyboard state). This makes it easier for applications and keyboard layout designers to specify to the function a modifier key or data structure should fulfill without having to worry about which modifier is bound to a particular keysym.
The use of a single, server-driven mechanism for reporting changes to all data structures makes it easier for clients to stay synchronized. For example, the core protocol specifies a special interpretation for the modifier bound to the Num_Lock key. Whenever any keys or modifiers are rebound, every application has to check the keyboard mapping to make sure that the binding for Num_Lock has not changed. If Num_Lock is remapped when XKB is in use, the keyboard description is automatically updated to reflect the new binding, and clients are notified immediately and explicitly if there is a change they need to consider.
The separation of function from physical modifier bindings also makes it easier to specify more clearly the intent of a binding. X servers do not all assign modifiers the same way — for example, Num_Lock might be bound to Mod2 for one vendor and to Mod4 for another. This makes it cumbersome to automatically remap the keyboard to a desired configuration without some kind of prior knowledge about the keyboard layout and bindings. With XKB, applications simply use virtual modifiers to specify the behavior they want, without regard for the actual physical bindings in effect.
XKB puts most aspects of the keyboard under user or program control, so it is even more important to clearly and uniformly refer to modifiers by function.
Use an XKB modifier definition to specify the modifiers affected by any XKB control or data structure. An XKB modifier definition consists of a set of real modifiers, a set of virtual modifiers, and an effective mask. The mask is derived from the real and virtual modifiers and cannot be explicitly changed — it contains all of the real modifiers specified in the definition plus any real modifiers that are bound to the virtual modifiers specified in the definition. For example, this modifier definition specifies the numeric lock modifier if the Num_Lock keysym is not bound to any real modifier:
{ real_mods= None, virtual_mods= NumLock, mask= None }
If we assign Mod2 to the Num_Lock key, the definition changes to:
{ real_mods= None, virtual_mods= NumLock, mask= Mod2 }
Using this kind of modifier definition makes it easy to specify the desired behavior in such a way that XKB can automatically update all of the data structures that make up a keymap to reflect user or application specified changes in any one aspect of the keymap.
The use of modifier definitions also makes it possible to unambiguously specify the reason that a modifier is of interest. On a system for which the Alt and Meta keysyms are bound to the same modifier, the following definitions behave identically:
{ real_mods= None, virtual_mods= Alt, mask= Mod1 }
{ real_mods= None, virtual_mods= Meta, mask= Mod1 }
If we rebind one of the modifiers, the modifier definitions automatically reflect the change:
{ real_mods= None, virtual_mods= Alt, mask= Mod1 }
{ real_mods= None, virtual_mods= Meta, mask= Mod4 }
Without the level of indirection provided by virtual modifier maps and modifier definitions, we would have no way to tell which of the two definitions is concerned with Alt and which is concerned with Meta.
Some XKB structures ignore modifier definitions in which the virtual modifiers are unbound. Consider this example:
if ( state matches { Shift } ) Do OneThing;
if ( state matches { Shift+NumLock } ) Do Another;
If the NumLock virtual modifier is not bound to any real modifiers, these effective masks for these two cases are identical (i.e. they contain only Shift ). When it is essential to distinguish between OneThing and Another, XKB considers only those modifier definitions for which all virtual modifiers are bound.
XKB maintains a virtual modifier mapping , which lists the virtual modifiers associated with each key. The real modifiers bound to a virtual modifier always include all of the modifiers bound to any of the keys that specify that virtual modifier in their virtual modifier mapping.
For example, if Mod3 is bound to the Num_Lock key by the core protocol modifier mapping, and the NumLock virtual modifier is bound to they Num_Lock key by the virtual modifier mapping, Mod3 is added to the set of modifiers associated with the NumLock virtual modifier.
The virtual modifier mapping is normally updated automatically whenever actions are assigned to keys (see Changing the Keyboard Mapping Using the Core Protocol for details) and few applications should need to change the virtual modifier mapping explicitly.
Table of Contents
The X Keyboard Extension supports a number of global key controls , which affect the way that XKB handles the keyboard as a whole. Many of these controls make the keyboard more accessible to the physically impaired and are based on the AccessDOS package[1].
The core protocol only allows control over whether or not the entire keyboard or individual keys should autorepeat when held down. The RepeatKeys control extends this capability by adding control over the delay until a key begins to repeat and the rate at which it repeats. RepeatKeys is also coupled with the core autorepeat control; changes to one are always reflected in the other.
The RepeatKeys control has two parameters. The autorepeat delay specifies the delay between the initial press of an autorepeating key and the first generated repeat event in milliseconds. The autorepeat interval specifies the delay between all subsequent generated repeat events in milliseconds.
When RepeatKeys are active, the PerKeyRepeat control specifies whether or not individual keys should autorepeat when held down. XKB provides the PerKeyRepeat for convenience only, and it always parallels the auto-repeats field of the core protocol GetKeyboardControl request — changes to one are always reflected in the other.
The X server usually generates both press and release events whenever an autorepeating key is held down. If an XKB-aware client enables the DetectableAutorepeat per-client option for a keyboard, the server sends that client a key release event only when the key is physically released. For example, holding down a key to generate three characters without detectable autorepeat yields:
Press -> Release -> Press -> Release -> Press -> Release
If detectable autorepeat is enabled, the client instead receives:
Press-> Press -> Press -> Release
Note that only clients that request detectable autorepeat are affected; other clients continue to receive both press and release events for autorepeating keys. Also note that support for detectable autorepeat is optional; servers are not required to support detectable autorepeat, but they must correctly report whether or not it is supported.
Querying and Changing Per-Client Flags describes the XkbPerClientFlags request, which reports or changes values for all of the per-client flags, and which lists the per-client flags that are supported.
Some users often bump keys accidentally while moving their hand or typing stick toward the key they want. Usually, the keys that are bumped accidentally are hit only for a very short period of time. The SlowKeys control helps filter these accidental bumps by telling the server to wait a specified period, called the SlowKeys acceptance delay , before delivering key events. If the key is released before this period elapses, no key events are generated. The user can then bump any number of keys on their way to the one they want without generating unwanted characters. Once they have reached the key they want, they can then hold it long enough for SlowKeys to accept it.
The SlowKeys control has one parameter; the slow keys delay specifies the length of time, in milliseconds, that a key must be held down before it is accepted.
When SlowKeys are active, the X Keyboard Extension reports the initial press, acceptance, rejection or release of any key to interested clients using AccessXNotify events. The AccessXNotify event is described in more detail in Events.
Some people with physical impairments accidentally "bounce" on a key when they press it. That is, they press it once, then accidentally press it again immediately. The BounceKeys control temporarily disables a key after it has been pressed, effectively "debouncing" the keyboard.
The BounceKeys has a single parameter. The BounceKeys delay specifies the period of time, in milliseconds, that the key is disabled after it is pressed.
When BounceKeys are active, the server reports the acceptance or rejection of any key to interested clients by sending an AccessXNotify event. The AccessXNotify event is described in more detail in Events.
Some people find it difficult or impossible to press two keys at once. The StickyKeys control makes it easier for them to type by changing the behavior of the modifier keys. When StickyKeys are enabled, a modifier is latched when the user presses it just once, so the user can first press a modifier, release it, then press another key. For example, to get an exclamation point (!) on a PC-style keyboard, the user can press the Shift key, release it, then press the 1 key.
By default, StickyKeys also allows users to lock modifier keys without requiring special locking keys. The user can press a modifier twice in a row to lock it, and then unlock it by pressing it one more time.
Modifiers are automatically unlatched when the user presses a non-modifier key. For instance, to enter the sequence Shift + Ctrl + Z the user could press and release the Shift key to latch the Shift modifier, then press and release the Ctrl key to latch the Control modifier — the Ctrl key is a modifier key, so pressing it does not unlatch the Shift modifier, but leaves both the Shift and Control modifiers latched, instead. When the user presses the Z key, it will be as though the user pressed Shift + Ctrl + Z simultaneously. The Z key is not a modifier key, so the Shift and Control modifiers are unlatched after the event is generated.
A locked a modifier remains in effect until the user unlocks it. For example, to enter the sequence ("XKB") on a PC-style keyboard with a typical US/ASCII layout, the user could press and release the Shift key twice to lock the Shift modifier. Then, when the user presses the 9 , ‘ , x , k , b , ‘ , and 0 keys in sequence, it will generate ("XKB"). To unlock the Shift modifier, the user can press and release the Shift key.
Two option flags modify the behavior of the StickyKeys control:
If the XkbAX_TwoKeys flag is set, XKB automatically turns StickyKeys off if the user presses two or more keys at once. This serves to automatically disable StickyKeys when a user who does not require sticky keys is using the keyboard.
The XkbAX_LatchToLock controls the locking behavior of StickyKeys ; the StickyKeys control only locks modifiers as described above if the XkbAX_LatchToLock flag is set.
The MouseKeys control lets a user control all the mouse functions from the keyboard. When MouseKeys are enabled, all keys with MouseKeys actions bound to them generate core pointer events instead of normal key press and release events.
The MouseKeys control has a single parameter, the mouse keys default button , which specifies the core pointer button to be used by mouse keys actions that do not explicitly specify a button.
If the MouseKeysAccel control is enabled, the effect of a pointer motion action changes as a key is held down. The mouse keys delay specifies the amount of time between the initial key press and the first repeated motion event. The mouse keys interval specifies the amount of time between repeated mouse keys events. The steps to maximum acceleration field specifies the total number of events before the key is travelling at maximum speed. The maximum acceleration field specifies the maximum acceleration. The curve parameter controls the ramp used to reach maximum acceleration.
When MouseKeys are active and a SA_MovePtr key action (see Key Actions) is activated, a pointer motion event is generated immediately. If MouseKeysAccel is enabled and if acceleration is enabled for the key in question, a second event is generated after mouse keys delay milliseconds, and additional events are generated every mouse keys interval milliseconds for as long as the key is held down.
If the SA_MovePtr action specifies relative motion, events are generated as follows: The initial event always moves the cursor the distance specified in the action; after steps to maximum acceleration events have been generated, all subsequent events move the pointer the distance specified in the action times the maximum acceleration. Events after the first but before maximum acceleration has been achieved are accelerated according to the formula:
Where action_delta is the offset specified by the mouse keys action, max_accel and steps_to_max are parameters to the MouseKeysAccel ctrl, and the curveFactor is computed using the MouseKeysAccel curve parameter as follows:
With the result that a curve of 0 causes the distance moved to increase linearly from action_delta to
, and the minimum legal curve of - 1000 causes all events after the first move at max_accel . A negative curve causes an initial sharp increase in acceleration which tapers off, while a positive curve yields a slower initial increase in acceleration followed by a sharp increase as the number of pointer events generated by the action approaches steps_to_max .
If AccessXKeys is enabled many controls can also be turned on or off from the keyboard by entering the following standard key sequences:
Holding down a shift key by itself for eight seconds toggles the SlowKeys control.
Pressing and releasing a shift key five times in a row without any intervening key events and with less than 30 seconds delay between consecutive presses toggles the state of the StickyKeys control.
Simultaneously operating two or more modifier keys deactivates the StickyKeys control.
Some of these key sequences optionally generate audible feedback of the change in state, as described in The AccessXFeedback Control, or cause XkbAccessXNotify events as described in Events.
In environments where computers are shared, features such as SlowKeys present a problem: if SlowKeys is on, the keyboard can appear to be unresponsive because keys have no effect unless they are held for a certain period of time. To help address this problem, XKB provides an AccessXTimeout control to automatically change the value of any global controls or AccessX options if the keyboard is idle for a specified period of time.
The AccessXTimeout control has a number of parameters which affect the duration of the timeout and the features changed when the timeout expires.
The AccessX Timeout field specifies the number of seconds the keyboard must be idle before the global controls and AccessX options are modified. The AccessX Options Mask field specifies which values in the AccessX Options field are to be changed, and the AccessX Options Values field specifies the new values for those options. The AccessX Controls Mask field specifies which controls are to be changed in the global set of enabled controls , and the AccessX Controls Values field specifies the new values for those controls.
If AccessXFeedback is enabled, special beep-codes indicate changes in keyboard controls (or some key events when SlowKeys or StickyKeys are active). Many beep codes sound as multiple tones, but XKB reports a single XkbBellNotify event for the entire sequence of tones.
All feedback tones are governed by the AudibleBell control. Individual feedback tones can be explicitly enabled or disabled using the accessX options mask or set to deactivate after an idle period using the accessX timeout options mask . XKB defines the following feedback tones:
| Feedback Name | Bell Name | Default Sound | Indicates |
|---|---|---|---|
| FeatureFB | AX_FeatureOn | rising tone | Keyboard control enabled |
| AX_FeatureOff | falling tone | Keyboard control disabled | |
| AX_FeatureChange | two tones | Several controls changed state | |
| IndicatorFB | AX_IndicatorOn | high tone | Indicator Lit |
| AX_IndicatorOff | low tone | Indicator Extinguished | |
| AX_IndicatorChange | two high tones | Several indicators changed state | |
| SlowWarnFB | AX_SlowKeysWarning | three high tones | Shift key held for four seconds |
| SKPressFB | AX_SlowKeyPress | single tone | Key press while SlowKeys are on |
| SKReleaseFB | AX_SlowKeyRelease | single tone | Key release while SlowKeys are on |
| SKAcceptFB | AX_SlowKeyAccept | single tone | Key event accepted by SlowKeys |
| SKRejectFB | AX_SlowKeyReject | low tone | Key event rejected by SlowKeys |
| StickyKeysFB | AX_StickyLatch | low tone then high tone | Modifier latched by StickyKeys |
| AX_StickyLock | high tone | Modifier locked by StickyKeys | |
| AX_StickyUnlock | low tone | Modifier unlocked by StickyKeys | |
| BKRejectFB | AX_BounceKeysReject | low tone | Key event rejected by BounceKeys |
Implementations that cannot generate continuous tones may generate multiple beeps instead of falling and rising tones; for example, they can generate a high-pitched beep followed by a low-pitched beep instead of a continuous falling tone.
If the physical keyboard bell is not very capable, attempts to simulate a continuous tone with multiple bells can sound horrible. Set the DumbBellFB AccessX option to inform the server that the keyboard bell is not very capable and that XKB should use only simple bell combinations. Keyboard capabilities vary wildly, so the sounds generated for the individual bells when the DumbBellFB option is set are implementation specific.
A keyboard overlay allows some subset of the keyboard to report alternate keycodes when the overlay is enabled. For example a keyboard overlay can be used to simulate a numeric or editing keypad on keyboard that does not actually have one by generating alternate of keycodes for some keys when the overlay is enabled. This technique is very common on portable computers and embedded systems with small keyboards.
XKB includes direct support for two keyboard overlays, using the Overlay1 and Overlay2 controls. When Overlay1 is enabled, all of the keys that are members of the first keyboard overlay generate an alternate keycode. When Overlay2 is enabled, all of the keys that are members of the second keyboard overlay generate an alternate keycode.
To specify the overlay to which a key belongs and the alternate keycode it should generate when that overlay is enabled, assign it either the KB_Overlay1 or KB_Overlay2 key behaviors, as described in Key Behavior.
All of the controls described above, along with the AudibleBell control (described in Disabling Server Generated Bells) and the IgnoreGroupLock control (described in Server Internal Modifiers and Ignore Locks Behavior) comprise the boolean controls . In addition to any parameters listed in the descriptions of the individual controls, the boolean controls can be individually enabled or disabled by changing the value of the EnabledControls control.
The following non-boolean controls are always active and cannot be changed using the EnabledControls control or specified in any context that accepts only boolean controls: GroupsWrap (Computing Effective Modifier and Group), EnabledControls , InternalMods (Server Internal Modifiers and Ignore Locks Behavior), and IgnoreLockMods (Server Internal Modifiers and Ignore Locks Behavior) and PerKeyRepeat (The RepeatKeys Control)
The auto-reset controls are a per-client value which consist of two masks that can contain any of the boolean controls (see "Boolean" Controls and The EnabledControls Control). Whenever the client exits for any reason, any boolean controls specified in the auto-reset mask are set to the corresponding value from the auto-reset values mask. This makes it possible for clients to "clean up after themselves" automatically, even if abnormally terminated.
For example, a client that replace the keyboard bell with some other audible cue might want to turn off the AudibleBell control (Disabling Server Generated Bells) to prevent the server from also generating a sound and thus avoid cacophony. If the client were to exit without resetting the AudibleBell control, the user would be left without any feedback at all. Setting AudibleBell in both the auto-reset mask and auto-reset values guarantees that the audible bell will be turned back on when the client exits.
[1] AccessDOS provides access to the DOS operating system for people with physical impairments and was developed by the Trace R&D Center at the University of Wisconsin. For more information on AccessDOS, contact the Trace R&D Center, Waisman Center and Department of Industrial Engineering, University of Wisconsin-Madison WI 53705-2280. Phone: 608-262-6966. e-mail: info@trace.wisc.edu.
There are three steps to processing each key event in the X server, and at least three in the client. This section describes each of these steps briefly; the following sections describe each step in more detail.
First, the server applies global keyboard controls to determine whether the key event should be processed immediately, deferred, or ignored. For example, the SlowKeys control can cause a key event to be deferred until the slow keys delay has elapsed while the RepeatKeys control can cause multiple X events from a single physical key press if the key is held down for an extended period. The global keyboard controls affect all of the keys on the keyboard and are described in Global Keyboard Controls.
Next, the server applies per-key behavior. Per key-behavior can be used to simulate or indicate some special kinds of key behavior. For example, keyboard overlays, in which a key generates an alternate keycode under certain circumstances, can be implemented using per-key behavior. Every key has a single behavior, so the effect of key behavior does not depend on keyboard modifier or group state, though it might depend on global keyboard controls. Per-key behaviors are described in detail in Key Behavior.
Finally, the server applies key actions. Logically, every keysym on the keyboard has some action associated with it. The key action tells the server what to do when an event which yields the corresponding keysym is generated. Key actions might change or suppress the event, generate some other event, or change some aspect of the server. Key actions are described in Key Actions.
If the global controls, per-key behavior and key action combine to cause a key event, the client which receives the event processes it in several steps.
First the client extracts the effective keyboard group and a set of modifiers from the state field of the event. See Computing A State Field from an XKB State for details.
Using the modifiers and effective keyboard group, the client selects a symbol from the list of keysyms bound to the key. Determining the KeySym Associated with a Key Event discusses symbol selection.
If necessary, the client transforms the symbol and resulting string using any modifiers that are "left over" from the process of looking up a symbol. For example, if the Lock modifier is left over, the resulting keysym is capitalized according to the capitalization rules specified by the system. See Transforming the KeySym Associated with a Key Event for a more detailed discussion of the transformations defined by XKB.
Finally, the client uses the keysym and remaining modifiers in an application-specific way. For example, applications based on the X toolkit might apply translations based on the symbol and modifiers reported by the first three steps.
Table of Contents
This section describes the steps involved in processing a key event within the server when XKB is present. Key events can be generated due to keyboard activity and passed to XKB by the DDX layer, or they can be synthesized by another extension, such as XTEST.
When the X Keyboard Extension receives a key event, it first checks the global key controls to decide whether to process the event immediately or at all. The global key controls which might affect the event, in descending order of priority, are:
If a key is pressed while the BounceKeys control is enabled, the extension generates the event only if the key is active. When a key is released, the server deactivates the key and starts a bounce keys timer with an interval specified by the debounce delay.
If the bounce keys timer expires or if some other key is pressed before the timer expires, the server reactivates the corresponding key and deactivates the timer. Neither expiration nor deactivation of a bounce keys timer causes an event.
If the SlowKeys control is enabled, the extension sets a slow keys timer with an interval specified by the slow keys delay, but does not process the key event immediately. The corresponding key release deactivates this timer.
If the slow keys timer expires, the server generates a key press for the corresponding key, sends an XkbAccessXNotify and deactivates the timer.
The extension processes key press events normally whether or not the RepeatKeys control is active, but if RepeatKeys are enabled and per-key autorepeat is enabled for the event key, the extension processes key press events normally, but it also initiates an autorepeat timer with an interval specified by the autorepeat delay. The corresponding key release deactivates the timer.
If the autorepeat timer expires, the server generates a key release and a key press for the corresponding key and reschedules the timer according to the autorepeat interval.
Key events are processed by each global control in turn: if the BounceKeys control accepts a key event, SlowKeys considers it. Once SlowKeys allows or synthesizes an event, the RepeatKeys control acts on it.
Once an event is accepted by all of the controls or generated by a timer, the server checks the per-key behavior of the corresponding key. This extension currently defines the following key behaviors:
| Behavior | Effect |
|---|---|
| KB_Default | Press and release events are processed normally. |
| KB_Lock | If a key is logically up (i.e. the corresponding bit of the core key map is cleared) when it is pressed, the key press is processed normally and the corresponding release is ignored. If the key is logically down when pressed, the key press is ignored but the corresponding release is processed normally. |
|
KB_RadioGroup flags: CARD8 index: CARD8 | If another member of the radio group specified by index is logically down when a key is pressed, the server synthesizes a key release for the member that is logically down and then processes the new key press event normally. If the key itself is logically down when pressed, the key press event is ignored, but the processing of the corresponding key release depends on the value of the RGAllowNone bit in flags . If it is set, the key release is processed normally; otherwise the key release is also ignored. All other key release events are ignored. |
|
KB_Overlay1 key: KEYCODE | If the Overlay1 control is enabled, events from this key are reported as if they came from the key specified in key . Otherwise, press and release events are processed normally. |
|
KB_Overlay2 key: KEYCODE | If the Overlay2 control is enabled, events from this key are reported as if they came from the key specified in key . Otherwise, press and release events are processed normally. |
The X server uses key behavior to determine whether to process or filter out any given key event; key behavior is independent of keyboard modifier or group state (each key has exactly one behavior.
Key behaviors can be used to simulate any of these types of keys or to indicate an unmodifiable physical, electrical or software driver characteristic of a key. An optional permanent flag can modify any of the supported behaviors and indicates that behavior describes an unalterable physical, electrical or software aspect of the keyboard. Permanent behaviors cannot be changed or set by the XkbSetMap request. The permanent flag indicates a characteristic of the underlying system that XKB cannot affect, so XKB treats all permanent behaviors as if they were KB_Default and does not filter key events described in the table above.
Once the server has applied the global controls and per-key behavior and has decided to process a key event, it applies key actions to determine the effects of the key on the internal state of the server. A key action consists of an operator and some optional data. XKB supports actions which:
change base, latched or locked modifiers or group
move the core pointer or simulate core pointer button events
change most aspects of keyboard behavior
terminate or suspend the server
send a message to interested clients
simulate events on other keys
Each key has an optional list of actions. If present, this list parallels the list of symbols associated with the key (i.e. it has one action per symbol associated with the key). For key press events, the server looks up the action to be applied from this list using the key symbol mapping associated with the event key, just as a client looks up symbols as described in Determining the KeySym Associated with a Key Event; if the event key does not have any actions, the server uses the SA_NoAction event for that key regardless of modifier or group state.
Key actions have essentially two halves; the effects on the server when the key is pressed and the effects when the key is released. The action applied for a key press event determines the further actions, if any, that are applied to the corresponding release event or to events that occur while the key is held down. Clients can change the actions associated with a key while the key is down without changing the action applied next time the key is released; subsequent press-release pairs will use the newly bound key action.
Most actions directly change the state of the keyboard or server; some actions also modify other actions that occur simultaneously with them. Two actions occur simultaneously if the keys which invoke the actions are both logically down at the same time, regardless of the order in which they are pressed or delay between the activation of one and the other.
Most actions which affect keyboard modifier state accept a modifier definition (see Virtual Modifiers) named mods and a boolean flag name useModMap among their arguments. These two fields combine to specify the modifiers affected by the action as follows: If useModMap is True , the action sets any modifiers bound by the modifier mapping to the key that initiated the action; otherwise, the action sets the modifiers specified by mods . For brevity in the text of the following definitions, we refer to this combination of useModMap and mods as the "action modifiers."
The X Keyboard Extension supports the following actions:
| Action | Effect |
|---|---|
| SA_NoAction |
|
|
SA_SetMods mods: MOD_DEF useModMap: BOOL clearLocks: BOOL |
|
|
SA_LatchMods mods: MOD_DEF useModMap: BOOL clearLocks: BOOL latchToLock: BOOL |
|
|
SA_LockMods mods: MOD_DEF useModMap: BOOL noLock: BOOL noUnlock: BOOL |
|
|
SA_SetGroup group: INT8 groupAbsolute: BOOL clearLocks: BOOL |
|
|
SA_LatchGroup group: INT8 groupAbsolute: BOOL clearLocks: BOOL latchToLock: BOOL |
|
|
SA_LockGroup group: INT8 groupAbsolute: BOOL |
|
|
SA_MovePtr x, y: INT16 noAccel: BOOL absoluteX: BOOL absoluteY: BOOL |
|
|
SA_PtrBtn button: CARD8 count: CARD8 useDfltBtn: BOOL |
|
|
SA_LockPtrBtn button: BUTTON noLock: BOOL noUnlock: BOOL useDfltBtn: BOOL |
|
|
SA_SetPtrDflt affect: CARD8 value: CARD8 dfltBtnAbs: BOOL |
|
|
SA_ISOLock dfltIsGroup: False mods: MOD_DEF useModMap: BOOL noLock: BOOL noUnlock: BOOL noAffectMods: BOOL noAffectGrp: BOOL noAffectPtr: BOOL noAffectCtrls: BOOL or dfltIsGroup: True group: INT8 groupAbsolute: BOOL noAffectMods: BOOL noAffectGrp: BOOL noAffectPtr: BOOL noAffectCtrls: BOOL |
|
| SA_TerminateServer |
|
|
SA_SwitchScreen num: INT8 switchApp: BOOL screenAbs: BOOL |
|
|
SA_SetControls controls: KB_BOOLCTRLMASK |
|
|
SA_LockControls controls: KB_BOOLCTRLMASK noLock: BOOL noUnlock: BOOL |
|
|
SA_ActionMessage : pressMsg: BOOL releaseMsg: BOOL genEvent: BOOL message: STRING |
|
|
SA_RedirectKey newKey: KEYCODE modsMask: KEYMASK mods: KEYMASK vmodsMask: CARD16 vmods: CARD16 |
|
|
SA_DeviceBtn count: CARD8 button: BUTTON device: CARD8 |
|
|
SA_LockDeviceBtn button: BUTTON device: CARD8 noLock: BOOL noUnlock: BOOL |
|
|
SA_DeviceValuator device : CARD8 val1What : SA_DVOP val1 : CARD8 val1Value : INT8 val1Scale : 0...7 val2What : BOOL val2 : CARD8 val2Value : INT8 val2Scale : 0...7 |
|
If StickyKeys are enabled, all SA_SetMods and SA_SetGroup actions act like SA_LatchMods and SA_LatchGroup respectively. If the LatchToLock AccessX option is set, either action behaves as if both the SA_ClearLocks and SA_LatchToLock flags are set.
Actions which cause an event from another key or from a button on another device immediately generate the specified event. These actions do not consider the behavior or actions (if any) that are bound to the key or button to which the event is redirected.
Core events generated by server actions contain the keyboard state that was in effect at the time the key event occurred; the reported state does not reflect any changes in state that occur as a result of the actions bound to the key event that caused them.
Events sent to clients that have not issued an XkbUseExtension request contain a compatibility state in place of the actual XKB keyboard state. See Effects of XKB on Core Protocol Events for a description of this compatibility mapping.
The window and client that receive core protocol and input extension key or button events are determined using the focus policy, window hierarchy and passive grabs as specified by the core protocol and the input extension, with the following changes:
A passive grab triggers if the modifier state specified in the grab matches the grab compatibility state (described in Compatibility Components of Keyboard State). Clients can choose to use the XKB grab state instead by setting the GrabsUseXKBState per-client flag. This flag affects all passive grabs that are requested by the client which sets it but does not affect passive grabs that are set by any other client.
The state field of events which trigger a passive grab reports the XKB or compatibility grab state in effect at the time the grab is triggered; the state field of the corresponding release event reports the corresponding grab state in effect when the key or button is released.
If the LookupStateWhenGrabbed per-client flag is set, all key or button events that occur while a keyboard or pointer grab is active contain the XKB or compatibility lookup state, depending on the value of the GrabsUseXKBState per-client flag. If LookupStateWhenGrabbed is not set, they include the XKB or compatibility grab state, instead.
Otherwise, the state field of events that do not trigger a passive grab report is derived from the XKB effective modifiers and group, as described in Computing A State Field from an XKB State.
If a key release event is the result of an autorepeating key that is being held down, and the client to which the event is reported has requested detectable autorepeat (see Detectable Autorepeat), the event is not delivered to the client.
The following section explains the intent of the XKB interactions with core protocol grabs and the reason that the per-client flags are needed.
XKB provides the separate lookup and grab states to help work around some difficulties with the way the core protocol specifies passive grabs. Unfortunately, many clients work around those problems differently, and the way that XKB handles grabs and reports keyboard state can sometimes interact with those client workarounds in unexpected and unpleasant ways.
To provide more reasonable behavior for clients that are aware of XKB without causing problems for clients that are unaware of XKB, this extension provides two per-client flags that specify the way that XKB and the core protocol should interact.
The largest problems arise from the fact that an XKB state field encodes an explicit keyboard group in bits 13-14 (as described in Computing A State Field from an XKB State), while pre-XKB clients use one of the eight keyboard modifiers to select an alternate keyboard group. To make existing clients behave reasonably, XKB normally uses the compatibility grab state instead of the XKB grab state to determine whether or not a passive grab is triggered. XKB-aware clients can set the GrabsUseXKBState per-client flag to indicate that they are specifying passive grabs using an XKB state.
Some toolkits start an active grab when a passive grab is triggered, in order to have more control over the conditions under which the grab is terminated. Unfortunately, the fact that XKB reports a different state in events that trigger or terminate grabs means that this grab simulation can fail to terminate the grab under some conditions. To work around this problem, XKB normally reports the grab state in all events whenever a grab is active. Clients which do not use active grabs like this can set the LookupStateWhenGrabbed per-client flag in order to receive the same state component whether or not a grab is active.
The GrabsUseXKBState per-client flag also applies to the state of events sent while a grab is active. If it is set, events during a grab contain the XKB lookup or grab state; by default, events during a grab contain the compatibility lookup or grab state.
The state used to trigger a passive grab is controlled by the setting of the GrabsUseXKBState per-client flag at the time the grab is registered. Changing this flag does not affect existing passive grabs.
Table of Contents
The XKB client map for a keyboard is the collection of information a client needs to interpret key events that come from that keyboard. It contains a global list of key types , described in Key Types, and an array of key symbol map s, each of which describes the symbols bound to one particular key and the rules to be used to interpret those symbols.
XKB associates a two-dimensional array of symbols with each key. Symbols are addressed by keyboard group (see Keyboard State) and shift level, where level is defined as in the ISO9995 standard:
Level | One of several states (normally 2 or 3) which govern which graphic character is produced when a graphic key is actuated. In certain cases the level may also affect function keys. |
Note that shift level is derived from the modifier state, but not necessarily in the same way for all keys. For example, the Shift modifier selects shift level 2 on most keys, but for keypad keys the modifier bound to Num_Lock (i.e. the NumLock virtual modifier) also selects shift level 2.gray symbols on a key
We use the notation G n L n to specify the position of a symbol on a key or in memory:
The gray characters indicate symbols that are implied or expected but are not actually engraved on the key.
Unfortunately, the "natural" orientation of symbols on a key and the natural orientation in memory are reversed from one another, so keyboard group refers to a column on the key and a row in memory. There’s no real help for it, but we try to minimize confusion by using "group" and "level" (or "shift level") to refer to symbols regardless of context.
To look up the symbol associated with an XKB key event, we need to know the group and shift level that correspond to the event.
Group is reported in bits 13-14 of the state field of the key event, as described in Computing A State Field from an XKB State. The keyboard group reported in the event might be out-of-range for any particular key because the number of groups can vary from key to key. The XKB description of each key contains a group info field which is interpreted identically to the global groups wrap control (see Computing Effective Modifier and Group) and which specifies the interpretation of groups that are out-of-range for that key.
Once we have determined the group to be used for the event, we have to determine the shift level. The description of a key includes a key type for each group of symbols bound to the key. Given the modifiers from the key event, this key type yields a shift level and a set of "leftover" modifiers, as described in Key Types below.
Finally, we can use the effective group and the shift level returned by the type of that group to look up a symbol in a two-dimensional array of symbols associated with the key.
Each entry of a key type’s map field specifies the shift level that corresponds to some XKB modifier definition; any combination of modifiers that is not explicitly listed somewhere in the map yields shift level one. Map entries which specify unbound virtual modifiers (see Inactive Modifier Definitions) are not considered; each entry contains an automatically-updated active field which indicates whether or not it should be used.
Each key type includes a few fields that are derived from the contents of the map and which report some commonly used values so they don’t have to be constantly recalculated. The numLevels field contains the highest shift level reported by any of its map entries; XKB uses numLevels to insure that the array of symbols bound to a key is large enough (the number of levels reported by a key type is also referred to as its width). The modifiers field reports all real modifiers considered by any of the map entries for the type. Both modifiers and numLevels are updated automatically by XKB and neither can be changed explicitly.
Any modifiers specified in modifiers are normally consumed (see Transforming the KeySym Associated with a Key Event), which means that they are not considered during any of the later stages of event processing. For those rare occasions that a modifier should be considered despite having been used to look up a symbol, key types include an optional preserve field. If a preserve list is present, each entry corresponds to one of the key type’s map entries and lists the modifiers that should not be consumed if the matching map entry is used to determine shift level.
For example, the following key type implements caps lock as defined by the core protocol (using the second symbol bound to the key):
type "ALPHABETIC" {
modifiers = Shift+Lock;
map[Shift]= Level2;
map[Lock]= Level2;
map[Shift+Lock]= Level2;
};
The problem with this kind of definition is that we could assign completely unrelated symbols to the two shift levels, and "Caps Lock" would choose the second symbol. Another definition for alphabetic keys uses system routines to capitalize the keysym:
type "ALPHABETIC" {
modifiers= Shift;
map[Shift]= Level2;
};
When caps lock is applied using this definition, we take the symbol from shift level one and capitalize it using system-specific capitalization rules. If shift and caps lock are both set, we take the symbol from shift level two and try to capitalize it, which usually has no effect.
The following key type implements shift-cancels-caps lock behavior for alphabetic keys:
type "ALPHABETIC" {
modifiers = Shift+Lock;
map[Shift] = Level2;
preserve[Lock]= Lock;
};
Consider the four possible states that can affect alphabetic keys: no modifiers, shift alone, caps lock alone or shift and caps lock together. The map contains no explicit entry for None (no modifiers), so if no modifiers are set, any group with this type returns the first keysym. The map entry for Shift reports Level2 , so any group with this type returns the second symbol when Shift is set. There is no map entry for Lock alone, but the type specifies that the Lock modifier should be preserved in this case, so Lock alone returns the first symbol in the group but first applies the capitalization transformation, yielding the capital form of the symbol. In the final case, there is no map entry for Shift+Lock , so it returns the first symbol in the group; there is no preserve entry, so the Lock modifier is consumed and the symbol is not capitalized.
The key symbol map for a key contains all of the information that a client needs to process events generated by that key. Each key symbol mapping reports:
The number of groups of symbols bound to the key ( numGroups ).
The treatment of out-of-range groups ( groupInfo ).
The index of the key type to for each possible group ( kt_index[MaxKbdGroups] ).
The width of the widest type associated with the key ( groupsWidth ).
The two-dimensional (numGroups × groupsWidth) array of symbols bound to the key.
It is legal for a key to have zero groups, in which case it also has zero symbols and all events from that key yield NoSymbol . The array of key types is of fixed width and is large enough to hold key types for the maximum legal number of groups ( MaxKbdGroups , currently four); if a key has fewer than MaxKbdGroups groups, the extra key types are reported but ignored. The groupsWidth field cannot be explicitly changed; it is updated automatically whenever the symbols or set of types bound to a key are changed.
If, when looking up a symbol, the effective keyboard group is out-of-range for the key, the groupInfo field of the key symbol map specifies the rules for determining the corresponding legal group as follows:
If the RedirectIntoRange flag is set, the two least significant bits of groupInfo specify the index of a group to which all illegal groups correspond. If the specified group is also out of range, all illegal groups map to Group1 .
If ClampIntoRange flag is set, out-of-range groups correspond to the nearest legal group. Effective groups larger than the highest supported group are mapped to the highest supported group; effective groups less than Group1 are mapped to Group1 . For example, a key with two groups of symbols uses Group2 type and symbols if the global effective group is either Group3 or Group4 .
If neither flag is set, group is wrapped into range using integer modulus. For example, a key with two groups of symbols for which groups wrap uses Group1 symbols if the global effective group is Group3 or Group2 symbols if the global effective group is Group4 .
The client map contains an array of key symbol mappings, with one entry for each key between the minimum and maximum legal keycodes, inclusive. All keycodes which fall in that range have key symbol mappings, whether or not any key actually yields that code.
Any modifiers that were not used to look up the keysym, or which were explicitly preserved, might indicate further transformations to be performed on the keysym or the character string that is derived from it. For example, If the Lock modifier is set, the symbol and corresponding string should be capitalized according to the locale-sensitive capitalization rules specified by the system. If the Control modifier is set, the keysym is not affected, but the corresponding character should be converted to a control character as described in Default Symbol Transformations.
This extension specifies the transformations to be applied when the Control or Lock modifiers are active but were not used to determine the keysym to be used:
| Modifier | Transformation |
|---|---|
| Control | Report the control character associated with the symbol. This extension defines the control characters associated with the ASCII alphabetic characters (both upper and lower case) and for a small set of punctuation characters (see Default Symbol Transformations). Applications are free to associate control characters with any symbols that are not specified by this extension. |
| Lock | Capitalize the symbol either according to capitalization rules appropriate to the application locale or using the capitalization rules defined by this extension (see Default Symbol Transformations). |
Interpretation of other modifiers is application dependent.
This definition of capitalization is fundamentally different from the core protocol’s, which uses the lock modifier to select from the symbols bound to the key. Consider key 9 in the client map example; the core protocol provides no way to generate the capital form of either symbol bound to this key. XKB specifies that we first look up the symbol and then capitalize, so XKB yields the capital form of the two symbols when caps lock is active.
XKB specifies the behavior of Lock and Control , but interpretation of other modifiers is left to the application.
Consider a simple, if unlikely, keyboard with the following keys (gray characters indicate symbols that are implied or expected but are not actually engraved on the key):
The core protocol represents this keyboard as a simple array with one row per key and four columns (the widest key, key 10, determines the width of the entire array).
| Key | G1L1 | G1L2 | G2L1 | G2L2 |
|---|---|---|---|---|
| 8 | Q | NoSymbol | at | NoSymbol |
| 9 | odiaeresis | egrave | NoSymbol | NoSymbol |
| 10 | A | NoSymbol | Æ | NoSymbol |
| 11 | ssharp | question | backslash | questiondown |
| 12 | KP_End | KP_1 | NoSymbol | NoSymbol |
| 13 | Num_Lock | NoSymbol | NoSymbol | NoSymbol |
| 14 | NoSymbol | NoSymbol | NoSymbol | NoSymbol |
| 15 | Return | NoSymbol | NoSymbol | NoSymbol |
The row to be used for a given key event is determined by keycode; the column to be used is determined by the symbols bound to the key, the state of the Shift and Lock Modifiers and the state of the modifiers bound to the Num_Lock and Mode_switch keys as specified by the core protocol.
The XKB description of this keyboard consists of six key symbol maps, each of which specifies the types and symbols associated with each keyboard group for one key:
| Key | Group: Type | L1 | L2 |
|---|---|---|---|
| 8 | G1: ALPHABETIC | q | Q |
| G2: ONE_LEVEL | @ | NoSymbol | |
| 9 | G1: TWO_LEVEL | odiaeresis | egrave |
| 10 | G1: ALPHABETIC | a | A |
| G2: ALPHABETIC | ae | AE | |
| 11 | G1: TWO_LEVEL | ssharp | question |
| G2: ONE_LEVEL | backslash | questiondown | |
| 12 | G1: KEYPAD | KP_End | KP_1 |
| 13 | G1: ONE_LEVEL | Num_Lock | |
| 14 | No Groups | ||
| 15 | G1: ONE_LEVEL | Return |
The keycode reported in a key event determines the row to be used for that event; the effective keyboard group determines the list of symbols and key type to be used. The key type determines which symbol is chosen from the list.
Determining the KeySym Associated with a Key Event details the procedure to map from a key event to a symbol and/or a string.
The core protocol does not provide any information to clients other than that actually used to interpret events. This makes it difficult to write a client which presents the keyboard to a user in an easy-to-understand way. Such applications have to examine the vendor string and keycodes to determine the type of keyboard connected to the server and have to examine keysyms and modifier mappings to determine the effects of most modifiers (the Shift , Lock and Control modifiers are defined by the core protocol but no semantics are implied for any other modifiers).
This extension provides such applications with symbolic names for most components of the keyboard extension and a description of the physical layout of the keyboard.
The keycodes name describes the range and meaning of the keycodes returned by the keyboard in question; the keyboard geometry name describes the physical location, size and shape of the various keys on the keyboard. As an example to distinguish between these two names, consider function keys on PC-compatible keyboards. Function keys are sometimes above the main keyboard and sometimes to the left of the main keyboard, but the same keycode is used for the key that is logically F1 regardless of physical position. Thus, all PC-compatible keyboards might share a keycodes name but different geometry names.
The keycodes name is intended to be a very general description of the keycodes returned by a keyboard; A single keycodes name might cover keyboards with differing numbers of keys provided that the keys that all keys have the same semantics when present. For example, 101 and 102 key PC keyboards might use the same name. Applications can use the keyboard geometry to determine which subset of the named keyboard type is in use.
The symbols name identifies the symbols bound to the keys. The symbols name is a human or application-readable description of the intended locale or usage of the keyboard with these symbols. The physical symbols name describes the symbols actually engraved on the keyboard, which might be different than the symbols currently being used.
The types name provides some information about the set of key types that can be associated with the keyboard keys. The compat name provides some information about the rules used to bind actions to keys changed using core protocol requests.
The compat , types , keycodes , symbols and geometry names typically correspond to the keyboard components from which the current keyboard description was assembled. These components are stored individually in the server’s database of keyboard components, described in The Server Database of Keyboard Components, and can be combined to assemble a complete keyboard description.
Each key has a four-byte symbolic name. The key name links keys with similar functions or in similar positions on keyboards that report different scan codes. Key aliases allow the keyboard layout designer to assign multiple names to a single key, to make it easier to refer to keys using either their position or their "function."
For example, consider the common keyboard customizations:
Set the "key to the left of the letter a" to be a control key.
Change the "caps lock" key, wherever it might be, to a control key.
If we specify key names by position, the first customization is simple but the second is impossible; if we specify key names by function, the second customization is simple but the first is impossible. Using key aliases, we can specify both function and position for "troublesome" keys, and both customizations are straightforward.
Key aliases can be specified both in the symbolic names component and in the keyboard geometry (see Keyboard Geometry). Both sets of aliases are always valid, but key alias definitions in the keyboard geometry have priority; if both symbolic names and geometry include aliases, applications should consider the definitions from the geometry before considering the definitions from the symbolic names section.
XKB provides symbolic names for each of the four keyboard groups, sixteen virtual modifiers, thirty-two keyboard indicators, and up to MaxRadioGroups (32) radio groups.
XKB allows keyboard layout designers or editors to assign names to each key type and to each of the levels in a key type. For example, the second position on an alphabetic key might be called the "Caps" level while the second position on a numeric keypad key might be called the "Num Lock" level.
Although the core X protocol supports thirty-two LEDs on a keyboard, it does not provide any way to link the state of the LEDs and the logical state of the keyboard. For example, most keyboards have a "Caps Lock" LED, but X does not provide any standard way to make the LED automatically follow the logical state of the modifier bound to the Caps Lock key.
The core protocol also gives no way to determine which bits in the led_mask field of the keyboard state map to the particular LEDs on the keyboard. For example, X does not provide a method for a client to determine which bit to set in the led_mask to turn on the "Scroll Lock" LED, or even if the keyboard has a "Scroll Lock" LED.
Most X servers implement some kind of automatic behavior for one or more of the keyboard LEDs, but the details of that automatic behavior are implementation-specific and can be difficult or impossible to control.
XKB provides indicator names and programmable indicators to help solve these problems. Using XKB, clients can determine the names of the various indicators, determine and control the way that the individual indicators should be updated to reflect keyboard changes, and determine which of the 32 keyboard indicators reported by the protocol are actually present on the keyboard. Clients may also request immediate notification of changes to the state of any subset of the keyboard indicators, which makes it straightforward to provide an on-screen "virtual" LED panel.
XKB provides only two pieces of information about the indicators as a group.
The physical indicators mask reports which of the 32 logical keyboard indicators supported by the core protocol and XKB corresponds to some actual indicator on the keyboard itself. Because the physical indicators mask describes a physical characteristic of the keyboard, it cannot be directly changed under program control. It is possible, however, for the set of physical indicators to be change if a new keyboard is attached or if a completely new keyboard description is loaded by the XkbGetKeyboardByName request (see Using the Server’s Database of Keyboard Components).
The indicator state mask reports the current state of the 32 logical keyboard indicators. This field and the core protocol indicator state (as reported by the led-mask field of the core protocol GetKeyboardControl request) are always identical.
Each of the thirty-two keyboard indicators has a symbolic name, of type ATOM. The XkbGetNames request reports the symbolic names for all keyboard components, including the indicators. Use the XkbSetNames request to change symbolic names. Both requests are described in Querying and Changing Symbolic Names.
XKB also provides an indicator map for each of the thirty-two keyboard indicators; an indicator map specifies:
The conditions under which the keyboard modifier state affects the indicator.
The conditions under which the keyboard group state affects the indicator.
The conditions under which the state of the boolean controls affects the indicator.
The effect (if any) of attempts to explicitly change the state of the indicator using the core protocol SetKeyboardControl request.
If IM_NoAutomatic is set in the flags field of an indicator map, that indicator never changes in response to changes in keyboard state or controls, regardless of the values for the other fields of the indicator map. If IM_NoAutomatic is not set in flags , the other fields of the indicator map specify the automatic changes to the indicator in response to changes in the keyboard state or controls.
The which_groups and the groups fields of an indicator map determine how the keyboard group state affects the corresponding indicator. The which_groups field controls the interpretation of groups and may contain any one of the following values:
| Value | Interpretation of the Groups Field |
|---|---|
| IM_UseNone | The groups field and the current keyboard group state are ignored. |
| IM_UseBase | If groups is non-zero, the indicator is lit whenever the base keyboard group is non-zero. If groups is zero, the indicator is lit whenever the base keyboard group is zero. |
| IM_UseLatched | If groups is non-zero, the indicator is lit whenever the latched keyboard group is non-zero. If groups is zero, the indicator is lit whenever the latched keyboard group is zero. |
| IM_UseLocked | The groups field is interpreted as a mask. The indicator is lit when the current locked keyboard group matches one of the bits that are set in groups . |
| IM_UseEffective | The groups field is interpreted as a mask. The indicator is lit when the current effective keyboard group matches one of the bits that are set in groups . |
The which_mods and mods fields of an indicator map determine how the state of the keyboard modifiers affect the corresponding indicator. The mods field is an XKB modifier definition, as described in Modifier Definitions, which can specify both real and virtual modifiers. The mods field takes effect even if some or all of the virtual indicators specified in mods are unbound.
The which_mods field can specify one or more components of the XKB keyboard state. The corresponding indicator is lit whenever any of the real modifiers specified in the mask field of the mods modifier definition are also set in any of the current keyboard state components specified by the which_mods . The which_mods field may have any combination of the following values:
| Value | Keyboard State Component To Be Considered |
|---|---|
| IM_UseBase | Base modifier state |
| IM_UseLatched | Latched modifier state |
| IM_UseLocked | Locked modifier state |
| IM_UseEffective | Effective modifier state |
| IM_UseCompat | Modifier compatibility state |
The controls field specifies a subset of the boolean keyboard controls (see "Boolean" Controls and The EnabledControls Control). The indicator is lit whenever any of the boolean controls specified in controls are enabled.
An indicator is lit whenever any of the conditions specified by its indicator map are met, unless overridden by the IM_NoAutomatic flag (described above) or an explicit indicator change (described below).
If the IM_NoExplicit flag is set in an indicator map, attempts to change the state of the indicator are ignored.
If both IM_NoExplicit and IM_NoAutomatic are both absent from an indicator map, requests to change the state of the indicator are honored but might be immediately superseded by automatic changes to the indicator state which reflect changes to keyboard state or controls.
If the IM_LEDDrivesKB flag is set and the IM_NoExplicit flag is not, the keyboard state and controls are changed to reflect the other fields of the indicator map, as described in the remainder of this section. Attempts to explicitly change the value of an indicator for which IM_LEDDrivesKB is absent or for which IM_NoExplicit is present do not affect keyboard state or controls.
The effect on group state of changing an explicit indicator which drives the keyboard is determined by the value of which_groups and groups , as follows:
| which_groups | New State | Effect on Keyboard Group State |
|---|---|---|
| IM_UseNone , or IM_UseBase | On or Off | No Effect |
| IM_UseLatched | On | The groups field is treated as a group mask. The keyboard group latch is changed to the lowest numbered group specified in groups ; if groups is empty, the keyboard group latch is changed to zero. |
| IM_UseLatched | Off | The groups field is treated as a group mask. If the indicator is explicitly extinguished, keyboard group latch is changed to the lowest numbered group not specified in groups ; if groups is zero, the keyboard group latch is set to the index of the highest legal keyboard group. |
| IM_UseLocked , or IM_UseEffective | On | If the groups mask is empty, group is not changed, otherwise the locked keyboard group is changed to the lowest numbered group specified in groups . |
| IM_UseLocked , or IM_UseEffective | Off | Locked keyboard group is changed to the lowest numbered group that is not specified in the groups mask, or to Group1 if the groups mask contains all keyboard groups. |
The effect on the keyboard modifiers of changing an explicit indicator which drives the keyboard is determined by the values that are set in of which_mods and mods , as follows:
| Set in which_mods | New State | Effect on Keyboard Modifiers |
|---|---|---|
| IM_UseBase | On or Off | No Effect |
| IM_UseLatched | On | Any modifiers specified in the mask field of mods are added to the latched modifiers. |
| IM_UseLatched | Off | Any modifiers specified in the mask field of mods are removed from the latched modifiers. |
| IM_UseLocked , IM_UseCompat , or IM_UseEffective | On | Any modifiers specified in the mask field of mods are added to the locked modifiers. |
| IM_UseLocked | Off | Any modifiers specified in the mask field of mods are removed from the locked modifiers. |
| IM_UseCompat , or IM_UseEffective | Off | Any modifiers specified in the mask field of mods are removed from both the locked and latched modifiers. |
Lighting an explicit indicator which drives the keyboard also enables all of the boolean controls specified in the controls field of its indicator map. Explicitly extinguishing such an indicator disables all of the boolean controls specified in controls .
The effects of changing an indicator which drives the keyboard are cumulative; it is possible for a single change to affect keyboard group, modifiers and controls simultaneously.
If an indicator for which both the IM_LEDDrivesKB and IM_NoAutomatic flags are specified is changed, the keyboard changes specified above are applied and the indicator is changed to reflect the state that was explicitly requested. The indicator will remain in the new state until it is explicitly changed again.
If the IM_NoAutomatic flag is not set for an indicator which drives the keyboard, the changes specified above are applied and the state of the indicator is set to the values specified by the indicator map. Note that it is possible in this case for the indicator to end up in a different state than the one that was explicitly requested. For example, an indicator with which_mods of IM_UseBase and mods of Shift is not extinguished if one of the Shift keys is physically depressed when the request to extinguish the indicator is processed.
Table of Contents
The core protocol provides requests to control the pitch, volume and duration of the keyboard bell and a request to explicitly sound the bell.
The X Keyboard Extension allows clients to disable the audible bell, attach a symbolic name to a bell request or receive an event when the keyboard bell is rung.
Clients can ask to receive XkbBellNotify event when a bell is requested by a client or generated by the server. Bells can be sounded due to core protocol Bell requests, X Input Extension DeviceBell requests, X Keyboard Extension XkbBell requests or for reasons internal to the server such as the XKB AccessXFeedback control.
Bell events caused by the XkbBell request or by the AccessXFeedback control include an optional window and symbolic name for the bell. If present, the window makes it possible to provide some kind of visual indication of which window caused the sound. The symbolic name can report some information about the reason the bell was generated and makes it possible to generate a distinct sound for each type of bell.
The global AudibleBell boolean control for a keyboard indicates whether bells sent to that device should normally cause the server to generate a sound. Applications which provide "sound effects" for the various named bells will typically disable the server generation of bells to avoid burying the user in sounds.
When the AudibleBell control is active, all bells caused by core protocol Bell and X Input Extension DeviceBell requests cause the server to generate a sound, as do all bells generated by the XKB AccessXFeedback control. Bells requested via the X kbBell request normally cause a server-generated sound, but clients can ask the server not to sound the default keyboard bell.
When the AudibleBell control is disabled, the server generates a sound only for bells that are generated using the XkbBell request and which specify forced delivery of the bell.
The XkbBell request allows clients to specify a symbolic name which is reported in the bell events they cause. Bells generated by the AccessXFeedback control of this extension also include a symbolic name, but all kinds of feedback cause a single event even if they sound multiple tones.
The X server is permitted to use symbolic bell names (when present) to generate sounds other than simple tones, but it is not required to do so.
Aside from those used by the XKB AccessXFeedback control (see The AccessXFeedback Control), this extension does not specify bell names or their interpretation.
Under some circumstances, some kind of quiet audio feedback is useful, but a normal keyboard bell is not. For example, a quiet "launch effect" can be helpful to let the user know that an application has been started, but a loud bell would simply be annoying.
To simplify generation of these kinds of effects, the XkbBell request allows clients to specify "event only" bells. The X server never generates a normal keyboard bell for "event only" bells, regardless of the setting of the global AudibleBell control.
If the X server generates different sounds depending bell name, it is permitted to generate a sound even for "event only" bells. This field is intended simply to weed out "normal" keyboard bells.
Occasionally, it is useful to force the server to generate a sound. For example, a client could "filter" server bells, generating sound effects for some but sounding the normal server bell for others. Such a client needs a way to tell the server that the requested bell should be generated regardless of the setting of the AudibleBell control.
To simplify this process, clients which call the XkbBell request can specify that a bell is forced. A forced bell always causes a server generated sound and never causes a XkbBellNotify event. Because forced bells do not cause bell notify events, they have no associated symbolic name or event window.
Table of Contents
The XKB description of a keyboard includes an optional keyboard geometry which describes the physical appearance of the keyboard. Keyboard geometry describes the shape, location and color of all keyboard keys or other visible keyboard components such as indicators. The information contained in a keyboard geometry is sufficient to allow a client program to draw an accurate two-dimensional image of the keyboard.
The components of the keyboard geometry include the following:
A symbolic name to help users identify the keyboard.
The width and height of the keyboard, in
. For non-rectangular keyboards, the width and height describe the smallest bounding-box that encloses the outline of the keyboard.
A list of up to MaxColors ( 32 ) color names . A color name is a string whose interpretation is not specified by XKB. Other geometry components refer to colors using their indices in this list.
The base color of the keyboard is the predominant color on the keyboard and is used as the default color for any components whose color is not explicitly specified.
The label color is the color used to draw the labels on most of the keyboard keys.
The label font is a string which describes the font used to draw labels on most keys; XKB does not specify a format or name space for font names.
A list of geometry properties . A geometry property associates an arbitrary string with an equally arbitrary name. Geometry properties can be used to provide hints to programs that display images of keyboards, but they are not interpreted by XKB. No other geometry structures refer to geometry properties.
A list of key aliases , as described in Symbolic Names.
A list of shapes ; other keyboard components refer to shapes by their index in this list. A shape consists of a name and one or more closed-polygons called outlines . Shapes and outlines are described in detail in Shapes and Outlines.
Unless otherwise specified, geometry measurements are in
units. The origin (0,0) is in the top left corner of the keyboard image. Some geometry components can be drawn rotated; all such objects rotate about their origin in
increments.
All geometry components include a priority , which indicates the order in which overlapping objects should be drawn. Objects are drawn in order from highest priority ( 0 ) to lowest ( 255 ).
The description of the actual appearance of the keyboard is subdivided into named sections of related keys and doodads . A a doodad describes some visible aspect of the keyboard that is not a key. A section is a collection of keys and doodads that are physically close together and logically related.
An outline is a list of one or more points which describes a single closed-polygon, as follows:
A list with a single point describes a rectangle with one corner at the origin of the shape ( 0 , 0 ) and the opposite corner at the specified point.
A list of two points describes a rectangle with one corner at the position specified by the first point and the opposite corner at the position specified by the second point.
A list of three or more points describes an arbitrary polygon. If necessary, the polygon is automatically closed by connecting the last point in the list with the first.
A non-zero value for the cornerRadius field specifies that the corners of the polygon should be drawn as circles with the specified radius.
All points in an outline are specified relative to the origin of the enclosing shape. Points in an outline may have negative values for the X and Y coordinate.
One outline (usually the first) is the primary outline; a keyboard display application can generate a simpler but still accurate keyboard image by displaying only the primary outlines for each shape. Non-rectangular keys must include a rectangular approximation as one of the outlines associated with the shape; the approximation is not normally displayed but can be used by very simple keyboard display applications to generate a recognizable but degraded image of the keyboard.
Each section has its own coordinate system — if a section is rotated, the coordinates of any components within the section are interpreted relative to the edges that were on the top and left before rotation. The components that make up a section include:
A list of rows . A row is a list of horizontally or vertically adjacent keys. Horizontal rows parallel the (pre-rotation) top of the section and vertical rows parallel the (pre-rotation) left of the section. All keys in a horizontal row share a common top coordinate; all keys in a vertical row share a left coordinate.
A key description consists of a key name , a shape , a key color , and a gap . The key name should correspond to one of the keys named in the keyboard names description, the shape specifies the appearance of the key, and the key color specifies the color of the key (not the label on the key). Keys are normally drawn immediately adjacent to one another from left-to-right (or top-to-bottom) within a row. The gap field specifies the distance between a key and its predecessor.
An optional list of doodads; any type of doodad can be enclosed within a section. Position and angle of rotation are relative to the origin and angle of rotation of the sections that contain them. Priority is relative to the other components of the section, not to the keyboard as a whole.
An optional list of overlay keys . Each overlay key definition indicates a key that can yield multiple scan codes and consists of a field named under , which specifies the primary name of the key and a field named over , which specifies the name for the key when the overlay keycode is selected. The key specified in under must be a member of the section that contains the overlay key definition, while the key specified in over must not.
Doodads can be global to the keyboard or part of a section. Doodads have symbolic names of arbitrary length. The only doodad name whose interpretation is specified by XKB is "Edges", which describes the outline of the entire keyboard, if present.
All doodads report their origin in fields named left and top . XKB supports five kinds of doodads:
An indicator doodad describes one of the physical keyboard indicators. Indicator doodads specify the shape of the indicator, the indicator color when it is lit ( on_color ) and the indicator color when it is dark ( off_color ).
An outline doodad describes some aspect of the keyboard to be drawn as one or more hollow, closed polygons. Outline doodads specify the shape, color, and angle of rotation about the doodad origin at which they should be drawn.
A solid doodad describes some aspect of the keyboard to be drawn as one or more filled polygons. Solid doodads specify the shape, color and angle of rotation about the doodad origin at which they should be drawn.
A text doodad describes a text label somewhere on the keyboard. Text doodads specify the label string, the font and color to use when drawing the label, and the angle of rotation of the doodad about its origin.
A logo doodad is a catch-all, which describes some other visible element of the keyboard. A logo doodad is essentially an outline doodad with an additional symbolic name that describes the element to be drawn.
If a keyboard display program recognizes the symbolic name, it can draw something appropriate within the bounding region of the shape specified in the doodad. If the symbolic name does not describe a recognizable image, it should draw an outline using the specified shape, outline, and angle of rotation.
The XKB extension does not specify the interpretation of logo names.
Consider the following example keyboard:
This keyboard has six sections: The left and right function sections (at the very top) each have one horizontal row with eight keys. The left and right alphanumeric sections (the large sections in the middle) each have six vertical rows, with four or five keys in each row. The left and right editing sections each have three vertical rows with one to three keys per row; the left editing section is rotated 20° clockwise about its origin while the right editing section is rotated 20° counterclockwise.
This keyboard has four global doodads: Three small, round indicators and a rectangular logo. The program which generated this image did not recognize the logo, so it displays an outline with an appropriate shape in its place.
This keyboard has seven shapes: All of the keys in the two function sections use the "FKEY" shape. Most of the keys in the alphanumeric sections, as well as four of the keys in each of the editing sections use the "NORM" shape. The keys in the first column of the left alphanumeric section and the last column of the right alphanumeric section all use the "WIDE" shape. Two keys in each of the editing sections use the "TALL" shape. The "LED" shape describes the three small, round indicators between the function and alphabetic sections. The "LOGO" shape describes the keyboard logo, and the "EDGE" shape describes the outline of the keyboard as a whole.
The keyboard itself is white, as are all of the keys except for the eight keys that make up the home row, which use the "grey20" color. It isn’t really visible in this picture, but the three indicators have an "on" color of "green" and are "green30" when they are turned off. The keys in the alphanumeric and editing sections all have a (vertical) gap of 0.5mm; the keys in the two function sections have a (horizontal) gap of 3mm.
Many of the keys in the right alphanumeric section, and the rightmost key in the right editing section are drawn with two names in this image. Those are overlay keys; the bottom key name is the normal name while the overlay name is printed at the top. For example, the right editing section has a single overlay key entry, which specifies an under name of <SPCE> and an over name of <KP0> , which indicates that the key in question is usually the shift key, but can behave like the 0 key on the numeric keypad when an overlay is active.
Table of Contents
In addition to providing a number of new requests, XKB replaces or extends existing core protocol requests and events. Some aspects of the this extension, such as the ability to lock any key or modifier, are visible even to clients that are unaware of the XKB extension. Other capabilities, such as control of keysym selection on a per-key basis, are available only to XKB-aware clients.
Though they do not have access to some advanced extension capabilities, the XKB extension includes compatibility mechanisms to ensure that non-XKB clients behave as expected and operate at least as well with an XKB-capable server as they do today.
There are a few significant areas in which XKB state and mapping differences might be visible to XKB-unaware clients:
The core protocol uses a modifier to choose between two keyboard groups, while this extension provides explicit support for multiple groups.
The order of the symbols associated with any given key by XKB might not match the ordering demanded by the core protocol.
To minimize problems that might result from these differences, XKB includes ways to specify the correspondence between core protocol and XKB modifiers and symbols.
This section describes the differences between the core X protocol’s notion of a keyboard mapping and XKB and explains the ways they can interact.
As described in Keyboard State, the current keyboard group is reported to XKB-aware clients in bits 13-14 of the state field of many core protocol events. XKB-unaware clients cannot interpret those bits, but they might use a keyboard modifier to implement support for a single keyboard group. To ensure that pre-XKB clients continue to work when XKB is present, XKB makes it possible to map an XKB state field, which includes both keyboard group and modifier state into a pre-XKB state field which contains only modifiers.
A keyboard description includes one group compatibility map per keyboard group (four in all). Each such map is a modifier definition (i.e. specifies both real and virtual modifiers) which specifies the modifiers to be set in the compatibility states when the corresponding keyboard group is active. Here are a few examples to illustrate the application of the group compatibility map:
| Group | GroupCompat Map | Effective Modifiers | State for XKB Clients | Compatibility Modifiers | State for non-XKB Clients |
|---|---|---|---|---|---|
| 1 | Group1=None | Shift | x00xxxxx00000001 | Shift | xxxxxxxx00000001 |
| 2 | Group2=Mod3 | None | x01xxxxx00000000 | Mod3 | xxxxxxxx00100000 |
| 3 | Group3=Mod2 | Shift | x10xxxxx00000001 | Shift+Mod2 | xxxxxxxx00010001 |
| 4 | Group4=None | Control | x11xxxxx00000100 | Control | xxxxxxxx00000100 |
Note that non-XKB clients (i.e. clients that are linked with a version of the X library that does not support XKB) cannot detect the fact that Group4 is active in this example because the group compatibility map for Group4 does not specify any modifiers.
The fact that the state field of an event might look different when XKB is present can cause problems with passive grabs. Existing clients specify the modifiers they wish to grab using the rules defined by the core protocol, which use a normal modifier to indicate keyboard group. If we used an XKB state field, the high bits of the state field would be non-zero whenever the keyboard was in any group other than Group1 , and none of the passive grabs set by clients could ever be triggered.
To avoid this behavior, the X server normally uses the compatibility grab state to decide whether or not to activate a passive grab, even for XKB-aware clients. The group compatibility map attempts to encode the keyboard group in one or more modifiers of the compatibility state, so existing clients continue to work exactly the way they do today. By default, there is no way to directly specify a keyboard group in a Grabbed or GrabButton request, but groups can be specified indirectly by correctly adjusting the group compatibility map.
Clients that wish to specify an XKB keyboard state, including a separate keyboard group, can set the GrabsUseXKBState per-client flag which indicates that all subsequent key and button grabs from the requesting clients are specified using an XKB state.
Whether the XKB or core state should be used to trigger a grab is determined by the setting of the GrabsUseXKBState flag for the requesting client at the time the key or button is grabbed. There is no way to change the state to be used for a grab that is already registered or for grabs that are set by some other client.
An XKB keyboard description includes a lot of information that is not present in the core protocol description of a keyboard. Whenever a client remaps the keyboard using core protocol requests, XKB examines the map to determine likely default values for the components that cannot be specified using the core protocol.
Some aspects of this automatic mapping are configurable, and make it fairly easy to take advantage of many XKB features using existing tools like xmodmap , but much of the process of mapping a core keyboard description into an XKB description is designed to preserve compatible behavior for pre-XKB clients and cannot be redefined by the user. Clients or users that want behavior that cannot be described using this mapping should use XKB functions directly.
This automatic remapping might accidentally replace definitions that were explicitly requested by an application, so the XKB keyboard description defines a set of explicit components for each key; any components that are listed in the explicit components for a key are not changed by the automatic keyboard mapping. The explicit components field for a key can contain any combination of the following values:
| Bit in Explicit Mask | Protects Against |
|---|---|
| ExplicitKeyType1 | Automatic determination of the key type associated with Group1 (see Assigning Types To Groups of Symbols for a Key) |
| ExplicitKeyType2 | Automatic determination of the key type associated with Group2 (see Assigning Types To Groups of Symbols for a Key) |
| ExplicitKeyType3 | Automatic determination of the key type associated with Group3 (see Assigning Types To Groups of Symbols for a Key). |
| ExplicitKeyType4 | Automatic determination of the key type associated with Group4 (see Assigning Types To Groups of Symbols for a Key). |
| ExplicitInterpret | Application of any of the fields of a symbol interpretation to the key in question (see Assigning Actions To Keys). |
| ExplicitAutoRepeat | Automatic determination of autorepeat status for the key, as specified in a symbol interpretation (see Assigning Actions To Keys). |
| ExplicitBehavior | Automatic assignment of the KB_Lock behavior to the key, if the LockingKey flag is set in a symbol interpretation (see Assigning Actions To Keys). |
| ExplicitVModMap | Automatic determination of the virtual modifier map for the key based on the actions assigned to the key and the symbol interpretations which match the key (see Assigning Actions To Keys). |
The first step in applying the changes specified by a core protocol ChangeKeyboardMapping request to the XKB description of a keyboard is to determine the number of groups that are defined for the key and the width of each group. The XKB extension does not change key types in response to core protocol SetModifierMapping requests, but it does choose key actions as described in Assigning Actions To Keys.
Determining the number of symbols required for each group is straightforward. If the key type for some group is not protected by the corresponding ExplicitKeyType component, that group has two symbols. If any of the explicit components for the key include ExplicitKeyType3 or ExplicitKeyType4 , the width of the key type currently assigned to that group determines the number of symbols required for the group in the core protocol keyboard description. The explicit type components for Group1 and Group2 behave similarly, but for compatibility reasons the first two groups must have at least two symbols in the core protocol symbol mapping. Even if an explicit type assigned to either of the first two keyboard groups has fewer than two symbols, XKB requires two symbols for it in the core keyboard description.
If the core protocol request contains fewer symbols than XKB needs, XKB adds trailing NoSymbol keysyms to the request to pad it to the required length. If the core protocol request includes more symbols than it needs, XKB truncates the list of keysyms to the appropriate length.
Finally, XKB divides the symbols from the (possibly padded or truncated) list of symbols specified by the core protocol request among the four keyboard groups. In most cases, the symbols for each group are taken from the core protocol definition in sequence (i.e. the first pair of symbols is assigned to Group1 , the second pair of symbols is assigned to Group2 , and so forth). If either Group1 or Group2 has an explicitly defined key type with a width other than two, it gets a little more complicated.
The server assigns the first four symbols from the expanded or truncated map to the symbol positions G1L1 , G1L2, G2L1 and G2L2, respectively. If the key type assigned to Group1 reports more than two shift levels, the fifth and following symbols contain the extra keysyms for Group2 . If the key type assigned to Group2 reports more than two shift levels, the extra symbols follow the symbols (if any) for Group1 in the core protocol list of symbols. Symbols for Group3 and Group4 are contiguous and follow the extra symbols, if any, for Group1 and Group2 .
For example, consider a key with a key type that returns three shift levels bound to each group. The symbols bound to the core protocol are assigned in sequence to the symbol positions:
G1L1, G1L2, G2L1, G2L2, G1L3, G2L3, G3L1, G3L2, G3L3, G4L1, G4L2, and G4L3
For a key with a width one key type on group one, a width two key type on group two and a width three key type on group three, the symbols bound to the key by the core protocol are assigned to the following key positions:
G1L1, (G1L2), G2L1, G2L2, G3L1, G3L2, G3L3
Note that the second and fourth symbols (positions G1L2 and G2L2 ) can never be generated if the key type associated with the group yields only one symbol. XKB accepts and ignores them in order to maintain compatibility with the core protocol.
Once the symbols specified by ChangeKeyboardMapping have been assigned to the four keyboard groups for a key, the X server assigns a key type to each group on the key from a canonical list of key types. The first four key types in any keyboard map are reserved for these standard key types:
| Key Type Name | Standard Definition |
|---|---|
| ONE_LEVEL | Describes keys that have exactly one symbol per group. Most special or function keys (such as Return ) are ONE_LEVEL keys. Any combination of modifiers yields level 0 . Index 0 in any key symbol map specifies key type ONE_LEVEL . |
| TWO_LEVEL | Describes non-keypad and non-alphabetic keys that have exactly two symbols per group. By default, the TWO_LEVEL type yields column 1 if the Shift modifier is set, column 0 otherwise. Index 1 in any key symbol map specifies key type TWO_LEVEL . |
| ALPHABETIC | Describes alphabetic keys that have exactly two symbols per group. The default definition of the ALPHABETIC type provides shift-cancels-caps behavior as described in Key Types. Index 2 in any key symbol map specifies key type ALPHABETIC . |
| KEYPAD | Describes numeric keypad keys with two symbols per group. Yields column 1 if either of the Shift modifier or the real modifier bound to the virtual modifier named NumLock are set. Yields column 0 if neither or both modifiers are set. Index 3 in any key symbol map specifies key type KEYPAD . |
Users or applications may change these key types to get different default behavior (to make shift cancel caps lock, for example) but they must always have the specified number of symbols per group.
Before assigning key types to groups, the X server expands any alphanumeric symbol definitions as follows:
If the second symbol of either group is NoSymbol and the first symbol of that group is an alphabetic keysym for which both lowercase and uppercase forms are defined, the X server treats the key as if the first element of the group were the lowercase form of the symbol and the second element were the uppercase form of the symbol. For the purposes of this expansion, XKB ignores the locale and uses the capitalization rules defined in Default Symbol Transformations.
For each keyboard group that does not have an explicit type definition, XKB chooses a key type from the canonical key types. If the second symbol assigned to a group is NoSymbol (after alphabetic expansion), the server assigns key type ONE_LEVEL . If the group contains the lowercase and uppercase forms of a single glyph (after alphanumeric expansion), the server assigns key type ALPHABETIC . If either of the symbols in a group is a numeric keypad keysym ( KP_* ), the server assigns key type KEYPAD . Otherwise, it assigns key type TWO_LEVEL .
Finally, XKB determines the number of groups of symbols that are actually defined for the key. Trailing empty groups (i.e. groups that have NoSymbol in all symbol positions) are ignored.
There are two last special cases for compatibility with the core protocol: If, after trailing empty groups are excluded, all of the groups of symbols bound to the key have identical type and symbol bindings, XKB assigns only one group to the key. If Group2 is empty and either of Group3 or Group4 are not, and if neither Group1 nor Group2 have explicit key types, XKB copies the symbols and key type from Group1 into Group2 .
Once symbols have been divided into groups and key types chosen for the keys affected by a ChangeKeyboardMapping request, XKB examines the symbols and modifier mapping for each changed key and assigns server actions where appropriate. XKB also automatically assigns server actions to changed keys if the client issues a core protocol SetModifierMapping request, and does so optionally in response to XkbSetMap and XkbSetCompatMap requests.
The compatibility map includes a list of symbol interpretations , which XKB compares to each symbol associated with any changed keys in turn, unless the ExplicitInterp component is set for a key. Setting the ExplicitInterp component prevents the application of symbol interpretations to that key.
If the modifiers and keysym specified in a symbol interpretation match the modifier mapping and a symbol bound to a changed key that is not protected by ExplicitInterp , the server applies the symbol interpretation to the symbol position. The server considers all symbol interpretations which specify an explicit keysym before considering any that do not. The server uses the first interpretation which matches the given combination of keysym and modifier mapping; other matching interpretations are ignored.
XKB uses four of the fields of a symbol interpretation to decide if it matches one of the symbols bound to some changed key:
The symbol field is a keysym which matches if it has the value NoSymbol or is identical to the symbol in question.
The modifiers specified in the mods field are compared to the modifiers affected by the key in question as indicated by match .
The match field can specify any of the comparisons: NoneOf , AnyOfOrNone , AnyOf , AllOf or Exactly .
The levelOneOnly setting, indicates that the interpretation in question should only use the modifiers bound to this key by the modifier mapping if the symbol that matches in level one of its group. Otherwise, if the symbol being considered is not in shift level one of its group, the server behaves as if the modifier map for the key were empty. Note that it is still possible for such an interpretation to apply to a symbol in a shift level other than one if it matches a key without modifiers; the levelOneOnly flag only controls the way that matches are determined and that the key modifiers are applied when an interpretation does match.
Applying a symbol interpretation can affect several aspects of the XKB definition of the key symbol mapping to which it is applied:
The action specified in the symbol interpretation is bound to the symbol position; any key event which yields that symbol will also activate the new action.
If the matching symbol is in position G1L1, the autorepeat behavior of the key is set from the autorepeat field of the symbol interpretation. The ExplicitAutoRepeat component protects the autorepeat status of a key from symbol interpretation initiated changes.
If the symbol interpretation specifies an associated virtual modifier, that virtual modifier is added to the virtual modifier map for the key. The ExplicitVModMap component guards the virtual modifier map for a key from automatic changes. If the levelOneOnly flag is set for the interpretation, and the symbol in question is not in position G1L1, the virtual modifier map is not updated.
If the matching symbol is in position G1L1, and the locking key field is set in the symbol interpretation, the behavior of the key is changed to KB_Lock (see Key Behavior). The ExplicitBehavior component prevents this change.
If no interpretations match a given symbol or key, the server uses: SA_NoAction , autorepeat enabled, non-locking key. with no virtual modifiers.
If all of the actions computed for a key are SA_NoAction , the server assigns an length zero list of actions to the key.
If the core protocol modifier mapping is changed, the server regenerates actions for the affected keys. The XkbSetMap and XkbSetCompatMap requests can also cause actions for some or all keyboard keys to be recomputed.
Changes to the symbols or modifier mapping can affect the bindings of virtual modifiers. If any virtual modifiers change, XKB updates all of its data structures to reflect the change. Applying virtual modifier changes to the keyboard mapping night result in changes to types, the group compatibility map, indicator maps, internal modifiers or ignore locks modifiers.
After applying server actions which modify the base, latched or locked modifier or group state of the keyboard, the X server recomputes the effective group and state. Several components of the keyboard state are reported to XKB-aware clients depending on context (see Keyboard State for a detailed description of each of the keyboard state components):
The effective modifier state is reported in XkbStateNotify events and in response to XkbGetState requests.
The symbol lookup state is reported to XKB-aware clients in the state field of core protocol and input extension key press and release events that do not activate passive grabs. Unless the LookupStateWhenGrabbed per-client flag is set, the lookup state is only reported in these events when no grabs are active.
The grab state is reported to XKB-aware clients in the state field of all core protocol events that report keyboard state, except KeyPress and KeyRelease events that do not activate passive grabs.
The effective group is the sum of the base, latched and locked keyboard groups. An out of range effective group is wrapped or truncated into range according to the setting of the groupsWrap flag for the keyboard.
The server reports compatibility states to any clients that have not issued a successful XkbUseExtension request. The server computes the compatibility symbol lookup state and the compatibility effective grab state by applying the compatibility modifier map to the corresponding computed XKB states.
The compatibility symbol lookup state is reported to non-XKB clients whenever an XKB-aware client would receive the XKB lookup state. The compatibility grab state is reported to XKB-unaware clients whenever an XKB client would receive the XKB grab state.
If the GrabsUseXKBState per-client option is not set, even XKB-aware clients receive the compatibility grab state in events that trigger or terminate passive grabs. If this flag is not set, XKB clients also receive the compatibility grab or lookup state whenever any keyboard grab is active.
If the LookupStateWhenGrabbed per-client option is set, clients receive either the XKB or compatibility lookup state when the keyboard is grabbed, otherwise they receive either the XKB or compatibility grab state. All non-XKB clients receive the compatibility form of the appropriate state component; the form that is sent to an XKB-aware client depends on the setting of the GrabsUseXKBState option for that client.
Whenever a client updates the keyboard mapping using a core protocol request, the server saves the requested core protocol keyboard mapping and reports it to any clients that issue GetKeyboardMapping or GetModifierMapping requests. Whenever a client updates the keyboard mapping using XKB requests, the server discards the affected portion of the stored core keyboard description and regenerates it based on the XKB description of the keyboard.
The symbols associated with the XKB keyboard description appear in the order:
G1L1 G1L2 G2L1 G2L2 G1L3-n G2L3-n G3L* G4L*
If the type associated with Group1 is width one, the second symbol is NoSymbol ; if the type associated with Group2 is width one, the fourth symbol is NoSymbol .
If a key has only one group but the keyboard has several, the symbols for Group1 are repeated for each group. For example, given a keyboard with three groups and a key with one group that contains the symbols { a A }, the core protocol description would contain the six symbols: { a A a A a A }. As a slightly more complicated example, an XKB key which had a single width three group with the symbols { a b c } would show up in the generated core protocol keyboard description with the symbols { a b a b c c a b c } for a keyboard with three groups.
The generated modifier mapping for a key contains all of the modifiers affected by all of the actions associated with the key plus all of the modifiers associated with any virtual modifiers bound to the key by the virtual modifier mapping. If any of the actions associated with a key affect any component of the keyboard group, any modifiers specified in any entry of the group compatibility map (see Group Compatibility Map) are reported in the modifier mask. The SA_ISOLock action can theoretically affect any modifier, but the modifier map of an SA_ISOLock key contains only the modifiers or group state that it sets by default.
The server notifies interested clients of keyboard map changes in one of two ways. It sends XkbMapNotify to clients that have explicitly selected them and core protocol MappingNotify events to clients that have not. Once a client requests XkbMapNotify events, the server stops sending it MappingNotify events to inform it of keyboard changes.
XKB normally assumes that events sent to clients using the core protocol SendEvent request contain a core protocol state, if applicable. If the client which will receive the event is not XKB-capable, XKB attempts to convert the core state to an XKB state as follows: if any of the modifiers bound to Group2 in the group compatibility map are set in the event state, XKB clears them in the resulting event but sets the effective group in the event state to Group2 .
If the PCF_SendEventUsesXKBState per-client flag is set at the time of the SendEvent request, XKB instead assumes that the event reported in the event is an XKB state. If the receiving client is not XKB-aware, the extension converts the XKB state (which contains the effective state in bits 13-14) to a core state by applying the group compatibility map just as it would for actual key events.
Table of Contents
The X server maintains a database of keyboard components and common keyboard mappings. This database contains five kinds of components; when combined, these five components provide a complete description of a keyboard and its behavior.
The X Keyboard Extension provides requests to list the contents of this database, to assemble and complete keyboard descriptions by merging the current keyboard description with the contents of this database, or to replace the current keyboard description with a complete keyboard description assembled as described below.
Component and keymap names have the form " class ( member )" where class describes a subset of the available components for a particular type and the optional member identifies a specific component from that subset. For example, the name "atlantis(acme)" might specify the symbols used for the atlantis national keyboard layout by the vendor "acme." Each class has an optional default member — references which specify a class but not a member refer to the default member of the class, if one exists.
The class and member names are both specified using characters from the Latin-1 character set. XKB implementations must accept all alphanumeric characters, minus (‘-’) and underscore (‘_’) in class or member names, and must not accept parentheses, plus, vertical bar, percent sign, asterisk, question mark or white space. The use of other characters is implementation-dependent.
Some of the elements in the server database contain describe only a piece of the corresponding keyboard component. These partial components should be combined with other components of the same type to be useful.
For example, a partial symbols map might describe the differences between a common ASCII keyboard and some national layout. Such a partial map is not useful on its own because it does not include those symbols that are the same on both the ASCII and national layouts (such as function keys). On the other hand, this partial map can configure any ASCII keyboard to use a national layout.
Two components can be combined in two ways:
If the second component overrides the first, any definitions that are present in both components are taken from the second.
If the second component augments the first, any definitions that are present in both components are taken from the first.
Applications can use a component expression to combine multiple components of some time into a complete description of some aspect of the keyboard. A component expression is a string which lists the components to be combined separated by operators which specify the rules for combining them. A complete description is assembled from the listed components, left to right, as follows:
If the new elements are being merged with an existing map, the special component name ‘%’ refers to the unmodified value of the map.
The ‘+’ operator specifies that the next specified component should override the current assembled definition.
The ‘|’ operator specifies that the next specified component should augment the currently assembled definition.
If the new elements are being merged with an existing map and the component expression begins with an operator, a leading ‘%’ is implied.
If any unknown or illegal characters appear anywhere in the string, the entire expression is invalid and is ignored.
For example, the component expression "+de" specifies that the default element of the "de" map should be applied to the current keyboard mapping, overriding any existing definitions.
A slightly more involved example: the expression "acme(ascii)+de(basic)|iso9995-3" constructs a German (de) mapping for the ASCII keyboard supplied by the "acme" vendor. The new definition begins with the symbols for the default ASCII keyboard for Acme, overrides them with any keys that are defined for the default German keyboard layout and then applies the definitions from the iso9995-3 to any undefined keys or groups of keys (part three of the iso9995 standard defines a common set of bindings for the secondary group, but allows national layouts to override those definitions where necessary).
Each component has a set of flags that provide some additional hints about that component. XKB provides these hints for clients that present the keyboard database to users and specifies their interpretation only loosely. Clients can use these hints to constrain the list of components or to control the way that components are presented to the user.
Hints for a component are reported with its name. The least significant byte of the hints field has the same meaning for all five types of keyboard components, and can contain any combination of the following values:
| Flag | Meaning |
|---|---|
| LC_Hidden | Indicates a component that should not normally be presented to the user. |
| LC_Default | Indicates a component that is the default member of its class. |
| LC_Partial | Indicates a partial component. |
The interpretation of the most significant byte of the hints field is dependent on the type of component. The hints defined for each kind of component are listed in the section below that describes that kind of component.
The five types of components stored in the server database of keyboard components correspond to the symbols , geometry , keycodes , compat and types symbolic names associated with a keyboard.
The keycodes component of a keyboard mapping specifies the range and interpretation of the raw keycodes reported by the device. It sets the keycodes symbolic name, the minimum and maximum legal keycodes for the keyboard, and the symbolic name for each key. The keycodes component might also contain aliases for some keys, symbolic names for some indicators, and a description of which indicators are physically present.
The special keycodes component named "computed" indicates that XKB should assign unused keycodes to any unknown keys referenced by name by any of the other components. The computed keycodes component is useful primarily when browsing keymaps because it makes it possible to use the symbols and geometry components without having to find a set of keycodes that includes keycode definitions for all of the keys listed in the two components.
XKB defines no hints that are specific to the keycodes component.
The types component of a keyboard mapping specifies the key types that can be associated with the various keyboard keys. It affects the types symbolic name and the list of types associated with the keyboard (see Key Types). The types component of a keyboard mapping can also optionally contain real modifier bindings and symbolic names for one or more virtual modifiers.
The special types component named "canonical" always contains the types and definitions listed in Canonical Key Types of this document.
XKB defines no hints that are specific to the types component.
The compatibility map component of a keyboard mapping primarily specifies the rules used to assign actions to keysyms. It affects the compat symbolic name, the symbol compatibility map and the group compatibility map. The compat component might also specify maps for some indicators and the real modifier bindings and symbolic names of some virtual modifiers.
XKB defines no hints that are specific to the compatibility map component.
The symbols component of a keyboard mapping specifies primarily the symbols bound to each keyboard key. It affects the symbols symbolic name, a key symbol mapping for each key, they keyboard modifier mapping, and the symbolic names for the keyboard symbol groups. Optionally, the symbols component can contain explicit actions and behaviors for some keys, or the real modifier bindings and symbolic names for some virtual modifiers.
XKB defines the following additional hints for the symbols component:
| Flag | Meaning |
|---|---|
| LC_AlphanumericKeys | Indicates a symbol component that contains bindings primarily for an alphanumeric section of the keyboard. |
| LC_ModifierKeys | Indicates a symbol component that contains bindings primarily for modifier keys. |
| LC_KeypadKeys | Indicates a symbol component that contains bindings primarily for numeric keypad keys. |
| LC_FunctionKeys | Indicates a symbol component that contains bindings primarily for function keys. |
| LC_AlternateGroup | Indicates a symbol component that contains bindings for an alternate keyboard group. |
These hints only apply to partial symbols components; full symbols components are assumed to specify all of the pieces listed above.
The alphanumeric, modifier, keypad or function keys hints should describe the primary intent of the component designer and should not simply an exhaustive list of the kinds of keys that are affected. For example, national keyboard layouts affect primarily alphanumeric keys, but many affect a few modifier keys too; such mappings should set only LC_AlphanumericKeys hint. In general, symbol components should set only one of those four flags (though LC_AlternateGroup may be combined with any of the other flags).
The geometry component of a keyboard mapping specifies primarily the geometry of the keyboard. It contains the geometry symbolic name and the keyboard geometry description. The geometry component might also contain aliases for some keys or symbolic names for some indicators and might affect the set of indicators that are physically present. Key aliases defined in the geometry component of a keyboard mapping override those defined in the keycodes component.
XKB defines no hints that are specific to the geometry component.
The X server also reports a set of fully specified keymaps. The keymaps specified in this list are usually assembled from the components stored in the rest of the database and typically represent the most commonly used keymaps for a particular system.
XKB defines no hints that are specific to complete keymaps.
XKB supports the XkbNewKeyboardNotify event, which reports a change in keyboard geometry or the range of supported keycodes. The server can generate an XkbNewKeyboardNotify event when it detects a new keyboard, or in response to an XkbGetKeyboardByName request (see Using the Server’s Database of Keyboard Components) which loads a new keyboard description.
When a client opens a connection to the X server, the server reports the minimum and maximum keycodes. If the range of supported keycodes is changed, XKB keeps track of the minimum and maximum keycodes that were reported to each client and filters out any events that fall outside of that range. Note that these events are simply ignored; they are not delivered to some other client.
When the server sends an XkbNewKeyboardNotify event to a client to inform it of the new keycode range, XKB resets the stored range of legal keycodes to the keycode range reported in the event. Non-XKB clients and XKB-aware clients that do not request XkbNewKeyboardNotify events never receive events from keys that fall outside of the legal range that XKB maintains for that client.
When a client requests XkbNewKeyboardNotify events, the server compares the range of keycodes for the current keyboard to the range of keycodes that are valid for the client. If they are not the same, the server immediately sends that client an XkbNewKeyboardNotify event. Even if the "new" keyboard is not new to the server, it is new to this particular client.
In addition to filtering out-of-range key events, XKB:
Adjusts core protocol MappingNotify events to refer only to keys that match the stored legal range.
Reports keyboard mappings for keys that match the stored legal range to clients that issue a core protocol GetKeyboardMapping request.
Reports modifier mappings only for keys that match the stored legal range to clients that issue a core protocol GetModifierMapping request.
Restricts the core protocol ChangeKeyboardMapping and SetModifierMapping requests to keys that fall inside the stored legal range.
In short, XKB does everything possible to hide the fact that the range of legal keycodes has changed from clients non-XKB clients, which cannot be expected to deal with it. The corresponding XKB events and requests do not pay attention to the legal keycode range in the same way because XKB makes it possible for clients to track changes to the keycode range for a device and respond to them.
Table of Contents
All XKB interactions with the input extension are optional; implementors are free to restrict the effects of the X Keyboard Extension to the core keyboard device. The XkbGetExtensionDeviceInfo request reports whether or not an XKB implementation supports a particular capability for input extension devices.
XKB recognizes the following interactions with the X Input Extension:
| Name | Capability |
|---|---|
| XI_Keyboards | If set, applications can use all XKB requests and events with extension keyboards. |
| XI_ButtonActions | If set, clients can assign key actions to buttons, even on input extension devices that are not keyboards. |
| XI_IndicatorNames | If set, clients can assign names to indicators on non-keyboard extension devices. |
| XI_IndicatorMaps | If set, clients can assign indicator maps to indicators on non-keyboard extension devices. |
| XI_IndicatorState | If set, clients can change the state of device indicators using the XkbSetExtensionDeviceInfo request. |
Attempts to use an XKB feature with an extension device fail with a Keyboard error if the server does not support the XkbXI_Keyboards optional feature. If a capability particular capability other than XkbXI_Keyboards is not supported, attempts to use it fail silently. The replies for most requests that can use one of the other optional features include a field to report whether or not the request was successful, but such requests do not cause an error condition.
Clients can also request an XkbExtensionDeviceNotify event. This event notifies interested clients of changes to any of the supported XKB features for extension devices, or if a request from the client that is receiving the event attempted to use an unsupported feature.
All XKB requests and events include a device identifier which can refer to an input extension KeyClass device, if the implementation allows XKB to control extension devices. If the implementation does not support XKB manipulation of extension devices, the device identifier is ignored but it must be either 0 or UseCoreKbd .
Implementations which do not support the use of XKB functions with extension keyboards must not set the XkbXI_Keyboards flag. Attempts to use XKB features on an extension keyboard with an implementation that does not support this feature yield a Keyboard error.
The XKB extension optionally allows clients to assign any key action (see Key Actions) to core pointer or input extension device buttons. This makes it possible to control the keyboard or generate keyboard key events from extension devices or from the core pointer.
XKB implementations are required to support actions for the buttons of the core pointer device, but support for actions on extension devices is optional. Implementations which do not support button actions for extension devices must not set the XkbXI_ButtonActions flag.
Attempts to query or assign button actions with an implementation that does not support this feature report failure in the request reply and might cause the server to send an XkbExtensionDeviceNotify event to the client which issued the request that failed. Such requests never cause an error condition.
The XKB extension allows applications to assign indicator maps to the indicators of non-keyboard extension devices. If supported, maps can be assigned to all extension device indicators, whether they are part of a keyboard feedback or part of an indicator feedback.
Implementations which do not support indicator maps for extension devices must not set the XkbXI_IndicatorMaps flag.
Attempts to query or assign indicator maps with an implementation that does not support this feature report failure in the request reply and might cause the server to send an XkbExtensionDeviceNotify event to the client which issued the request that failed. Such requests never cause an error condition.
If this feature is supported, the maps for the default indicators on the core keyboard device are visible both as extension indicators and as the core indicators. Changes made with XkbSetDeviceInfo are visible via XkbGetIndicatorMap and changes made with XkbSetIndicatorMap are visible via XkbGetDeviceInfo .
The XKB extension allows applications to assign symbolic names to the indicators of non-keyboard extension devices. If supported, symbolic names can be assigned to all extension device indicators, whether they are part of a keyboard feedback or part of an indicator feedback.
Implementations which do not support indicator maps for extension devices must not set the XkbXI_IndicatorMaps flag.
Attempts to query or assign indicator names with an implementation that does not support this feature report failure in the request reply and might cause the server to send an XkbExtensionDeviceNotify event to the client which issued the request that failed. Such requests never cause an error condition.
If this feature is supported, the names for the default indicators on the core keyboard device are visible both as extension indicators and as the core indicators. Changes made with XkbSetDeviceInfo are visible via XkbGetNames and changes made with XkbSetNames are visible via XkbGetDeviceInfo .
Table of Contents
This document uses the syntactic conventions and common types defined by the specification of the core X protocol with a number of additions, which are detailed below.
If a client attempts to use any other XKB request except XkbUseExtension before the extension is properly initialized, XKB reports an Access error and ignores the request. XKB is properly initialized once XkbUseExtension reports that the client has asked for a supported or compatible version of the extension.
In addition to all of the errors defined by the core protocol, the X Keyboard Extension defines a single error, Keyboard , which indicates that some request specified an illegal device identifier or an extension device that is not a member of an appropriate. Unless otherwise noted, any request with an argument of type KB_DEVICESPEC can cause Keyboard errors if an illegal or inappropriate device is specified.
When the extension reports a Keyboard error, the most significant byte of the resource_id is a further refinement of the error cause, as defined in the table below. The least significant byte contains the device, class, or feedback id as indicated:
| high-order byte | value | meaning | low-order byte |
|---|---|---|---|
| XkbErr_BadDevice | 0xff | device not found | device id |
| XkbErr_BadClass | 0xfe | device found, but is the wrong class | class id |
| XkbErr_BadId | 0xfd | device found, class ok, but device does not have a feedback with the indicated id | feedback id |
With the exception of Alloc or Implementation errors, which might result in an inconsistent internal state, no XKB request that reports an error condition has any effect. Unless otherwise stated, requests which update some aspect of the keyboard description will not apply only part of a request — if part of a request fails, the whole thing is ignored.
The following types are used in the request and event definitions in subsequent sections:
| Name | Value |
|---|---|
| LISTofITEMs | The type LISTofITEMs is special. It is similar to the LISTofVALUE defined by the core protocol, but the elements of a LISTofITEMs are not necessarily all the same size. The use of a BITMASK to indicate which members are present is optional for a LISTofITEMs — it is possible for the set of elements to be derived from one or more fields of the request. |
| KB_DEVICESPEC | 8 bit unsigned integer, UseCoreKbd, or UseCorePtr |
| KB_LEDCLASSSPEC | { KbdFeedbackClass , LedFeedbackClass , DfltXIClass , AllXIClasses , XINone } |
| KB_BELLCLASSSPEC | { KbdFeedbackClass , BellFeedbackClass , DfltXIClass , AllXIClasses } |
| KB_IDSPEC | 8 bit unsigned integer or DfltXIId |
| KB_VMODMASK | CARD16, each bit corresponds to a virtual modifier |
| KB_GROUPMASK | { Group1 , Group2 , Group3 , Group4 } |
| KB_GROUPSWRAP | { WrapIntoRange , ClampIntoRange , RedirectIntoRange } |
| KB_GROUPINFO | { groupsWrap: KB_GROUPSWRAP redirectGroup: 1…4, numGroups: 1…4 } |
| KB_NKNDETAILSMASK | { NKN_Keycodes , NKN_Geometry, NKN_DeviceID } |
| KB_STATEMASK | KEYBUTMASK or KB_GROUPMASK |
| KB_STATEPARTMASK | { ModifierState , ModifierBase , ModifierLatch , ModifierLock , GroupState , GroupBase , GroupLatch , GroupLock , CompatState , GrabMods , CompatGrabMods , LookupMods , CompatLookupMods , PointerButtons } |
| KB_BOOLCTRLMASK | { RepeatKeys , SlowKeys , BounceKeys , StickyKeys , MouseKeys , MouseKeysAccel , AccessXKeys , AccessXTimeout , AccessXFeedback , AudibleBell , Overlay1 , Overlay2 , IgnoreGroupLock } |
| KB_CONTROLSMASK | { GroupsWrap, InternalMods , IgnoreLockMods , PerKeyRepeat , ControlsEnabled } or KB_BOOLCTRLMASK |
| KB_MAPPARTMASK | { KeyTypes , KeySyms , ModifierMap , ExplicitComponents , KeyActions , KeyBehaviors , VirtualMods , VirtualModMap } |
| KB_CMDETAILMASK | { SymInterp , GroupCompat } |
| KB_NAMEDETAILMASK | { KeycodesName , GeometryName , SymbolsName , PhysSymbolsName , TypesName , CompatName , KeyTypeNames , KTLevelNames , IndicatorNames , KeyNames , KeyAliases , VirtualModNames , GroupNames , RGNames } |
| KB_AXNDETAILMASK | { AXN_SKPress , AXN_SKAccept , AXN_SKReject , AXN_SKRelease, AXN_BKAccept, AXN_BKReject, AXN_AXKWarning } |
| KB_AXSKOPTSMASK | { AX_TwoKeys , AX_LatchToLock } |
| KB_AXFBOPTSMASK | { AX_SKPressFB , AX_SKAcceptFB , AX_FeatureFB , AX_SlowWarnFB , AX_IndicatorFB , AX_StickyKeysFB , AX_SKReleaseFB , AX_SKRejectFB , AX_BKRejectFB , AX_DumbBellFB } |
| KB_AXOPTIONSMASK | KB_AXFBOPTSMASK or KB_AXSKOPTSMASK |
| KB_GBNDETAILMASK | { GBN_Types , GBN_CompatMap , GBN_ClientSymbols , GBN_ServerSymbols , GBN_IndicatorMap , GBN_KeyNames , GBN_Geometry , GBN_OtherNames } |
| KB_BELLDETAILMASK | { XkbAllBellNotifyEvents } |
| KB_MSGDETAILMASK | { XkbAllActionMessages } |
| KB_EVENTTYPE | { XkbNewKeyboardNotify , XkbMapNotify , XkbStateNotify , XkbControlsNotify , XkbIndicatorStateNotify , XkbIndicatorMapNotify , XkbNamesNotify , XkbCompatMapNotify , XkbBellNotify , XkbActionMessage , XkbAccessXNotify , XkbExtensionDeviceNotify } |
| KB_ACTION | [ type: CARD8 data: LISTofCARD8 ] |
| KB_BEHAVIOR | [ type: CARD8, data: CARD 8 ] |
| KB_MODDEF | [ mask: KEYMASK, mods: KEYMASK, vmods: KB_VMODMASK ] |
| KB_KTMAPENTRY | [ active: BOOL, level: CARD8, mods: KB_MODDEF ] |
| KB_KTSETMAPENTRY | [ level: CARD8, mods: KB_MODDEF ] |
| KB_KEYTYPE | [ mods: KB_MODDEF, numLevels: CARD8, map: LISTofKB_KTMAPENTRY, preserve: LISTofKB_MODDEF ] |
| KB_SETKEYTYPE | [ realMods: KEYMASK, vmods: CARD16, numLevels: CARD8, map: LISTofKB_KTSETMAPENTRY, preserve: LISTofKB_MODDEF ] |
| KB_KEYSYMMAP | [ ktIndex: LISTofCARD8, width: CARD8 numGroups: 0…4, groupsWrap: KB_GROUPSWRAP, redirectGroup: 0…3, syms: LISTofKEYSYM ] |
| KB_KEYVMODMAP | [ key: KEYCODE, vmods: CARD16 ] |
| KB_KEYMODMAP | [ key: KEYCODE, mods: KEYMASK ] |
| KB_EXPLICITMASK | { ExplicitKeyType1 , ExplicitKeyType2 , ExplicitKeyType3 , ExplicitKeyType4 , ExplicitInterpret , ExplicitAutoRepeat , ExplicitBehavior , ExplicitVModMap } |
| KB_INDICATORMASK | CARD32, each bit corresponds to an indicator |
| KB_IMFLAGS | { IM_NoExplicit , IM_NoAutomatic , IM_LEDDrivesKB } |
| KB_IMMODSWHICH | { IM_UseNone , IM_UseBase , IM_UseLatched , IM_UseLocked , IM_UseEffective , IM_UseCompat } |
| KB_IMGROUPSWHICH | { IM_UseNone , IM_UseBase , IM_UseLatched , IM_UseLocked , IM_UseEffective } |
| KB_INDICATORMAP | [ flags: CARD8, mods: KB_MODDEF, whichMods: groups: KB_GROUPMASK, whichGroups: ctrls: KB_BOOLCTRLMASK ] |
| KB_SYMINTERPMATCH | { SI_NoneOf , SI_AnyOfOrNone , SI_AnyOf , SI_AllOf , SI_Exactly } |
| KB_SYMINTERP | [ sym: KEYSYM, mods; KEYMASK, levelOneOnly: BOOL, match: KB_SYMINTERPMATCH, virtualMod: CARD8, autoRepeat: BOOL, lockingKey: BOOL ] |
| KB_PCFMASK | { PCF_DetectableAutorepeat , PCF_GrabsUseXkbState , PCF_AutoResetControls , PCF_LookupStateWhenGrabbed , PCF_SendEventUsesXKBState } |
| KB_LCFLAGSMASK | { LC_Hidden , LC_Default , LC_Partial } |
| KB_LCSYMFLAGSMASK | { LC_AlphanumericKeys , LC_ModifierKeys , LC_KeypadKeys , LC_FunctionKeys , LC_AlternateGroup } |
These types are used by the XkbGetGeometry and XkbSetGeometry requests:
| Name | Value |
|---|---|
| KB_PROPERTY | [ name, value: STRING8 ] |
| KB_POINT | [ x, y: CARD16 ] |
| KB_OUTLINE | [ cornerRadius: CARD8, points: LISTofKB_POINT ] |
| KB_SHAPE | [ name: ATOM, outlines: LISTofKB_OUTLINE primaryNdx, approxNdx: CARD8 ] |
| KB_KEYNAME | [ name: LISTofCHAR ] |
| KB_KEYALIAS | [ real: LISTofCHAR, alias: LISTofCHAR ] |
| KB_KEY | [ name: KB_KEYNAME, gap: INT16, shapeNdx, colorNdx: CARD8 ] |
| KB_ROW | [ top, left: INT16, vertical: BOOL, keys LISTofKB_KEY ] |
| KB_OVERLAYKEY | [ over, under: KB_KEYNAME ] |
| KB_OVERLAYROW | [ rowUnder: CARD8, keys: LISTofKB_OVERLAYKEY ] |
| KB_OVERLAY | [ sectionUnder: CARD8, rows: LISTofKB_OVERLAYROW ] |
| KB_SHAPEDOODAD | [ name: ATOM, priority: CARD8, top, left: INT16, type: { SolidDoodad, OutlineDoodad }, angle: INT16, width, height: CARD16 colorNdx, shapeNdx: CARD8 ] |
| KB_TEXTDOODAD | [ name: ATOM, priority: CARD8, top, left: INT16, angle: INT16, width, height: CARD16, colorNdx: CARD8, text: STRING8, font: STRING8 ] |
| KB_INDICATORDOODAD | [ name: ATOM, priority: CARD8, top, left: INT16, angle: INT16, shapeNdx, onColorNdx, offColorNdx: CARD8 ] |
| KB_LOGODOODAD | [ name: ATOM, priority: CARD8, top, left: INT16, angle: INT16, colorNdx, shapeNdx: CARD8, logoName: STRING8 ] |
| KB_DOODAD | KB_SHAPEDOODAD, or KB_TEXTDOODAD, or KB_INDICATORDOODAD, or KB_LOGODOODAD |
| KB_SECTION | [ name: ATOM, top, left, angle: INT16, width, height: CARD16, priority: CARD8, rows: LISTofKB_ROW, doodads: LISTofKB_DOODAD, overlays: LISTofKB_OVERLAY ] |
These types are used by XkbGetDeviceInfo and XkbSetDeviceInfo :
| Name | Value |
|---|---|
| KB_XIDEVFEATUREMASK | { XI_ButtonActions , XI_IndicatorNames , XI_IndicatorMaps , XI_IndicatorState } |
| KB_XIFEATUREMASK | { KB_XIDEVFEATURES or XI_Keyboards |
| KB_XIDETAILMASK | { KB_XIFEATURES or XI_UnsupportedFeature } |
| KB_DEVICELEDINFO | [ ledClass: KB_LEDCLASSSPEC, ledID: KB_IDSPEC, physIndicators: CARD32, state: CARD32, names: LISTofATOM, maps: LISTofKB_INDICATORMAP ] |
This section lists all of the requests supported by the X Keyboard Extension, separated into categories of related requests.
| XkbUseExtension |
|---|
| wantedMajor, wantedMinor: CARD16 |
| supported: BOOL |
| serverMajor, serverMinor: CARD16 |
This request enables XKB extension capabilities for the client that issues the request; the wantedMajor and wantedMinor fields specify the extension version in use by the requesting client. The supported field is True if the server supports a compatible version, False otherwise. The serverMajor and serverMinor fields return the actual version supported by the server.
Until a client explicitly and successfully requests the XKB extension, an XKB capable server reports compatibility state in all core protocol events and requests. Once a client asks for XKB extension semantics by issuing this request, the server reports the extended XKB keyboard state in some core protocol events and requests, as described in the overview section of this specification.
Clients should issue an XkbUseExtension request before using any other extension requests.
| XkbSelectEvents |
|---|
| deviceSpec: KB_DEVICESPEC |
| affectWhich, clear, selectAll: KB_EVENTTYPE |
| affectMap, map: KB_MAPPARTMASK |
| details: LISTofITEMs |
| Errors: Keyboard , Match , Value |
This request updates the event masks of the keyboard indicated by deviceSpec for this client. If deviceSpec specifies an illegal device, a Keyboard error results.
The affectMap and map fields specify changes to the event details mask for the XkbMapNotify event. If any map components are set in map but not in affectMap , a Match error results. Otherwise, any map components that are set in affectMap are set or cleared in the map notify details mask, depending on the value of the corresponding field in map .
The affectWhich , clear , and selectAll fields specify changes to any other event details masks. If any event types are set in both clear and selectAll , a Match error results; if any event types are specified in either clear or selectAll but not in affectWhich , a Match error results. Otherwise, the detail masks for any event types specified in the affectWhich field of this request are changed as follows:
If the event type is also set in clear , the detail mask for the corresponding event is set to 0 or False , as appropriate.
If the event type is also set in selectAll , the detail mask for the corresponding event is set to include all legal detail values for that type.
If the event type is not set in either clear or selectAll , the corresponding element of details lists a set of explicit changes to the details mask for the event, as described below.
Each entry of the details list specifies changes to the event details mask for a single type of event, and consists of an affects mask and a values mask. All details that are specified in affects are set to the corresponding value from values ; if any details are listed in values but not in affects , a Match error results.
The details list contains entries only for those event types, if any, that are listed in the affectWhich mask and not in either clear or selectAll . When present, the items of the details list appear in the following order:
| Event Type | Legal Details | Type |
|---|---|---|
| XkbNewKeyboardNotify | KB_NKNDETAILSMASK | CARD16 |
| XkbStateNotify | KB_STATEPARTMASK | CARD16 |
| XkbControlsNotify | KB_CONTROLMASK | CARD32 |
| XkbIndicatorMapNotify | KB_INDICATORMASK | CARD32 |
| XkbIndicatorStateNotify | KB_INDICATORMASK | CARD32 |
| XkbNamesNotify | KB_NAMEDETAILMASK | CARD16 |
| XkbCompatMapNotify | KB_CMDETAILMASK | CARD8 |
| XkbBellNotify | KB_BELLDETAILMASK | CARD8 |
| XkbActionMessage | KB_MSGDETAILMASK | CARD8 |
| XkbAccessXNotify | KB_AXNDETAILMASK | CARD16 |
| XkbExtensionDeviceNotify | KB_XIDETAILMASK | CARD16 |
Detail masks for event types that are not specified in affectWhich are not changed.
If any components are specified in a client’s event masks, the X server sends the client an appropriate event whenever any of those components change state. Unless explicitly modified, all event detail masks are empty. Events describes all XKB events and the conditions under which the server generates them.
| XkbBell |
|---|
| deviceSpec: KB_DEVICESPEC |
| bellClass: KB_BELLCLASSSPEC |
| bellID: KB_IDSPEC |
| percent: INT8 |
| forceSound: BOOL |
| eventOnly: BOOL |
| pitch, duration: INT16 |
| name: ATOM |
| window: WINDOW |
| Errors: Keyboard , Value , Match |
This request generates audible bells and/or XkbBellNotify events for the bell specified by the bellClass and bellID on the device specified by deviceSpec at the specified pitch , duration and volume ( percent ). If deviceSpec specifies a device that does not have a bell or keyboard feedback, a Keyboard error results.
If both forceSound and eventOnly are set, this request yields a Match error. Otherwise, if forceSound is True , this request always generates a sound and never generates an event; if eventOnly is True , it causes an event but no sound. If neither forceSound nor eventOnly are True , this request always generates an event; if the keyboard’s global AudibleBell control is enabled, it also generates a sound.
Any bell event generated by this request contains all of the information about the bell that was requested, including the symbolic name specified by name and the event window specified by window. The name and window are not directly interpreted by XKB, but they must have the value None or specify a legal Atom or Window, respectively. XkbBellNotify events generated in response to core protocol or X input extension bell requests always report None as their name .
The bellClass , bellID , and percent fields are interpreted as for the X input extension DeviceBell request. If pitch and duration are zero, the server uses the corresponding values for that bell from the core protocol or input extension, otherwise pitch and duration are interpreted as for the core protocol ChangeKeyboardControl request; if they do not include legal values, a Value error results. The window field must specify a legal Window or have the value None , or a Value error results. The name field must specify a legal Atom or have the value None , or an Atom error results. If an error occurs, this request has no other effect (i.e. does not cause a sound or generate an event).
The pitch , volume , and duration are suggested values for the bell, but XKB does not require the server to honor them.
| XkbGetState |
|---|
| deviceSpec: KB_DEVICESPEC |
| deviceID: CARD8 |
| mods, baseMods, latchedMods, lockedMods: KEYMASK |
| group, lockedGroup: KB_GROUP |
| baseGroup, latchedGroup: INT16 |
| compatState: KEYMASK |
| grabMods, compatGrabMods: KB_GROUP |
| lookupMods, compatLookupMods: KEYMASK |
| ptrBtnState: BUTMASK |
| Errors: Keyboard |
This request returns a detailed description of the current state of the keyboard specified by deviceSpec .
The deviceID return value contains the input extension identifier for the specified device, or 0 if the server does not support the input extension.
The baseMods return value reports the modifiers that are set because one or more modifier keys are logically down. The latchedMods and lockedMods return values report the modifiers that are latched or locked respectively. The mods return value reports the effective modifier mask which results from the current combination of base, latched and locked modifiers.
The baseGroup return value reports the group state selected by group shift keys that are logically down. The latchedGroup and lockedGroup return values detail the effects of latching or locking group shift keys and XkbLatchLockState requests. The group return value reports the effective keyboard group which results from the current combination of base, latched and locked group values.
The lookupMods return value reports the lookup modifiers, which consist of the current effective modifiers minus any server internal modifiers. The grabMods return value reports the grab modifiers, which consist of the lookup modifiers minus any members of the ignore locks mask that are not either latched or logically depressed. Keyboard State describes the lookup modifiers and grab modifiers in more detail.
The ptrBtnState return value reports the current logical state of up to five buttons on the core pointer device.
The compatState return value reports the compatibility state that corresponds to the effective keyboard group and modifier state. The compatLookupMods and compatGrabMods return values report the core protocol compatibility states that correspond to the XKB lookup and grab state. All of the compatibility states are computed by applying the group compatibility mapping to the corresponding XKB modifier and group states, as described in Group Compatibility Map.
| XkbLatchLockState |
|---|
| deviceSpec: KB_DEVICESPEC |
| affectModLocks, modLocks: KEYMASK |
| lockGroup: BOOL |
| groupLock: KB_GROUP |
| affectModLatches,modLatches: KEYMASK |
| latchGroup: BOOL |
| groupLatch: INT16 |
| Errors: Keyboard , Value |
This request locks or latches keyboard modifiers and group state for the device specified by deviceSpec . If deviceSpec specifies an illegal or non-keyboard device, a Keyboard error occurs.
The locked state of any modifier specified in the affectModLocks mask is set to the corresponding value from modLocks . If lockGroup is True , the locked keyboard group is set to the group specified by groupLock . If any modifiers are set in modLocks but not affectModLocks , a Match error occurs.
The latched state of any modifier specified in the affectModLatches mask is set to the corresponding value from modLatches . If latchGroup is True , the latched keyboard group is set to the group specified by groupLatch . if any modifiers are set in modLatches but not in affectModLatches , a Match error occurs.
If the locked group exceeds the maximum number of groups permitted for the specified keyboard, it is wrapped or truncated back into range as specified by the global GroupsWrap control. No error results from an out-of-range group specification.
After changing the locked and latched modifiers and groups as specified, the X server recalculates the effective and compatibility keyboard state and generates XkbStateNotify events as appropriate if any state components have changed. Changing the keyboard state might also turn indicators on or off which can cause XkbIndicatorStateNotify events as well.
If any errors occur, this request has no effect.
| XkbGetControls |
|---|
| deviceSpec: KB_DEVICESPEC |
| deviceID: CARD8 |
| mouseKeysDfltBtn: CARD8 |
| numGroups: CARD8 |
| groupsWrap: KB_GROUPINFO |
| internalMods,ignoreLockMods: KB_MODDEF |
| repeatDelay,repeatInterval: CARD16 |
| slowKeysDelay, debounceDelay: CARD16 |
| mouseKeysDelay, mouseKeysInterval: CARD16 |
| mouseKeysTimeToMax, mouseKeysMaxSpeed: CARD16 |
| mouseKeysCurve: INT16 |
| accessXOptions: KB_AXOPTIONMASK |
| accessXTimeout: CARD16 |
| accessXTimeoutOptionsMask, accessXTimeoutOptionValues: CARD16 |
| accessXTimeoutMask,accessXTimeoutValues: CARD32 |
| enabledControls: KB_BOOLCTRLMASK |
| perKeyRepeat: LISTofCARD8 |
| Errors: Keyboard |
This request returns the current values and status of all controls for the keyboard specified by deviceSpec . If deviceSpec specifies an illegal device a Keyboard error results. On return, the deviceID specifies the identifier of the requested device or zero if the server does not support the input extension.
The numGroups return value reports the current number of groups, and groupsWrap reports the treatment of out-of-range groups, as described in Key Symbol Map. The internalMods and ignoreLockMods return values report the current values of the server internal and ignore locks modifiers as described in Keyboard State. Both are modifier definitions ( Modifier Definitions) which report the real modifiers, virtual modifiers, and the resulting combination of real modifiers that are bound to the corresponding control.
The repeatDelay , repeatInterval , slowKeysDelay and debounceDelay fields report the current values of the for the autorepeat delay, autorepeat interval, slow keys delay and bounce keys timeout, respectively. The mouseKeysDelay , mouseKeysInterval , mouseKeysTimeToMax and mouseKeysMaxSpeed and mouseKeysCurve return values report the current acceleration applied to mouse keys, as described in The MouseKeysAccel Control. All times are reported in milliseconds.
The mouseKeysDfltBtn return value reports the current default pointer button for which events are synthesized by the mouse keys server actions.
The accessXOptions return value reports the current settings of the various AccessX options flags which govern the behavior of the StickyKeys control and of AccessX feedback.
The accessXTimeout return value reports the length of time, in seconds, that the keyboard must remain idle before AccessX controls are automatically changed; an accessXTimeout of 0 indicates that AccessX controls are not automatically changed. The accessXTimeoutMask specifies the boolean controls to be changed if the AccessX timeout expires; the accessXTimeoutValues field specifies new values for all of the controls in the timeout mask. The accessXTimeoutOptionsMask field specifies the AccessX options to be changed when the AccessX timeout expires; the accessXTimeoutOptionValues return value reports the values to which they will be set.
The enabledControls return value reports the current state of all of the global boolean controls.
The perKeyRepeat array consists of one bit per key and reports the current autorepeat behavior of each keyboard key; if a bit is set in perKeyRepeat , the corresponding key repeats if it is held down while global keyboard autorepeat is enabled. This array parallels the core protocol and input extension keyboard controls, if the autorepeat behavior of a key is changed via the core protocol or input extension, those changes are automatically reflected in the perKeyRepeat array.
| XkbSetControls |
|---|
| deviceSpec: KB_DEVICESPEC |
| affectInternalRealMods, internalRealMods: KEYMASK |
| affectInternalVirtualMods,internalVirtualMods: KB_VMODMASK |
| affectIgnoreLockRealMods,ignoreLockRealMods: KB_MODMASK |
| affectIgnoreLockVirtualMods,ignoreLockVirtualMods: KB_VMODMASK |
| mouseKeysDfltBtn: CARD8 |
| groupsWrap: KB_GROUPINFO |
| accessXOptions: CARD16 |
| affectEnabledControls: KB_BOOLCTRLMASK |
| enabledControls: KB_BOOLCTRLMASK |
| changeControls: KB_CONTROLMASK |
| repeatDelay,repeatInterval: CARD16 |
| slowKeysDelay, debounceDelay: CARD16 |
| mouseKeysDelay, mouseKeysInterval: CARD16 |
| mouseKeysTimeToMax, mouseKeysMaxSpeed: CARD16 |
| mouseKeysCurve: INT16 |
| accessXTimeout: CARD16 |
| accessXTimeoutMask, accessXTimeoutValues: KB_BOOLCTRLMASK |
| accessXTimeoutOptionsMask,accessXTimeoutOptionsValues: CARD16 |
| perKeyRepeat: LISTofCARD8 |
| Errors: Keyboard , Value |
This request sets the keyboard controls indicated in changeControls for the keyboard specified by deviceSpec . Each bit that is set in changeControls indicates that one or more of the other request fields should be applied, as follows:
| Bit in changeControls | Field(s) to be Applied |
|---|---|
| XkbRepeatKeysMask | repeatDelay , repeatInterval |
| XkbSlowKeysMask | slowKeysDelay |
| XkbStickyKeysMask | accessXOptions (only the XkbAX_TwoKeys and the XkbAX_LatchToLock options are affected) |
| XkbBounceKeysMask | debounceDelay |
| XkbMouseKeysMask | mouseKeysDfltBtn |
| XkbMouseKeysAccelMask | mouseKeysDelay , mouseKeysInterval , mouseKeysCurve , mouseKeysTimeToMax , mouseKeysMaxSpeed |
| XkbAccessXKeysMask | accessXOptions (all options) |
| XkbAccessXTimeoutMask | accessXTimeout , accessXTimeoutMask , accessXTimeoutValues , accessXTimeoutOptionsMask , accessXTimeoutOptionsValues |
| XkbAccessXFeedbackMask | accessXOptions (all options except those affected by the XkbStickyKeysMask bit) |
| XkbGroupsWrapMask | groupsWrap |
| XkbInternalModsMask | affectInternalRealMods , internalRealMods , affectInternalVirtualMods , internalVirtualMods |
| XkbIgnoreLockModsMask | affectIgnoreLockRealMods , ignoreLockRealMods , affectIgnoreLockVirtualMods , ignoreLockVirtualMods |
| XkbPerKeyRepeatMask | perKeyRepeat |
| XkbControlsEnabledMask | affectEnabledControls , enabledControls |
If any other bits are set in changeControls , a Value error results. If any of the bits listed above are not set in changeControls , the corresponding fields must have the value 0 , or a Match error results.
If applied, repeatDelay and repeatInterval change the autorepeat characteristics of the keyboard, as described in The RepeatKeys Control. If specified, repeatDelay and repeatInterval must both be non-zero or a Value error results.
If applied, the slowKeysDelay field specifies a new delay for the SlowKeys control, as defined in The SlowKeys Control. If specified, slowKeysDelay must be non-zero, or a Value error results.
If applied, the debounceDelay field specifies a new delay for the BounceKeys control, as described in The BounceKeys Control. If present, the debounceDelay must be non-zero or a Value error results.
If applied, the mouseKeysDfltBtn field specifies the core pointer button for which events are generated whenever a SA_PtrBtn or SA_LockPtrBtn key action is activated. If present, mouseKeysDfltBtn must specify a legal button for the core pointer device, or a Value error results. Key Actions describes the SA_PtrBtn and SA_LockPtrBtn actions in more detail.
If applied, the mouseKeysDelay , mouseKeysInterval , mouseKeysTimeToMax , mouseKeysMaxSpeed and mouseKeysCurve fields change the rate at which the pointer moves when a key which generates a SA_MovePtr action is held down. The MouseKeysAccel Control describes these MouseKeysAccel parameters in more detail. If defined, the mouseKeysDelay , mouseKeysInterval , mouseKeysTimeToMax and mouseKeysMaxSpeed values must all be greater than zero, or a Value error results. The mouseKeysCurve value must be greater than -1000 or a Value error results.
If applied, the accessXOptions field sets the AccessX options, which are described in detail in The AccessXKeys Control. If either one of XkbStickyKeysMask and XkbAccessXFeedbackMask are set in changeControls and XkbAccessXKeysMask is not, only a subset of the AccessX options are changed, as described in the table above; if both are set or if the AccessXKeys bit is set in changeControls , all of the AccessX options are updated. Any bit in accessXOptions whose interpretation is undefined must be zero, or a Value error results.
If applied, the accessXTimeout , accessXTimeoutMask , accessXTimeoutValues , accessXTimeoutOptionsMask and accessXTimeoutOptionsValues fields change the behavior of the AccessX Timeout control, as described in The AccessXTimeout Control. The accessXTimeout must be greater than zero, or a Value error results. The accessXTimeoutMask or accessXTimeoutValues fields must specify only legal boolean controls, or a Value error results. The accessXTimeoutOptionsMask and accessXTimeoutOptionsValues fields must contain only legal AccessX options or a Value error results. If any bits are set in either values field but not in the corresponding mask, a Match error results.
If present, the groupsWrap field specifies the treatment of out-of-range keyboard groups, as described in Key Symbol Map. If the groupsWrap field does not specify a legal treatment for out-of-range groups, a Value error results.
If present, the affectInternalRealMods field specifies the set of real modifiers to be changed in the internal modifier definition and the internalRealMods field specifies new values for those modifiers. The affectInternalVirtualMods and internalVirtualMods fields update the virtual modifier component of the modifier definition that describes the internal modifiers in the same way. If any bits are set in either values field but not in the corresponding mask field, a Match error results.
If present, the affectIgnoreLockRealMods field specifies the set of real modifiers to be changed in the ignore locks modifier definition and the ignoreLockRealMods field specifies new values for those modifiers. The affectIgnoreLockVirtualMods and ignoreLockVirtualMods fields update the virtual modifier component of the ignore locks modifier definition in the same way. If any bits are set in either values field but not in the corresponding mask field, a Match error results.
If present, the perKeyRepeat array specifies the repeat behavior of the individual keyboard keys. The corresponding core protocol or input extension per-key autorepeat information is updated to reflect any changes specified in perKeyRepeat . If the bits that correspond to any out-of-range keys are set in perKeyRepeat , a Value error results.
If present, the affectEnabledControls and enabledControls field enable and disable global boolean controls. Any controls set in both fields are enabled; any controls that are set in affectEnabledControls but not in enabledControls are disabled. Controls that are not set in either field are not affected. If any controls are specified in enabledControls but not in affectEnabledControls , a Match error results. If either field contains anything except boolean controls, a Value error results.
| XkbGetMap | |
|---|---|
| deviceSpec: KB_DEVICESPEC | |
| full, partial: KB_MAPPARTMASK | |
| firstType, nTypes: CARD8 | |
| firstKeySym, span clhis request returns the current values and stat,1Timeousk< | |
| mouass="emphastr> | XkbSlows="proROLMASK |
| repeatDel spectively. If>KB_KEquest.nges tame" align="left"> repeatDel spectively. If>KB_KEqESPE.nges tame" align="left"> repeatDel spectively. If>KB_KEqESPE.nges tame" align="left"> repeatDel spectively. If>KB_KEqESPE.nges tame" align="left"> repeatDel spectively. If>KB_KEqESPE.nges tame" align="left"> repeatDel spectively. If>KB_KEqESPE.nges tame" align="left"> repeventOnly: BOOL repeatDel repeatDel spectively. velhe current values of the for the autorepeat delauseKeysDe> | |
| KB_MSGDETAILMASK | { error results. |
| numGroups: CARD8 | |
| mouseKeysDelay, mouseKeysInterval: CARD16 | |
| Errors: Keyboard , Match , Value |
This requelay, mouseKey="emphasis">
rol" title=ft"ft">
mouseKeysDfltBtn: CARD8
The
If presenr the autorepeat delapAbsolute"left"ft">
mouseKeysDfltBtn: CARD8
If presExplicitAutoRepeat
,
d, a eply" align="left">
serverMajor, serverMinor: CARD16
This request enables XKB extension capabilities for the client that issues the
request; the
numGroups: CARD8
in">
d, a em>
Group3
SA_PtrBtn
and
XkbSlows="proROLMASK
repeatDel spectively. If>KB_KEqESPE.nges tame" align="left">
repeatDel
and Errors:
Keyboard
,
SA_PtrBtn
and
numGroups: CARD8
deviceSpec: KB_DEVICESPEn zeroIf any
SA_PtrBtn
a2
This er Definitionsemphasis">
Legal Detan>
, {
numGroups: CARD8
lockGroup
is
True
, the locked keyboard group is set to the group specified by
accessXTihasis">
ModifierState
, KB_XIDEVFEATURlues reo this
combinat Legal Detan>
, tame" align="leyDfltBtnn>
and <>
accessXTimeout
,
accessXTimeoutMask
, Legal Detan>
, tame" align="leyDfltBtnn>
and <>
accessXTimthe KB_MSGDETAILMASK {
error results.
whose intee the behavior of the>
accessXTimeoud groups, as described in
Key Symbol Map. If the
Key
ROW ]
This request enables XKB extension capabilities for the client that issues the
request; the
Detail masks for event types that ares
Detail emphasis"> If the event type is also set in
semeoutMas"#The_MouseKeysAc
Matchs an event; if
eventOnly
es are used by
XkbGetDned must be zero, or atona/div>
If present, tsX optiod a specifiKB_XIDETAILMASK
This requelay, mouseKey="emphasis">
r>
must be non-zero, or a s">
GBN specified in
Value
error res/em>
,
butr the client that issues the
request; the
a locked group exceeds ay
must be non-zero, or a
Valueipan>
a locked gro
XkbMouseKeysrNonem>
Value
error res/em>
,
are set in
changrable>
} KB_XIFEATUREMASK { KB_XIDEVFEATURES or
duration
are zero, the server udisabled. Controls tRD8
changrable>[ cornerRadiusclass="c1" />
This request sets
and KB_MSGDETAILMASK {
error results.
{ KB_XIFEATURES or "left">KB_EXPLICITMASK KB_EXPLICITMASK { KB_XIFEATUAK Ke
p
mouseKeysDfltBtn: CARD8
Ke
p
mouseKeysDfltBtn: CARD8
Ke
p
Vawas request"s excepble> Ke
p
lookupMods,all be gre
accessXOptions
must beleft">
mouseKeysDfltBtn: ">
LC_Hidden
XkbCompatMaclKB_LCFLAGSMASK _LCFLAGSMASK_LCFLAGSMASK_L