XkbAddGeomDoodad(3)

πŸ’… XkbAddGeomDoodad β€” it's in XKB FUNCTIONS btw

okay so bestie, you're in the XkbAddGeomDoodad(3) page and honestly? this one's kinda cute. it's all about sticking one (1) doodad onto a section of a keyboard geometry, or onto the top-level geometry itself. icon behavior, no cap. πŸ’–


✨ SYNOPSIS ✨

XkbDoodadPtr XkbAddGeomDoodad (XkbGeometryPtr geom, XkbSectionPtr
       section, Atom name);

like, three args, one pointer back, we love a simple signature 🫢


πŸŽ€ ARGUMENTS πŸŽ€

  • geom β€” the geometry you're adding the doodad to, obviously πŸ’β€β™€οΈ
  • section β€” the section, if any, you're adding it to. yes "if any" β€” hold that thought, it matters later πŸ‘€
  • name β€” the name of your brand-new doodad. give it a good one ✨

🌸 DESCRIPTION 🌸

so Xkb has a whole lil family of functions that each add a single new element to the top-level keyboard geometry. and in each case β€” literally every one β€” the num_* fields of the corresponding struct get incremented by 1. main character bookkeeping, fr fr πŸ’…

important though: these functions do not change sz_* unless there's genuinely no more room left in the array. so like, don't assume the size grew just because the count did, bestie 😭

and heads up on the last bit: some of these functions fill in the values of the element's structure straight from the arguments, but for other functions you have to explicitly write code yourself to fill the structure's elements. iykyk 🧚

okay so now, geometry properties. the top-level geometry description includes a list of geometry properties, and a geometry property associates an arbitrary string with an equally arbitrary name. programs that display images of keyboards can use geometry properties as hints β€” but Xkb itself does not interpret them. at all. they're just vibes ✨ and no other geometry structures refer to geometry properties. periodt.

now, the actual star of the show: a doodad describes some visible aspect of the keyboard that is not a key and not a section. so like, decor. garnish. the keyboard's accessories πŸŽ€

XkbAddGeomDoodad adds a doodad with the name specified by name to:

  • the geometry geom β€” if section is NULL
  • the section of the geometry specified by section β€” if section is not NULL

and here's the vibe check on returns: XkbAddGeomDoodad returns NULL if any of the parameters is empty, or if it straight up wasn't able to allocate space for the doodad. no space, no doodad, no notes πŸ’€

BUT β€” plot twist β€” if there's already a doodad with the name name in the doodad array for the geometry (when section is NULL) or for the section (when section is non-NULL), then it just returns a pointer to that doodad. so it's not gonna duplicate, it's gonna hand you the existing one. respectful. πŸ‘‘

also like, quick PSA: if you need space for an arbitrary number of doodads on a section, use the XkbAllocGeomSectionDoodads function. and if you need space for an arbitrary number of doodads on a keyboard geometry, use the XkbAllocGeomDoodads function. don't just rawdog it, use the allocators 🫢

🌈 STRUCTURES 🌈

typedef union _XkbDoodad {
    XkbAnyDoodadRec            any;
    XkbShapeDoodadRec          shape;
    XkbTextDoodadRec           text;
    XkbIndicatorDoodadRec      indicator;
    XkbLogoDoodadRec           logo;
} XkbDoodadRec, *XkbDoodadPtr;

it's a union, it's giving versatility, it said "why choose one doodad type when you can be all of them" πŸ’œ


πŸ‘€ SEE ALSO πŸ‘€


okay that's the whole page, you ate it, you understood it, go add some doodads πŸ¦‹

and for the record, this lil masterpiece comes from X Version 11, libX11 1.8.14 β€” a true classic πŸŽ€πŸ’– slay, bye ✨

πŸ“¦ where this page comes from