XkbGetIndicatorState(3)

πŸ’… XkbGetIndicatorState(3) β€” aka the XKB FUNCTIONS girlies

okay so bestie, buckle up, we're diving into XkbGetIndicatorState from the XKB FUNCTIONS corner of the universe ✨ this is a libX11 situation and it's lowkey iconic.


🌸 NAME 🌸

XkbGetIndicatorState β€” literally just goes and gets you the current state of the keyboard indicators πŸŽ€ that's it, that's the whole job, and she does it well.


✨ SYNOPSIS ✨

Status XkbGetIndicatorState (Display *display, unsigned int device_spec,
       unsigned int state_return);

copy that exactly, bestie, don't get creative with the types πŸ™ˆ


πŸ¦‹ ARGUMENTS πŸ¦‹

  • display β€” the connection to the X server, your little phone line to the mothership πŸ“ž
  • device_spec β€” the device ID, or you can pass XkbUseCoreKbd if you're feeling basic πŸ’…
  • state_return β€” gets backfilled with a mask of the indicator state, so it comes back changed, like a glow-up but for a variable 🫢

πŸ’œ DESCRIPTION πŸ’œ

okay so here's the tea: Xkb lets applications get info about indicators using two different methods, and they are not the same vibe at all.

Method one is giving core X implementation energy β€” you use a mask to specify the indicators. very old school, very "we've been doing it this way forever." πŸ”₯

Method two is the interop-friendly one, and it uses indicator names instead. this is the one you pick when you actually care about applications talking to each other, iykyk 🌈

the correspondence between the indicator name and the bit position in masks is as follows: one of the parameters returned from XkbGetNamedIndicators is an index that is the bit position to use in any function call that requires a mask of indicator bits, as well as the indicator's index into the XkbIndicatorRec array of indicator maps. like, that index is your girl for basically everything mask-related πŸ‘‘


so what does XkbGetIndicatorState actually do? she queries the display for the state of the indicators on the device specified by device_spec. and for each indicator that is "turned on" on the device, the associated bit is set in state_return. every single one. very thorough, we love a detail-oriented queen πŸ’–

now the plot twist 😭 β€” if a compatible version of the Xkb extension is not available in the server, XkbGetIndicatorState returns a BadMatch error. rude, honestly. but otherwise? it sends the request to the X server, places the state of the indicators into state_return, and returns Success. slay πŸ’…

so like, the value reported by XkbGetIndicatorState is identical to the value reported by the core protocol. fr fr. no cap. same value, different font πŸŽ€


πŸ’€ DIAGNOSTICS πŸ’€

  • BadMatch β€” a compatible version of Xkb was not available in the server, or an argument has correct type and range, but is otherwise invalid. two very different crimes, same error card πŸ™ˆ

⭐ SEE ALSO ⭐

  • XkbGetNamedIndicators(3) β€” go read her too, she's the one handing out those indices πŸ‘‘

and that's the whole page bestie, you ate that πŸ’…βœ¨

this has been brought to you by X Version 11 and libX11 1.8.14 β€” go off, kings πŸ‘‘πŸ«Ά

πŸ“¦ where this page comes from