XtSetKeyTranslator(3)

πŸ’– XtSetKeyTranslator β€” the XT FUNCTIONS girlies πŸ’–

okay bestie, so this is the XtSetKeyTranslator(3) page from the XT FUNCTIONS manual, and it's literally all about turning KeySym into KeyCodes πŸ¦‹βœ¨. Sit down, grab a strawberry drink πŸ“, and let's get into it.


✨ NAME ✨

XtSetKeyTranslator, XtTranslateKeycode, XtRegisterCaseConverter, XtConvertCase β€” convert KeySym to KeyCodes πŸ’…


🌸 SYNTAX 🌸

#include <X11/Intrinsic.h>

void XtSetKeyTranslator(Display *display, XtKeyProc proc);

void XtTranslateKeycode(Display *display, KeyCode keycode, Modifiers
       modifiers, Modifiers *modifiers_return, KeySym *keysym_return);

void XtRegisterCaseConverter(Display *display, XtCaseProc proc, KeySym
       start, KeySym stop);

void XtConvertCase(Display *display, KeySym keysym, KeySym
       *lower_return, KeySym *upper_return);

πŸŽ€ ARGUMENTS πŸŽ€

  • display β€” the display, obviously. the whole vibe check happens here πŸ‘‘
  • keycode β€” the KeyCode you wanna translate, no cap.
  • keysym β€” the KeySym you're converting, periodt.
  • keysym_return β€” this one hands you back the resulting KeySym 🫢
  • lower_return β€” gives you back the lowercase equivalent of the KeySym πŸ’œ
  • upper_return β€” gives you back the UPPERCASE equivalent, loud and proud πŸ”₯
  • modifiers β€” the modifiers attached to that KeyCode.
  • modifiers_return β€” returns a mask showing which modifiers were actually used to generate the KeySym. receipts!! 🧾
  • proc β€” the procedure that's gonna do the key translating or the converting, your choice bestie.
  • start β€” the first KeySym this converter is valid for.
  • stop β€” the last KeySym this converter is valid for. yes queen, it's a range πŸŽ€

🌈 DESCRIPTION 🌈

So XtSetKeyTranslator does the thing where it sets the procedure you gave it as the current key translator. That's it, that's the function. πŸ’…

The default translator is XtTranslateKey, which is an XtKeyProc that uses Shift and Lock modifiers, with the interpretations defined by the core protocol. It's literally provided so that brand-new translators can call it to get the default KeyCode-to-KeySym translations, and also so the default translator can be reinstalled if you ever need to bring her back. main character energy fr fr πŸ‘‘

XtTranslateKeycode is the chill one β€” it just passes the arguments you gave it directly to whatever KeyCode-to-KeySym translator is currently registered. no middleman, no drama πŸ¦‹

XtRegisterCaseConverter registers the case converter you specified. The start and stop arguments give the inclusive range of KeySyms that this converter gets called for. Heads up though β€” the new converter overrides any previous converters for KeySyms in that range. 😭

and here's the tea bestie: no interface exists to remove converters. like, none. zero. you literally have to register an identity converter if you want one gone. that's the only way. πŸ’€

When a new converter gets registered, the Intrinsics refreshes the keyboard state if necessary. The default converter understands case conversion for all the KeySyms defined in the core protocol. slay ✨

And XtConvertCase calls the appropriate converter and returns the results. lowkey important: a user-supplied XtKeyProc may need to use this function, so don't forget about her 🫢


πŸ’œ SEE ALSO πŸ’œ

  • X Toolkit Intrinsics - C Language Interface
  • Xlib - C Language Interface

and that's the whole page, bestie!! πŸŽ€ this was X Version 11, libXt 1.3.1, and it's XtSetKeyTranslator(3) forever and always. go convert some keysyms, ily, bye πŸ’–βœ¨πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from