XkbAddGeomShape(3)

πŸ’… XkbAddGeomShape(3) β€” from the XKB FUNCTIONS manual, bestie πŸŽ€

Okay so real talk, this one's called XkbAddGeomShape and it does exactly what it says on the tin: it adds a shape to a keyboard geometry. Iconic behavior, honestly. ✨


✨ SYNOPSIS ✨

XkbShapePtr XkbAddGeomShape (XkbGeometryPtr geom, Atom name, int
       sz_outlines);

Like, that's the whole call. Three args, one pointer back. Simple slay. πŸ’…


🌸 ARGUMENTS 🌸

  • geom β€” the geometry you're updating, i.e. the thing getting the glow-up πŸ’–
  • name β€” the name of the new shape. Yep, you gotta name it. It's giving naming your sim.
  • sz_outlines β€” how many outlines you want reserved. Reserved, not created. Important distinction, no cap. 🫢

πŸ’œ DESCRIPTION πŸ’œ

So the tea is: Xkb provides functions that add a single new element to the top-level keyboard geometry. In each case, the num_* fields of the corresponding structure get incremented by 1. That's it, that's the vibe. ✨

⚠️ Heads up bestie: these functions do not change sz_* unless there's literally no more room in the array. So don't come for them when your size field looks stale. 😭

Some of these functions fill in the values of the element's structure from the arguments. For other functions, you have to explicitly write code yourself to fill the structure's elements. So like... read the room, check which one you're using. πŸ™ˆ

The top-level geometry description includes a list of geometry properties. 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 they are not interpreted by Xkb β€” it's giving "suggestion box, not a rulebook" πŸ“. No other geometry structures refer to geometry properties. Periodt.

A geometry contains an arbitrary number of shapes, each of which is made up of an arbitrary number of outlines. Very "arbitrary" of them, we love that for them. πŸ¦‹

XkbAddGeomShape adds a shape to a geometry geom by allocating space for sz_outlines outlines for it and giving it the name specified by name. πŸŽ€

  • If a shape with the name name already exists in the geometry β†’ a pointer to the existing shape is returned. No duplicates, we're not doing that today. πŸ‘‘
  • XkbAddGeomShape returns NULL if any of the parameters is empty or if it was not able to allocate space. Sad but true. πŸ’€

To allocate space for an arbitrary number of geometry shapes, use XkbAllocGeomShapes. That's the "buy in bulk" option. πŸ›’


🧚 STRUCTURES 🧚

typedef struct _XkbShape {
    Atom              name;           /* shape's name */
    unsigned short    num_outlines;   /* number of outlines for the shape */
    unsigned short    sz_outlines;    /* size of the outlines array */
    XkbOutlinePtr     outlines;       /* array of outlines for the shape */
    XkbOutlinePtr     approx;         /* pointer into the array to the approximating outline */
    XkbOutlinePtr     primary;        /* pointer into the array to the primary outline */
    XkbBoundsRec      bounds;         /* bounding box for the shape; encompasses all outlines */
} XkbShapeRec, *XkbShapePtr;

Read the comments, they're literally right there and they ate. πŸ”₯ That bounds field? Bounding box for the shape, encompasses all outlines β€” main character energy fr fr. 🌈


⭐ SEE ALSO ⭐


And that's the whole page, diva πŸ’œ β€” brought to you by X Version 11, libX11 1.8.14, dated right there in the footer alongside XkbAddGeomShape(3). Go forth and add shapes, you gorgeous Unix gremlin 🧚✨

πŸ“¦ where this page comes from