|
xkbcommon 1.14.0-beta2
Reference library implementing the XKB specification for parsing keyboard descriptions and handling keyboard state
|
#include <xkbcommon.h>
Public Member Functions | |
| XKB_EXPORT struct xkb_machine * | xkb_machine_new (const struct xkb_machine_builder *builder, enum xkb_status *status) |
| XKB_EXPORT struct xkb_machine * | xkb_machine_ref (struct xkb_machine *machine) |
| XKB_EXPORT void | xkb_machine_unref (struct xkb_machine *machine) |
| XKB_EXPORT struct xkb_keymap * | xkb_machine_get_keymap (const struct xkb_machine *machine) |
| 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) |
| XKB_EXPORT enum xkb_status | xkb_machine_process_synthetic (struct xkb_machine *machine, const struct xkb_synthetic_update *update, struct xkb_events *events) |
Opaque XKB state machine object.
xkb_machine is a Mealy machine: it is a finite-state machine that takes a stream of raw key events – a pair (keycode, direction) – as input, and produces a stream of atomic XKB events as output. Output depends on both the input and the current internal state (active modifiers, current layout, etc.).
This is the authoritative object for server-side XKB processing.
xkbcommon automatically fixes some usual shortcomings of classic XKB:
| Title | Description |
|---|---|
| Layout switch on modifier key | Enables modifier-based layout switching (such as Alt+Shift) to function both as a standalone switch when pressed and released alone, and as a modifier in keyboard shortcuts when combined with other keys.
Under the hood, this performs the following adjustments:
It may be deactivated using: |
xkb_state created via xkb_state::xkb_state_new_from_machine() and updated via xkb_state::xkb_state_update_event(). The xkb_state object is the observable state of the machine and provides the full query API.See Server State and Client State for details.
See the example for a Wayland server in the quick guide.
_Shared_ ownership using reference counting. Heap-allocated by xkb_machine_new(), which creates the first reference. Take additional references with xkb_machine_ref() and release each of them with exactly one xkb_machine_unref() call. The object is destroyed once its last reference has been released.
Owns a reference to the xkb_keymap passed during initialization, kept for the entire lifetime of the xkb_machine instance and released when calling xkb_machine_unref().
xkb_keymap remains valid for the entire lifetime of an xkb_machine instance thanks to reference counting on xkb_keymap. You may release your own reference as soon as the xkb_machine is created.