Tk_InternAtom(3tk)

πŸ“¦
version 9.0.4 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’… NAME πŸ’…

Tk_InternAtom, Tk_GetAtomName β€” bestie, these two are literally the cache managers for X atoms ✨


πŸŽ€ SYNOPSIS πŸŽ€

#include <tk.h>

Atom
Tk_InternAtom(tkwin, name)

const char *
Tk_GetAtomName(tkwin, atom)

🌸 ARGUMENTS 🌸

  • Tk_Window tkwin (in) β€” your window token, bestie. It's what maps the atom or the name relative to one specific display, so like, everything is scoped to that display, okay? πŸ’–
  • const char *name (in) β€” the string name that you want the atom for. Slay.
  • Atom atom (in) β€” the atom you've got, and you want the matching string name back for it. Periodt.

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so these procedures are giving major XInternAtom and XGetAtomName energy β€” they're similar to those Xlib ones, fr fr. But listen:

Tk_InternAtom hands you back the atom identifier that goes with the string you passed in as name. 🌟 And here's the catch β€” that atom identifier is only valid for the display associated with tkwin. Not other displays. Just that one. Iykyk.

Tk_GetAtomName is the reverse vibe: it gives you the string that goes with atom on tkwin's display. And the string it returns? It lives in Tk's storage. So:

  • the caller does not need to free that space when they're done with the string 🫢
  • and the caller should not modify the contents of the returned string πŸ™ˆ (hands off, bestie)
If there's no atom atom on tkwin's display, Tk_GetAtomName returns the string "?bad atom?". Iconic little error string, honestly.

Now the actual main character moment: Tk caches everything that Tk_InternAtom and Tk_GetAtomName give back, so future calls asking for the same info get served straight from the cache without ever contacting the server. πŸ’€ No server round-trip, no waiting.

So like β€” Tk_InternAtom and Tk_GetAtomName are generally much faster than their Xlib counterparts, and you should use them in place of the Xlib procedures. That's not a suggestion, that's the move. πŸ’…


⭐ KEYWORDS ⭐

atom, cache, display


okay that's the whole page bestie, mwah πŸŽ€ β€” this was Tk's Tk_InternAtom(3tk), from the Tk library procedures, and yeah, that date/version energy at the bottom is all Tk, no cap. bye bestie, go intern some atoms πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from