xkbcommon 1.14.0-beta2
Reference library implementing the XKB specification for parsing keyboard descriptions and handling keyboard state
Loading...
Searching...
No Matches
Data Structures | Enumerations | Functions
Keyboard server state machine
Collaboration diagram for Keyboard server state machine:

Data Structures

struct  xkb_machine_builder_config
 
struct  xkb_machine_builder_a11y_update
 
struct  xkb_machine_builder_mods_remap_update
 
struct  xkb_machine_builder_shortcut_override_update
 
struct  xkb_state_components_update
 
struct  xkb_layout_policy_update
 
struct  xkb_synthetic_update
 
struct  xkb_machine
 
struct  xkb_machine_builder
 

Enumerations

enum  xkb_machine_builder_flags { XKB_MACHINE_BUILDER_NO_FLAGS = 0 }
 
enum  xkb_machine_flags {
  XKB_MACHINE_NO_FLAGS = 0 ,
  XKB_MACHINE_SERVER_ACTIONS = (1 << 0) ,
  XKB_MACHINE_DISABLE_LAYOUT_SWITCH_ON_MODIFIER_KEY_FIX = (1 << 1) ,
  XKB_MACHINE_UNLOCK_MODS_ON_PRESS = (1 << 2)
}
 
enum  xkb_a11y_flags {
  XKB_A11Y_NO_FLAGS = 0 ,
  XKB_A11Y_STICKY_KEYS_NO_SIMULTANEOUS_KEYS = (1 << 0) ,
  XKB_A11Y_STICKY_KEYS_LATCH_TO_LOCK = (1 << 1) ,
  XKB_A11Y_LATCH_SIMULTANEOUS_KEYS = (1 << 2)
}
 
enum  xkb_layout_out_of_range_policy {
  XKB_LAYOUT_OUT_OF_RANGE_WRAP = 0 ,
  XKB_LAYOUT_OUT_OF_RANGE_CLAMP ,
  XKB_LAYOUT_OUT_OF_RANGE_REDIRECT
}
 

Functions

XKB_EXPORT struct xkb_machine_builder * xkb_machine_builder::xkb_machine_builder_new (struct xkb_keymap *keymap, const struct xkb_machine_builder_config *config, enum xkb_status *status)
 
XKB_EXPORT struct xkb_machine_builder * xkb_machine_builder::xkb_machine_builder_ref (struct xkb_machine_builder *builder)
 
XKB_EXPORT void xkb_machine_builder::xkb_machine_builder_unref (struct xkb_machine_builder *builder)
 
XKB_EXPORT struct xkb_keymap * xkb_machine_builder::xkb_machine_builder_get_keymap (const struct xkb_machine_builder *builder)
 
XKB_EXPORT enum xkb_status xkb_machine_builder::xkb_machine_builder_update_a11y (struct xkb_machine_builder *builder, const struct xkb_machine_builder_a11y_update *update)
 
XKB_EXPORT enum xkb_status xkb_machine_builder::xkb_machine_builder_update_mods_remap (struct xkb_machine_builder *builder, const struct xkb_machine_builder_mods_remap_update *update)
 
XKB_EXPORT enum xkb_status xkb_machine_builder::xkb_machine_builder_update_shortcut_override (struct xkb_machine_builder *builder, const struct xkb_machine_builder_shortcut_override_update *update)
 
XKB_EXPORT struct xkb_machine * xkb_machine::xkb_machine_new (const struct xkb_machine_builder *builder, enum xkb_status *status)
 
XKB_EXPORT struct xkb_machine * xkb_machine::xkb_machine_ref (struct xkb_machine *machine)
 
XKB_EXPORT void xkb_machine::xkb_machine_unref (struct xkb_machine *machine)
 
XKB_EXPORT struct xkb_keymap * xkb_machine::xkb_machine_get_keymap (const struct xkb_machine *machine)
 
XKB_EXPORT enum xkb_status xkb_machine::xkb_machine_process_key (struct xkb_machine *machine, xkb_keycode_t key, enum xkb_key_direction direction, struct xkb_events *events)
 
XKB_EXPORT enum xkb_status xkb_machine::xkb_machine_process_synthetic (struct xkb_machine *machine, const struct xkb_synthetic_update *update, struct xkb_events *events)
 

Detailed Description

Creating, destroying and manipulating server state machine.

Enumeration Type Documentation

◆ xkb_machine_builder_flags

Flags for xkb_machine_builder_config::flags.

See also
xkb_machine_builder::xkb_machine_builder_new()
Since
1.14.0
Enumerator
XKB_MACHINE_BUILDER_NO_FLAGS 

