XtAppAddInput(3)

πŸ’– XtAppAddInput β€” bestie edition πŸ’–

okay so this is a page from the XT FUNCTIONS corner of the manual, and it's literally about XtAppAddInput(3) β€” yes, the whole family. sit down, grab a strawberry πŸ“, we're registering input sources.


✨ NAME ✨

XtAppAddInput, XtRemoveInput β€” register and remove an input source πŸŽ€


🌸 SYNTAX 🌸

like, the actual shape of it:

#include <X11/Intrinsic.h>

XtInputId XtAppAddInput(XtAppContext app_context, int source, XtPointer
       condition, XtInputCallbackProc proc, XtPointer client_data);

void XtRemoveInput(XtInputId id);

πŸ¦‹ ARGUMENTS πŸ¦‹

here's the tea on every single one of them, no skips:

  • app_context β€” the application context that identifies the application. like, which app are we even talking about bestie πŸ’…
  • client_data β€” the argument that's gonna get passed to the procedure you specified, but only when input is actually available. it's the lil gift you hand over 🎁
  • condition β€” the mask that says read, write, or exception condition, or honestly some operating-system dependent condition. very "depends on the vibe of your OS" of it
  • id β€” the ID you got back from the matching XtAppAddInput call. yes, the one that call returned
  • proc β€” the procedure that gets called when input is available. your main character callback πŸ‘‘
  • source β€” the source file descriptor on a UNIX-based system, or some other operating-system dependent device specification. loosely interpreted, okurrr

πŸ’œ DESCRIPTION πŸ’œ

so XtAppAddInput registers a brand new source of events with the Intrinsics read routine. it's usually file input, but it can also be file output. and note β€” "file" should be loosely interpreted to mean any sink or source of data. any. sink. or. source. periodt.

XtAppAddInput also specifies the conditions under which the source can generate events. and when input is pending on this source, the callback procedure gets called. that's it, that's the whole loop πŸŒ€

the legal values for the condition argument are operating-system dependent. on a UNIX-based system, the condition is some union of XtInputReadMask, XtInputWriteMask, and XtInputExceptMask. that's the trio, that's the girl group 🌈

and XtRemoveInput? it causes the Intrinsics read routine to stop watching for input from the input source. she said "I'm done here" and left the group chat πŸ’€


⭐ SEE ALSO ⭐

go read these next, they're all connected, iykyk:


πŸ™ˆ BUGS πŸ™ˆ

okay so in ANSI C you have to cast the condition to an XtPointer. like, it's not optional, bestie, it will not compile. here's exactly how:

XtAppAddInput(app_context,
    source,
    (XtPointer) (XtInputReadMask | XtInputWriteMask),
    proc,
    client_data);
not me forgetting the cast and losing my entire mind 😭 don't be like me. cast it. (XtPointer). say it with me.

that's the whole page, bestie β€” go forth and register your input sources πŸ’–βœ¨πŸ¦‹

this little manual page comes to you from X Version 11, specifically libXt 1.3.1, and it's filed under XtAppAddInput(3) in the XT FUNCTIONS section. mwah, love u, bye πŸ«ΆπŸŽ€

πŸ“¦ where this page comes from