XtSetArg(3)

πŸ’– XtSetArg(3) β€” XT FUNCTIONS πŸ’–

okay bestie, we're in XT FUNCTIONS territory and today's icons are XtSetArg and XtMergeArgLists. yes they're both in this one page, no they are not the same function, keep up πŸ’…


✨ NAME ✨

XtSetArg, XtMergeArgLists β€” set and merge ArgLists πŸŽ€


🌸 SYNTAX 🌸

#include <X11/Intrinsic.h>

int XtSetArg(Arg arg, String name, XtArgVal value);

ArgList XtMergeArgLists(ArgList args1, Cardinal num_args1, ArgList
       args2, Cardinal num_args2);

πŸ¦‹ ARGUMENTS πŸ¦‹

  • arg β€” this is the name-value pair you're setting, babe.
  • args1 β€” the first ArgList. the OG one.
  • args2 β€” the second ArgList. the one coming in second place.
  • num_args1 β€” how many arguments are in that first argument list. count them. fr fr.
  • num_args2 β€” how many arguments are in the second argument list.
  • name β€” the name of the resource. iconic behaviour.
  • value β€” the value of the resource if it'll fit in an XtArgVal, or else the address. it's giving "depends on the size" πŸ™ˆ

πŸ‘‘ DESCRIPTION πŸ‘‘

So XtSetArg is usually used in a highly stylized manner to minimize the probability of you making a mistake. which, honestly, relatable β€” the whole point is to not mess up. example time:

Arg args[20];
int n;

n = 0;
XtSetArg(args[n], XtNheight, 100);      n++;
XtSetArg(args[n], XtNwidth, 200);       n++;
XtSetValues(widget, args, n);

alternatively, you can just statically declare the argument list and use XtNumber instead. lowkey cleaner:

static Args args[] = {
        {XtNheight, (XtArgVal) 100},
        {XtNwidth, (XtArgVal) 200},
};
XtSetValues(Widget, args, XtNumber(args));
⚠️ okay IMPORTANT bestie β€” do not use auto-increment or auto-decrement inside the first argument to XtSetArg. because XtSetArg can be implemented as a macro that dereferences the first argument twice. twice!! and that will absolutely wreck your day. no cap.

Now, XtMergeArgLists β€” she allocates enough storage to hold the combined ArgList structures and copies them into it. so she's doing the work for you, queen πŸ‘‘

πŸ’€ but heads up: it does not check for duplicate entries. so if you got dupes, that's on you, not her.

And when you're done with it, when it is no longer needed, free the returned storage by using XtFree. periodt. don't be leaving memory lying around, that's not the vibe.


🌈 SEE ALSO 🌈

  • XtOffset(3)
  • X Toolkit Intrinsics - C Language Interface
  • Xlib - C Language Interface

okay that's the whole page, you ate it, you understood it, you're literally a widget-resource-setting main character now 🫢✨

this was X Version 11, libXt 1.3.1 β€” mwah, take care of her, she's an icon πŸŽ€πŸ’œ

πŸ“¦ where this page comes from