Do not apply any flags.

Since
1.14.0

◆ xkb_machine_flags

Flags for xkb_machine_builder_config::machine_flags.

See also
xkb_machine_builder::xkb_machine_builder_new()
Since
1.14.0
Enumerator
XKB_MACHINE_NO_FLAGS 

Do not apply any flags.

Since
1.14.0
XKB_MACHINE_SERVER_ACTIONS 

Enable server actions.

When this flag is enabled, all keys with server actions bound to them generate server events instead of usual key press and release events.

Since
1.14.0
XKB_MACHINE_DISABLE_LAYOUT_SWITCH_ON_MODIFIER_KEY_FIX 

Disable automated fix for keys combining modifiers and layout switch.

This flag is intended for debugging. See Automatic behavior fixes for further details.

Since
1.14.0
XKB_MACHINE_UNLOCK_MODS_ON_PRESS 

Make modifier actions unlock on key press rather than the default on key release.

It makes `SetMods(…, clearLocks)`, `LatchMods(…, clearLocks)` and `LockMods(…, affect=unlock)` act if `unlockOnPress=true` for actions without an explicit `unlockOnPress` parameter.

Since
1.14.0

◆ xkb_a11y_flags

Flags for xkb_machine_builder_a11y_update::flags.

These flags configure the accessibility (a11y) features.

Since
1.14.0
Enumerator
XKB_A11Y_NO_FLAGS 

Do not apply any flags.

Since
1.14.0
XKB_A11Y_STICKY_KEYS_NO_SIMULTANEOUS_KEYS 

If both XKB_A11Y_STICKY_KEYS_NO_SIMULTANEOUS_KEYS and XKB_KEYBOARD_CONTROL_A11Y_STICKY_KEYS are activated, they enable users to deactivate sticky keys whenever two keys or more are pressed simultaneously.

See also
XKB_KEYBOARD_CONTROL_A11Y_STICKY_KEYS
Since
1.14.0
XKB_A11Y_STICKY_KEYS_LATCH_TO_LOCK 

If both XKB_A11Y_STICKY_KEYS_LATCH_TO_LOCK and XKB_KEYBOARD_CONTROL_A11Y_STICKY_KEYS are activated, they enable users to lock modifier keys without requiring special locking keys.

The user can press a latch modifier twice in a row to lock it, and then unlock it by pressing it one more time.

See also
XKB_KEYBOARD_CONTROL_A11Y_STICKY_KEYS
Since
1.14.0
XKB_A11Y_LATCH_SIMULTANEOUS_KEYS 

Without this option, the latch keys are only triggers if keys are strictly sequentially tapped, e.g.:

  1. ISO_Level2_Latch ↓
  2. ISO_Level2_Latch ↑
  3. A ↓
  4. A ↑

If one wants multiple active latches, they must be tapped in sequence: e.g.:

  1. ISO_Level2_Latch ↓
  2. ISO_Level2_Latch ↑
  3. ISO_Level3_Latch ↓
  4. ISO_Level3_Latch ↑
  5. A ↓
  6. A ↑

This option relaxes the strict sequence requirement and enables operating keys that do not break latches simultaneously with a latch key, e.g.:

  1. ISO_Level2_Latch ↓
  2. ISO_Level3_Latch ↓
  3. ISO_Level2_Latch ↑
  4. ISO_Level3_Latch ↑
  5. A ↓
  6. A ↑

This is an extension to the X11 XKB protocol and is enabled by default when using XKB_KEYMAP_FORMAT_TEXT_V2.

Since
1.14.0

◆ xkb_layout_out_of_range_policy

Policies defining how to bring out-of-range layout indices into range.

See also
struct xkb_synthetic_update
xkb_machine::xkb_machine_process_synthetic()
Since
1.14.0
Enumerator
XKB_LAYOUT_OUT_OF_RANGE_WRAP 

Wrap into range using integer modulus (default).

Since
1.14.0
XKB_LAYOUT_OUT_OF_RANGE_CLAMP Clamp into range, i.e. invalid indices are corrected to the closest valid bound (0 or highest layout index).
Since
1.14.0
XKB_LAYOUT_OUT_OF_RANGE_REDIRECT 

Redirect to a specific layout index.

Since
1.14.0

Function Documentation

◆ xkb_machine_builder_new()

XKB_EXPORT struct xkb_machine_builder * xkb_machine_builder_new ( struct xkb_keymap *  keymap,
const struct xkb_machine_builder_config *  config,
enum xkb_status *  status 
)

Create a new xkb_machine builder object.

