XkbGetMap(3)
π XkbGetMap β the XKB glow-up manual (section 3, XKB FUNCTIONS) π
okay bestie, pull up a chair, because this one is literally the blueprint for getting the keyboard's whole vibe from the server β¨
πΈ NAME πΈ
XkbGetMap β allocates an XkbDescRec structure and fills it with the server's keyboard client map and server map. it's giving "build me the whole keyboard blueprint from scratch" energy π
π¦ SYNOPSIS π¦
XkbDescPtr XkbGetMap (Display *display, unsigned int which, unsigned int
device_spec);
β¨ ARGUMENTS β¨
displayβ the connection to the X server. your link to the mothership π°οΈwhichβ a mask that selects which subcomponents get populated. it's the "which parts of the map do u actually want" checklist πdevice_specβ adevice_id, orXkbUseCoreKbd. so like, which keyboard are we talking about π
π DESCRIPTION π
so Xkb gives you two functions for pulling keyboard mapping components off the server, and they're siblings, not twins, okay? π«Ά
The first one, XkbGetMap, allocates an XkbDescRec structure, retrieves mapping components from the server, and stores them in the XkbDescRec structure it just allocated. brand new struct, freshly stocked, no cap π
The second one, XkbGetUpdatedMap, retrieves mapping components from the server and stores them in an XkbDescRec structure that has previously been allocated. that one's for the "i already have a struct at home" girlies π
To allocate an XkbDescRec structure and populate it with the server's keyboard client map and server map, use XkbGetMap. XkbGetMap is similar to XkbGetKeyboard, but is used only for obtaining the address of an XkbDescRec structure that is populated with keyboard mapping components. it gives you finer control over which substructures of the keyboard mapping components are to be populated β like ordering off the menu instead of getting the set meal π XkbGetKeyboard always returns fully populated components, while XkbGetMap can be instructed to return a partially populated component. main character energy: you decide π₯
The which mask is a bitwise inclusive OR of the masks defined in Table 14.1. Only those portions of the keyboard server map and the keyboard client maps that are specified in which are allocated and populated. so like, if you didn't ask for it, it's not invited to the party π«π
In addition to allocating and obtaining the server map and the client map, XkbGetMap also sets the device_spec, the min_key_code, and max_key_code fields of the keyboard description. little bonus garnish, we love a thorough function π
XkbGetMap is synchronous β it queries the server for the desired information, waits for a reply, and then returns. it does not do the "i'll text u later" thing, it waits for the reply like a loyal bestie π
If successful,XkbGetMapreturns a pointer to theXkbDescRecstructure it allocated. If unsuccessful,XkbGetMapreturnsNULL. π
When unsuccessful, one of the following protocol errors is also generated:
BadAllocβ unable to allocate theXkbDescRecstructure πBadValueβ some mask bits inwhichare undefined πBadImplementationβ a compatible version of the Xkb extension is not available in the server π§
To free the returned data, use XkbFreeKeyboard. clean up after yourself, periodt π§Ή
π Convenience functions (yes, there's more) π
Xkb also provides convenience functions to get partial component definitions from the server. These functions are specified in the "convenience functions" column in Table 1 (below, bestie). Refer to the sections listed in the table for more information on these functions π
π Table 1 β Xkb Mapping Component Masks and Convenience Functions π
XkbKeyTypesMaskβ Value(1<<0)β Map: client β Fields:types,size_types,num_typesβ Convenience Functions:XkbGetKeyTypes,XkbResizeKeyType,XkbCopyKeyType,XkbCopyKeyTypesXkbKeySymsMaskβ Value(1<<1)β Map: client β Fields:syms,size_syms,num_syms,key_sym_mapβ Convenience Functions:XkbGetKeySyms,XkbResizeKeySyms,XkbChangeTypesOfKeyXkbModifierMapMaskβ Value(1<<2)β Map: client β Fields:modmapβ Convenience Functions:XkbGetKeyModifierMapXkbExplicitComponentsMaskβ Value(1<<3)β Map: server β Fields:explicitβ Convenience Functions:XkbGetKeyExplicitComponentsXkbKeyActionsMaskβ Value(1<<4)β Map: server β Fields:key_acts,acts,num_acts,size_actsβ Convenience Functions:XkbGetKeyActions,XkbResizeKeyActionsXkbKeyBehaviorsMaskβ Value(1<<5)β Map: server β Fields:behaviorsβ Convenience Functions:XkbGetKeyBehaviorsXkbVirtualModsMaskβ Value(1<<6)β Map: server β Fields:vmodsβ Convenience Functions:XkbGetVirtualModsXkbVirtualModMapMaskβ Value(1<<7)β Map: server β Fields:vmodmapβ Convenience Functions:XkbGetVirtualModMap
Xkb defines combinations of these masks for convenience, and here they are, verbatim, no cap π«‘
#define XkbResizableInfoMask (XkbKeyTypesMask)
#define XkbAllClientInfoMask (XkbKeyTypesMask | XkbKeySymsMask |
XkbModifierMapMask)
#define XkbAllServerInfoMask (XkbExplicitComponentsMask |
XkbKeyActionsMask |
XkbKeyBehaviorsMask |
XkbVirtualModsMask |
XkbVirtualModMapMask)
#define XkbAllMapComponentsMask XkbAllClientInfoMask |
XkbAllServerInfoMask)
Key types, symbol maps, and actions are all interrelated: changes in one require changes in the others. it's giving codependent friend group π The convenience functions make it easier to edit these components and handle the interdependencies. they're the group chat admins keeping everyone in sync π
π STRUCTURES π
The complete description of an Xkb keyboard is given by an XkbDescRec. The component structures in the XkbDescRec represent the major Xkb components. look at her, she's beautiful π
typedef struct {
struct _XDisplay * display; /* connection to X server */
unsigned short flags; /* private to Xkb, do not modify */
unsigned short device_spec; /* device of interest */
KeyCode min_key_code; /* minimum keycode for device */
KeyCode max_key_code; /* maximum keycode for device */
XkbControlsPtr ctrls; /* controls */
XkbServerMapPtr server; /* server keymap */
XkbClientMapPtr map; /* client keymap */
XkbIndicatorPtr indicators; /* indicator map */
XkbNamesPtr names; /* names for all components */
XkbCompatMapPtr compat; /* compatibility map */
XkbGeometryPtr geom; /* physical geometry of keyboard */
} XkbDescRec, *XkbDescPtr;
The display field points to an X display structure. The flags field is private to the library: modifying flags may yield unpredictable results β do NOT touch, bestie, it's not yours π
ββοΈ The device_spec field specifies the device identifier of the keyboard input device, or XkbUseCoreKeyboard, which specifies the core keyboard device. The min_key_code and max_key_code fields specify the least and greatest keycode that can be returned by the keyboard. the full range, the whole spectrum, the entire era πΆ
Each structure component has a corresponding mask bit that is used in function calls to indicate that the structure should be manipulated in some manner, such as allocating it or freeing it. These masks and their relationships to the fields in the XkbDescRec are shown in Table 2. iykyk π
π§ Table 2 β Mask Bits for XkbDescRec π§
XkbControlsMaskβXkbDescRecField:ctrlsβ Value(1L<<0)XkbServerMapMaskβXkbDescRecField:serverβ Value(1L<<1)XkbIClientMapMaskβXkbDescRecField:mapβ Value(1L<<2)XkbIndicatorMapMaskβXkbDescRecField:indicatorsβ Value(1L<<3)XkbNamesMaskβXkbDescRecField:namesβ Value(1L<<4)XkbCompatMapMaskβXkbDescRecField:compatβ Value(1L<<5)XkbGeometryMaskβXkbDescRecField:geomβ Value(1L<<6)XkbAllComponentsMaskβXkbDescRecField: All Fields β Value(0x7f)
π¦ SEE ALSO π¦
the whole squad, in order, go say hi π
XkbChangeTypesOfKey(3), XkbCopyKeyType(3), XkbCopyKeyTypes(3), XkbFreeClientMap(3), XkbGetKeyActions(3), XkbGetKeyBehaviors(3), XkbGetKeyboard(3), XkbGetKeyExplicitComponents(3), XkbGetKeyModifierMap(3), XkbGetKeySyms(3), XkbGetKeyTypes(3), XkbGetUpdatedMap(3), XkbGetVirtualModMap(3), XkbGetVirtualMods(3), XkbResizeKeyActions(3), XkbResizeKeySyms(3), XkbResizeKeyType(3)
okay that's the whole thing, you ate that reading session fr fr π β¨
mwah π this drop was brought to you by X Version 11, libX11 1.8.14, page XkbGetMap(3) β go forth and map those keys, bestie ππ¦
π¦ where this page comes from
- alpine 3.24: libx11-doc 1.8.14-r0 Β· X11
- arch rolling: libx11 1.8.14-1 Β· MIT AND X11
- nixos 26.05: libx11 1.8.14
- nixpkgs unstable: libx11 1.8.14
- Copyright (c) 1999, Oracle and/or its affiliates
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms