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 β€” a device_id, or XkbUseCoreKbd. 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, XkbGetMap returns a pointer to the XkbDescRec structure it allocated. If unsuccessful, XkbGetMap returns NULL. 😭

When unsuccessful, one of the following protocol errors is also generated:

  • BadAlloc β€” unable to allocate the XkbDescRec structure πŸ’€
  • BadValue β€” some mask bits in which are 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, XkbCopyKeyTypes
  • XkbKeySymsMask β€” Value (1<<1) β€” Map: client β€” Fields: syms, size_syms, num_syms, key_sym_map β€” Convenience Functions: XkbGetKeySyms, XkbResizeKeySyms, XkbChangeTypesOfKey
  • XkbModifierMapMask β€” Value (1<<2) β€” Map: client β€” Fields: modmap β€” Convenience Functions: XkbGetKeyModifierMap
  • XkbExplicitComponentsMask β€” Value (1<<3) β€” Map: server β€” Fields: explicit β€” Convenience Functions: XkbGetKeyExplicitComponents
  • XkbKeyActionsMask β€” Value (1<<4) β€” Map: server β€” Fields: key_acts, acts, num_acts, size_acts β€” Convenience Functions: XkbGetKeyActions, XkbResizeKeyActions
  • XkbKeyBehaviorsMask β€” Value (1<<5) β€” Map: server β€” Fields: behaviors β€” Convenience Functions: XkbGetKeyBehaviors
  • XkbVirtualModsMask β€” Value (1<<6) β€” Map: server β€” Fields: vmods β€” Convenience Functions: XkbGetVirtualMods
  • XkbVirtualModMapMask β€” 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 β€” XkbDescRec Field: ctrls β€” Value (1L<<0)
  • XkbServerMapMask β€” XkbDescRec Field: server β€” Value (1L<<1)
  • XkbIClientMapMask β€” XkbDescRec Field: map β€” Value (1L<<2)
  • XkbIndicatorMapMask β€” XkbDescRec Field: indicators β€” Value (1L<<3)
  • XkbNamesMask β€” XkbDescRec Field: names β€” Value (1L<<4)
  • XkbCompatMapMask β€” XkbDescRec Field: compat β€” Value (1L<<5)
  • XkbGeometryMask β€” XkbDescRec Field: geom β€” Value (1L<<6)
  • XkbAllComponentsMask β€” XkbDescRec Field: 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