xkb_machine objects can then be created from the builder using xkb_machine::xkb_machine_new().

Parameters
[in]keymapThe keymap which the state machine will use. Shared ownership: the returned xkb_machine takes a new reference on this parameter.
[in]configConfiguration to control the builder behavior, or NULL for the defaults: an xkb_machine_builder_config struct with size set per Extensible structure ABI contract and all other fields zeroed.
[out]statusPointer to store the resulting status code, or NULL if not needed.
Precondition
config must point to a zero-initialized struct with `config->size` set per Extensible structure ABI contract.
Returns
A new xkb_machine builder object, or NULL on failure.
Postcondition
if status is not NULL, *status is set to XKB_SUCCESS on success or to an error code corresponding to the failure. Possible errors are:
See also
struct xkb_machine_builder_config
xkb_machine_builder_ref()
xkb_machine_builder_unref()
xkb_machine::xkb_machine_new()
Since
1.14.0

◆ xkb_machine_builder_ref()

XKB_EXPORT struct xkb_machine_builder * xkb_machine_builder_ref ( struct xkb_machine_builder *  builder)

Take a new reference on an xkb_machine builder object.

Parameters
[in]builderThe builder to reference.
Returns
The passed-in builder.
Since
1.14.0

◆ xkb_machine_builder_unref()

XKB_EXPORT void xkb_machine_builder_unref ( struct xkb_machine_builder *  builder)

Release a reference on an xkb_machine builder object, and possibly free it.

Parameters
[in]builderThe xkb_machine builder. If it is NULL, this function does nothing.
See also
xkb_machine_builder_new()
xkb_machine_builder_ref()
Since
1.14.0

◆ xkb_machine_builder_get_keymap()

XKB_EXPORT struct xkb_keymap * xkb_machine_builder_get_keymap ( const struct xkb_machine_builder *  builder)

Get the keymap which a xkb_machine_builder object is using.

Parameters
[in]builderThe state machine builder object.
Returns
The borrowed keymap which was passed to xkb_machine_builder_new() when creating this xkb_machine_builder object.
Warning
This function does not take a new reference on the keymap; you must explicitly reference it yourself if you plan to use it beyond the lifetime of the xkb_machine_builder object.
Since
1.14.0

◆ xkb_machine_builder_update_a11y()

XKB_EXPORT enum xkb_status xkb_machine_builder_update_a11y ( struct xkb_machine_builder *  builder,
const struct xkb_machine_builder_a11y_update *  update 
)

Update the accessibility flags of an xkb_machine_builder object.

Parameters
[in,out]builderThe xkb_machine builder object to modify.
[in]updateAccessibility update object.
Precondition
update must point to a zero-initialized struct with `update->size` set per Extensible structure ABI contract.
Returns
XKB_SUCCESS on success, otherwise an error code. Possible errors are:
See also
struct xkb_machine_builder_a11y_update
Since
1.14.0

◆ xkb_machine_builder_update_mods_remap()

XKB_EXPORT enum xkb_status xkb_machine_builder_update_mods_remap ( struct xkb_machine_builder *  builder,
const struct xkb_machine_builder_mods_remap_update *  update 
)

Update the modifiers remapping of an xkb_machine_builder object.

Parameters
[in,out]builderThe xkb_machine builder object to modify.
[in]updateModifiers remapping update object.
Precondition
update must point to a zero-initialized struct with `update->size` set per Extensible structure ABI contract.
Returns
XKB_SUCCESS on success, otherwise an error code. Possible errors are:
See also
struct xkb_machine_builder_mods_remap_update
Since
1.14.0

◆ xkb_machine_builder_update_shortcut_override()

XKB_EXPORT enum xkb_status xkb_machine_builder_update_shortcut_override ( struct xkb_machine_builder *  builder,
const struct xkb_machine_builder_shortcut_override_update *  update 
)

Update layout substitution of the shortcut layout overrides.

Parameters
[in,out]builderThe xkb_machine builder object to modify.
[in]updateShortcut layout substitution update object.
Precondition
update must point to a zero-initialized struct with `update->size` set per Extensible structure ABI contract.
Returns
XKB_SUCCESS on success, otherwise an error code. Possible errors are:
See also
struct xkb_machine_builder_shortcut_override_update
Since
1.14.0

◆ xkb_machine_new()

XKB_EXPORT struct xkb_machine * xkb_machine_new ( const struct xkb_machine_builder *  builder,
enum xkb_status *  status 
)

Create a new keyboard state machine object.

This entry point is intended for server applications; client applications should not run a state machine locally: instead they should use the xkb_state API and process server state update using xkb_state::xkb_state_update_mask(). See Server State and Client State for further information.

