XtGetSelectionValue(3)

πŸ’– NAME πŸ’–

XtGetSelectionValue, XtGetSelectionValues β€” bestie, we're getting selection values. that's the whole job. obtaining them. slay.


✨ SYNTAX ✨

first, the include, don't forget it or nothing works:

#include <X11/Intrinsic.h>

void XtGetSelectionValue(Widget w, Atom selection, Atom target,
       XtSelectionCallbackProc callback, XtPointer client_data, Time
       time);

void XtGetSelectionValues(Widget w, Atom selection, Atom *targets, int
       count, XtSelectionCallbackProc callback, XtPointer *client_data,
       Time time);

two functions, one vibe. the singular one asks for one thing, the plural one asks for a whole list of things at once. πŸ‘‘


πŸŽ€ ARGUMENTS πŸŽ€

okay so here's every single one, in order, no skipping, i promise:

  • callback β€” the callback procedure that gets called when the selection value has been obtained. it's giving "we'll ring you when your order's ready" energy.
  • client_data β€” the argument that is passed to the specified procedure when it is called. (this is the singular XtGetSelectionValue version, one blob of data, one callback.)
  • client_data β€” the client data, one for each target type, passed to the callback procedure when it's called for that target. (this is the XtGetSelectionValues version β€” yes it has the same name, no that's not a typo, it's a list now. the way that…)
  • count β€” the length of the targets and client_data lists. so you better keep them matching, fr fr.
  • selection β€” the particular selection you want, like primary or secondary. which one, bestie, pick.
  • target β€” the type of information that is needed about the selection. singular. one target.
  • targets β€” the types of information that are needed about the selection. plural. a whole array of them. main character energy.
  • time β€” the timestamp that indicates when the selection value is desired.
  • w β€” the widget that is making the request. the one doing the asking. 🫢

πŸ¦‹ DESCRIPTION πŸ¦‹

XtGetSelectionValue requests the value of the selection that has been converted to the target type. and here's the lowkey unhinged part: the callback you specified gets called some time after XtGetSelectionValue is called β€” and honestly it may be called before XtGetSelectionValue returns, or after it returns. either way. no cap. so don't go assuming anything about ordering, that's just how it is. πŸ’€

XtGetSelectionValues is literally the same situation as XtGetSelectionValue, except it takes a list of target types and a list of client data, and grabs the current value of the selection converted to each of the targets. the effect is as if each target were specified in its own separate call to XtGetSelectionValue. the callback gets called once with the corresponding client data for each target. and here's the glow-up: XtGetSelectionValues does guarantee that all the conversions will use the same selection value, because ownership of the selection can't change in the middle of the list β€” which is exactly the mess you'd get if you just called XtGetSelectionValue over and over again. periodt. ✨


🌸 SEE ALSO 🌸


heads up bestie, that callback timing thing is real: it can fire before XtGetSelectionValue even returns. write your callback like it's the main character and don't depend on the order. πŸ’…

okay that's the whole page, ily, go get those selection values. this was X Version 11, libXt 1.3.1, and it's giving XtGetSelectionValue(3) πŸ¦‹βœ¨πŸ’–

πŸ“¦ where this page comes from