Tk_OwnSelection(3tk)

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

πŸ’– Tk_OwnSelection β€” bestie, you're the owner now πŸ’…

okay so this is Tk_OwnSelection(3tk) from the Tk Library Procedures, and it's literally about handing your window the aux cord for the primary selection. let's get into it πŸŽ€


✨ NAME ✨

Tk_OwnSelection β€” make a window the owner of the primary selection πŸ‘‘


🌸 SYNOPSIS 🌸

#include <tk.h>

Tk_OwnSelection(tkwin, selection, proc, clientData)

πŸ¦‹ ARGUMENTS πŸ¦‹

  • Tk_Window tkwin (in) β€” the window that's about to become the shiny new selection owner. main character behavior, honestly.
  • Atom selection (in) β€” the name of the selection you're claiming, like XA_PRIMARY for example.
  • Tk_LostSelProc *proc (in) β€” the procedure that gets invoked later when tkwin loses selection ownership. think of it as the "you're not the owner anymore" callback 😭
  • void *clientData (in) β€” an arbitrary one-word value that gets passed along to proc. no questions asked, just vibes.

πŸ’œ DESCRIPTION πŸ’œ

So Tk_OwnSelection arranges for tkwin to become the new owner of the selection specified by the atom selection. Once this call finishes, future requests for that selection get directed to the handlers created for tkwin using Tk_CreateSelHandler. periodt.

And then, when tkwin eventually loses the selection ownership β€” yeah, it happens to everyone β€” proc will be invoked so the window can clean itself up (like, e.g. by unhighlighting the selection). so thoughtful of it 🫢

proc should have arguments and a result that match the type Tk_LostSelProc:

typedef void Tk_LostSelProc(
        void *clientData);

The clientData parameter to proc is a copy of the clientData argument that was given to Tk_OwnSelection, and it's usually a pointer to a data structure containing application-specific information about tkwin. iykyk πŸ’«


πŸ”₯ KEYWORDS πŸ”₯

own, selection owner


ngl bestie, if you skip the proc you're gonna be that window that never cleans up after itself, and nobody wants that energy πŸ’€

slay, go own that selection βœ¨πŸŒˆπŸ’–

β€” with love, from the Tk Library Procedures, version 4.0, dated Tk_OwnSelection(3tk), which is giving vintage but still iconic πŸŽ€πŸ’…

πŸ“¦ where this page comes from