Parameters
[in]builderThe builder object from which to create the state machine.
[out]statusPointer to store the resulting status code, or NULL if not needed.
Returns
A new keyboard state machine object, or NULL on failure. The returned xkb_machine shares ownership of the xkb_keymap associated with builder via a new reference.
Postcondition
if status is not NULL, *status is set to XKB_SUCCESS on success or to an error code corresponding to the failure. Possible errors are:
See also
xkb_machine_builder::xkb_machine_builder_new()
Since
1.14.0

◆ xkb_machine_ref()

XKB_EXPORT struct xkb_machine * xkb_machine_ref ( struct xkb_machine *  machine)

Take a new reference on a xkb_machine object.

Parameters
[in]machineThe state machine.
Returns
The passed in object.
Since
1.14.0

◆ xkb_machine_unref()

XKB_EXPORT void xkb_machine_unref ( struct xkb_machine *  machine)

Release a reference on a xkb_machine object, and possibly free it.

Parameters
[in]machineThe state machine. If it is NULL, this function does nothing.
Since
1.14.0

◆ xkb_machine_get_keymap()

XKB_EXPORT struct xkb_keymap * xkb_machine_get_keymap ( const struct xkb_machine *  machine)

Get the keymap which a xkb_machine object is using.

Parameters
[in]machineThe state machine.
Returns
The borrowed keymap which was used to create the xkb_machine object, i.e. the keymap passed to xkb_machine_builder::xkb_machine_builder_new() when creating the corresponding builder used in xkb_machine_new().
Warning
This function does not take a new reference on the keymap; you must explicitly reference it yourself if you plan to use it beyond the lifetime of the xkb_machine object.
Since
1.14.0

◆ xkb_machine_process_key()

XKB_EXPORT enum xkb_status xkb_machine_process_key ( struct xkb_machine *  machine,
xkb_keycode_t  key,
enum xkb_key_direction  direction,
struct xkb_events *  events 
)

Process a key event – a pair (keycode, direction) – through the XKB state machine, and collect the resulting keyboard events into an event batch.

The produced events form a single frame.

Use this function for in-band (device) inputs. Use xkb_machine_process_synthetic() instead to update the state machine in response to out-of-band (non-device) inputs, such as UI layout switchers or accessibility settings changes.

A series of calls to this function should be consistent; that is, a call with XKB_KEY_DOWN for a key should be matched by an XKB_KEY_UP; if a key is pressed twice, it should be released twice; etc. Otherwise (e.g. due to missed input events), situations like “stuck modifiers” may occur.

Parameters
[in,out]machineThe XKB state machine object.
[in]keyThe keycode of the key being operated.
[in]directionThe direction of the key operation.
[out]eventsThe event batch to collect events into. It will be reset before collecting.
Returns
XKB_SUCCESS on success, otherwise an error code.
See also
xkb_machine_process_synthetic()
Since
1.14.0

◆ xkb_machine_process_synthetic()

XKB_EXPORT enum xkb_status xkb_machine_process_synthetic ( struct xkb_machine *  machine,
const struct xkb_synthetic_update *  update,
struct xkb_events *  events 
)

Process a synthetic (out-of-band) atomic update through the XKB state machine, and collect the resulting keyboard events into an event batch.

Use this function to update the state machine in response to out-of-band (non-device) inputs, such as UI layout switchers or accessibility settings changes. Use xkb_machine_process_key() instead for in-band (device) inputs.

All changes specified in update are applied atomically as a single frame: the resulting events reflect the net state change at the end of the frame, not intermediate steps. In particular, a XKB_EVENT_TYPE_STATE_COMPONENTS event in the batch represents the cumulative state change for the entire frame — individual intermediate state transitions are not observable.

Only latched, locked and control components can be updated out-of-band; depressed components can only change through key presses via xkb_machine_process_key().

Layout out of range
If the effective layout, after taking into account the depressed, latched and locked layout, is out of range (negative or greater than the maximum layout index), it is brought into range according to the current out-of-range layout policy (see xkb_layout_out_of_range_policy).
Parameters
[in,out]machineThe XKB state machine object.
[in]updateThe update to apply.
[out]eventsThe event batch to collect events into. It will be reset before collecting.
Precondition
update must point to a zero-initialized struct with `update->size` set per Extensible structure ABI contract.
Returns
XKB_SUCCESS on success, otherwise an error code. Possible errors are:
See also
struct xkb_synthetic_update
struct xkb_state_components_update
struct xkb_layout_policy_update
xkb_machine_process_key()
Since
1.14.0