XMREDISPLAYWIDGET(3)

πŸ“¦
version 2.5.2 Β· 2 versions
, in alpine 3.24, arch rolling, centos-stream 9, epel 10, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0

πŸ’– XmRedisplayWidget πŸ’–

okay bestie, so this one's a library call β€” it lives in the Xm family, and it's genuinely one of those little functions that makes you go "wait, that's it? that's the whole thing?" and then you use it forever. it redraws a widget's content, right now, synchronously. no vibes-based waiting around. πŸ’…


✨ SYNOPSIS ✨

#include <Xm/Xm.h>
voidXmRedisplayWidget(
Widgetwidget);

🌸 DESCRIPTION 🌸

so the tea is: this function is a convenience routine. it exists purely to hide all the crunchy Xt internals from you, the poor application programmer, so you don't have to hand-build an Expose event and a Region yourself. instead it just calls the expose method of the widget you give it, with a well-formed Expose event and a Region that corresponds to the total area of the widget. 🫢

and if the widget doesn't have an Expose method? it does nothing. literally nothing. no drama, no error, just vibes. πŸ’€

where you'll see this the most is in the context of X Printing, when the programming model your app picked is synchronous β€” meaning it is not relying on X Print events to drive page layout, and instead wants to be fully in control of the sequence of rendering requests. main character energy, honestly. πŸ‘‘

one thing to know: XmRedisplayWidget does not clear the widget window before it calls the expose method β€” because that's handled by calls to XpStartPage. so don't come for it about clearing. it's not its job. βœ‹

  • widget β€” the widget you want to redisplay. that's it. that's the whole arg. πŸŽ€

✨ RETURN VALUE ✨

None. β€” it gives you nothing back. it's a giver, not a taker. πŸ’–


🌈 ERRORS/WARNINGS 🌈

Not applicable. no errors, no warnings, no chaos. iconic behaviour, fr fr. ⭐


πŸ“ EXAMPLES πŸ“

okay so picture this: a simple application wants to print the content of a multi-page text widget (think something like dtpad). here's the synchronous way:

PrintOKCallback(print_dialog...)
/*-------------*/
{
    pshell = XmPrintSetup (print_dialog, pbs->print_screen,
                                   "Print", NULL, 0);

    XpStartJob(XtDisplay(pshell), XPSpool);

    /**** here I realize the shell, get its size, create my widget
     hierarchy: a bulletin board, and then a text widget,
     that I stuff with the video text widget buffer */

    /* get the total number of pages to print */
    XtVaGetValues(ptext, XmNrows, &prows,
                         XmNtotalLines, n_lines, NULL);
    n_pages = n_lines / prows;

    /***** now print the pages in a loop */

    for (cur_page=0; cur_page != n_pages; cur_page++) {

               XpStartPage(XtDisplay(pshell), XtWindow(pshell), False);
               XmRedisplayWidget(ptext);  /* do the drawing */
               XpEndPage(XtDisplay(pshell));

        XmTextScroll(ptext, prows);  /* get ready for next page */
    }

    /***** I'm done */
    XpEndJob(XtDisplay(pshell));

}

now β€” of course β€” you could change all that up and stick it in a fork() branch so your main program isn't blocked while the printing is happening. that's valid. ✨

but there's another way to get that "print-in-the-background" effect, and it's using an Xt workproc. same sample app, and it gives us this:

Boolean
PrintOnePageWP(XtPointer npages) /* workproc */
/*-------------*/
{
    static int cur_page = 0;
    cur_page++;

    XpStartPage(XtDisplay(pshell), XtWindow(pshell), False);
    XmRedisplayWidget(ptext);  /* do the drawing */
    XpEndPage(XtDisplay(pshell));

    XmTextScroll(ptext, prows);  /*  get ready for next page */

    if (cur_page == n_pages) { /***** I'm done */
        XpEndJob(XtDisplay(pshell));

        XtDestroyWidget(pshell);
        XtCloseDisplay(XtDisplay(pshell));
    }

    return (cur_page == n_pages);
}
PrintOKCallback(...)
/*-------------*/
{
    pshell = XmPrintSetup (widget, pbs->print_screen,
                                   "Print", NULL, 0);

    XpStartJob(XtDisplay(pshell), XPSpool);

    /**** here I get the size of the shell, create my widget
          hierarchy: a bulletin board, and then a text widget,
                  that I stuff with the video text widget buffer */

    /* get the total number of pages to print */
    /* ... same code as above example */

    /***** print the pages in the background */
    XtAppAddWorkProc(app_context, PrintOnePageWP, n_pages);
}

see how cute that is? pages just quietly printing in the background while your app keeps living its life. πŸ¦‹


πŸ‘‘ SEE ALSO ⭐


and that's the whole page, bestie πŸŽ€ this one comes from the XmRedisplayWidget(library call) manual page β€” same name up top, same name at the bottom, so you know exactly where it lives. go forth and redisplay. πŸ’œβœ¨