XkbKeyGroupWidth(3)

πŸ’… XkbKeyGroupWidth β€” the libX11 era, bestie

okay so real talk, this one lives in the XKB FUNCTIONS section of the libX11 manual (X Version 11, if we're being specific πŸŽ€), and it's genuinely one of those little helper functions that does exactly one thing and does it iconically.


✨ NAME ✨

XkbKeyGroupWidth β€” literally computes the width of the type associated with the group grp for the key corresponding to keycode. that's it. that's the whole job. slay. πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

int XkbKeyGroupWidth (XkbDescPtr xkb, KeyCode keycode, int grp);

🌸 ARGUMENTS 🌸

  • xkb β€” the Xkb description you care about. the main character of this whole operation.
  • keycode β€” the keycode you're curious about. which key, bestie?
  • grp β€” the group you want. pick your group, babes.

πŸ’– DESCRIPTION πŸ’–

okay so here's the lore 🧚 β€” the key width and the number of groups associated with a key get used to form a small two-dimensional array of KeySyms for a key. and like, this array can be a different size for different keys. no cap. not every key gets the same real estate.

the array for a single key is stored as a linear list, in row-major order. the arrays for all the keys live in the syms field of the client map. so it's giving one big shared storage situation. 🫢

there's one row for each group associated with a key, and one column for each level. and the index corresponding to a given group and shift level is computed like this:

idx = group_index * key_width + shift_level

and the offset field of the key_sym_map entry for a key is what you use to access the beginning of the array. iykyk. πŸ”₯

so then XkbKeyGroupWidth goes ahead and computes the width of the type associated with the group grp for the key corresponding to keycode. that's the whole vibe check, and it passes. ⭐


lowkey important: that idx formula is group_index * key_width + shift_level β€” copy it exactly, don't get creative with it, bestie 😭

πŸ‘‘ sign-off πŸ‘‘

that's the page, bestie β€” shipped as part of libX11 1.8.14 under X Version 11, and yes, this was XkbKeyGroupWidth(3) the entire time πŸ¦‹πŸ’œ

πŸ“¦ where this page comes from