xkbcommon 1.14.0-beta2
Reference library implementing the XKB specification for parsing keyboard descriptions and handling keyboard state
Loading...
Searching...
No Matches
Functions
Server companion keyboard state
Collaboration diagram for Server companion keyboard state:

Functions

XKB_EXPORT struct xkb_state * xkb_state::xkb_state_new_from_machine (const struct xkb_machine *machine, enum xkb_status *status)
 
XKB_EXPORT enum xkb_status xkb_state::xkb_state_update_event (struct xkb_state *state, const struct xkb_event *event, enum xkb_state_component *changed)
 

Detailed Description

xkb_machine companion-specific API.

Function Documentation

◆ xkb_state_new_from_machine()

XKB_EXPORT struct xkb_state * xkb_state_new_from_machine ( const struct xkb_machine *  machine,
enum xkb_status *  status 
)

Create a new keyboard state object as an observer of an xkb_machine.

Constructor for server applications using the xkb_machine API:

See Server State and Client State for further information.

Note
The created state must be kept in sync with the machine using xkb_state_update_event().
The returned state is independent of the machine’s lifetime.
Parameters
[in]machineThe state machine whose keymap the new state will use.
[out]statusPointer to store the resulting status code, or NULL if not needed.
Returns
A new keyboard state object, or NULL on failure. The returned xkb_state shares ownership of the xkb_keymap associated with machine 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_state_new_with_mode()
XKB_STATE_MODE_SERVER_QUERY
struct xkb_machine
Since
1.14.0

◆ xkb_state_update_event()

XKB_EXPORT enum xkb_status xkb_state_update_event ( struct xkb_state *  state,
const struct xkb_event *  event,
enum xkb_state_component *  changed 
)

Update the keyboard state components from an event.

This entry point serves the companion role of xkb_machine. It is intended for server applications and should not be used by client applications; see Server State and Client State for details.

It enables server applications to use xkb_state as the observable state companion to an xkb_machine: feed each event produced by xkb_machine::xkb_machine_process_key() or xkb_machine::xkb_machine_process_synthetic() into this function to keep the observable state in sync.

Parameters
[in,out]stateThe keyboard state object.
[in]eventThe state event to update from.
[out]changedA pointer to the mask of state components that have changed as a result of the update, or NULL to ignore. If nothing in the state has changed, the mask is set to 0 (XKB_STATE_NO_COMPONENT).
Precondition
state must be created with xkb_state_new_from_machine() (i.e. with mode XKB_STATE_MODE_SERVER_QUERY) or xkb_state_new(), otherwise the call is rejected without updating the state and the misuse is logged as XKB_ERROR_UNEXPECTED_STATE_MODE.
Returns
Note
This function returns an error code rather than a state component delta (unlike other xkb_state_update_*() functions), in order to align with xkb_state_update_synthetic() API. The delta is optionally available via the changed parameter.
See also
xkb_state_new_from_machine()
Since
1.14.0