XkbSetMap(3)
π
XkbSetMap(3) β XKB FUNCTIONS π
okay bestie, welcome to the XkbSetMap(3) page from the XKB FUNCTIONS manual. this one is lowkey a big deal: itβs all about sending a whole fresh set of map values to the server. no cap, weβre keeping every detail. π
β¨ NAME β¨
XkbSetMap β Send a complete new set of values for entire components to the server.
π SYNOPSIS π
Bool XkbSetMap (Display *dpy, unsigned int which, XkbDescPtr xkb);
π ARGUMENTS π
dpyβ connection to X serverwhichβ mask selecting subcomponents to updatexkbβ description from which new values are taken
π¦ DESCRIPTION π¦
okay so there are literally two ways to make changes to map components: either change a local copy of the keyboard map and call XkbSetMap to send the modified map to the server, or β to reduce network traffic β use an XkbMapChangesRec structure and call XkbChangeMap. both iconic, different vibes. β¨
Use XkbSetMap to send a complete new set of values for entire components (for example, all symbols, all actions, and so on) to the server. The which parameter specifies the components to be sent to the server, and is a bitwise inclusive OR of the masks listed in Table 1. The xkb parameter is a pointer to an XkbDescRec structure and contains the information to be copied to the server. For each bit set in the which parameter, XkbSetMap takes the corresponding structure values from the xkb parameter and sends it to the server specified by dpy.
If any components specified by which are not present in the xkb parameter, XkbSetMap returns False. Otherwise, it sends the update request to the server and returns True. XkbSetMap can generate BadAlloc, BadLength, and BadValue protocol errors.
β οΈ heads up bestie: those protocol errors are real βBadAlloc,BadLength, andBadValue. do not ignore the vibe check. π
Key types, symbol maps, and actions are all interrelated; changes in one require changes in the others. Xkb provides functions to make it easier to edit these components and handle the interdependencies. Table 1 lists these helper functions and provides a pointer to where they are defined.
π 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
The changed field identifies the map components that have changed in an XkbDescRec structure and may contain any of the bits in Table 1, which are also shown in Table 2. Every 1 bit in changed also identifies which other fields in the XkbMapChangesRec structure contain valid values, as indicated in Table 2. The min_key_code and max_key_code fields are for reference only; they are ignored on any requests sent to the server and are always updated by the server whenever it returns the data for an XkbMapChangesRec.
π Table 2 XkbMapChangesRec Masks π
XkbKeyTypesMaskβ ValidXkbMapChangesRecfields:first_type,num_types;XkbDescRecfield containing changed data:map->type[first_type] .. map->type[first_type + num_types - 1]XkbKeySymsMaskβ ValidXkbMapChangesRecfields:first_key_sym,num_key_syms;XkbDescRecfield containing changed data:map->key_sym_map[first_key_sym] .. map->key_sym_map[first_key_sym + num_key_syms - 1]XkbModifierMapMaskβ ValidXkbMapChangesRecfields:first_modmap_key,num_modmap_keys;XkbDescRecfield containing changed data:map->modmap[first_modmap_key] .. map->modmap[first_modmap_key + num_modmap_keys - 1]XkbExplicitComponentsMaskβ ValidXkbMapChangesRecfields:first_key_explicit,num_key_explicit;XkbDescRecfield containing changed data:server->explicit[first_key_explicit] .. server->explicit[first_key_explicit + num_key_explicit - 1]XkbKeyActionsMaskβ ValidXkbMapChangesRecfields:first_key_act,num_key_acts;XkbDescRecfield containing changed data:server->key_acts[first_key_act] .. server->key_acts[first_key_act + num_key_acts - 1]XkbKeyBehaviorsMaskβ ValidXkbMapChangesRecfields:first_key_behavior,num_key_behaviors;XkbDescRecfield containing changed data:server->behaviors[first_key_behavior] .. server->behaviors[first_key_behavior + num_key_behaviors - 1]XkbVirtualModsMaskβ ValidXkbMapChangesRecfields:vmods;XkbDescRecfield containing changed data:server->vmods[*]XkbVirtualModMapMaskβ ValidXkbMapChangesRecfields:first_vmodmap_key,num_vmodmap_keys;XkbDescRecfield containing changed data:server->vmodmap[first_vmodmap_key] .. server->vmodmap[first_vmodmap_key + num_vmodmap_keys - 1]
π RETURN VALUES π
Trueβ TheXkbSetMapfunction returnsTrueall components specified bywhichare present in thexkbparameter.Falseβ TheXkbSetMapfunction returnsFalseif any component specified bywhichis not present in thexkbparameter.
β¨ STRUCTURES β¨
Okay so, bestie, use the XkbMapChangesRec structure to identify and track partial modifications to the mapping components β and to reduce the amount of traffic between the server and clients. Itβs giving βletβs not ship the whole keyboard over the wire every timeβ energy π
typedef struct _XkbMapChanges {
unsigned short changed; /* identifies valid components in structure */
KeyCode min_key_code; /* lowest numbered keycode for device */
KeyCode max_key_code; /* highest numbered keycode for device */
unsigned char first_type; /* index of first key type modified */
unsigned char num_types; /* # types modified */
KeyCode first_key_sym; /* first key whose key_sym_map changed */
unsigned char num_key_syms; /* # key_sym_map entries changed */
KeyCode first_key_act; /* first key whose key_acts entry changed */
unsigned char num_key_acts; /* # key_acts entries changed */
KeyCode first_key_behavior; /* first key whose behaviors changed */
unsigned char num_key_behaviors; /* # behaviors entries changed */
KeyCode first_key_explicit; /* first key whose explicit entry changed */
unsigned char num_key_explicit; /* # explicit entries changed */
KeyCode first_modmap_key; /* first key whose modmap entry changed */
unsigned char num_modmap_keys; /* # modmap entries changed */
KeyCode first_vmodmap_key; /* first key whose vmodmap changed */
unsigned char num_vmodmap_keys; /* # vmodmap entries changed */
unsigned char pad1; /* reserved */
unsigned short vmods; /* mask indicating which vmods changed */
} XkbMapChangesRec,*XkbMapChangesPtr;
The complete description of an Xkb keyboard is given by an XkbDescRec. The component structures in the XkbDescRec represent the major Xkb components. Iconic, honestly π₯
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 β so do not touch it, bestie, I am so serious π
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. Slay.
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 3.
π Table 3 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)
π DIAGNOSTICS π
BadAllocβ unable to allocate storage. The allocation said βnot todayβ πBadLengthβ the length of a request is shorter or longer than that required to minimally contain the arguments. Bestie, the request length is doing too much or not enough πBadValueβ an argument is out of range. Itβs giving βgirl, that value is not welcome hereβ π
π¦ SEE ALSO π¦
XkbChangeMap(3)XkbChangeTypesOfKey(3)XkbCopyKeyType(3)XkbCopyKeyTypes(3)XkbGetKeyActions(3)XkbGetKeyBehaviors(3)XkbGetKeyExplicitComponents(3)XkbGetKeyModifierMap(3)XkbGetKeySyms(3)XkbGetKeyTypes(3)XkbResizeKeyActions(3)XkbResizeKeySyms(3)XkbResizeKeyType(3)XkbGetVirtualModMap(3)XkbGetVirtualMods(3)
Okay bestie, thatβs the whole page π The source/version is X Version 11, libX11 1.8.14, and the page is XkbSetMap(3). The footer didnβt show a date, so Iβm not gonna invent one β no cap β¨π
π¦ 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