Re: XForms: refresh problem

From: Steve Lamont (
Date: Thu Jul 27 2000 - 09:47:07 EDT

  • Next message: Dario Abatianni: "XForms: Preventing new windows from getting focus"

    # To subscribers of the xforms list from Steve Lamont <> :

    > I have an aplication in which I capture a image from a camera, and i
    > put the image in a canvas object. I use an iddle callback to refresh
    > the image.
    > I have some fors to calculate some positions to move the camera,
    > then while the camera is moving, the image doesn't refresh, I think
    > because into the fors there isn't time to execute iddle callback.
    > is it True?

    The idle callback mechanism is not completely asynchronous -- it
    doesn't run in a separate thread or anything like that -- but is under
    control of the XForms "main loop" (executed when you call

    If you don't return control to XForms, the idle callback will not be
    called. You may also note that other parts of the form seem to
    "freeze up" while the camera is moving.

    > How can i "put time" to execute the iddle callback?

    You can call the function fl_check_forms() anywhere in your loop to
    momentarily hand control back to XForms. fl_check_forms() is
    basically the "guts" of the XForms main loop and does everything that
    the main loop does except that it doesn't loop -- it returns control
    to the calling function.

    If there is nothing for XForms to do, that is, no user interaction to
    process or no pending idle callback or timeout, then control is
    immediately handed back to your function.

    One caveat: I don't recommend calling fl_check_forms() in an inner
    loop that is executed thousands of times per second, since that will
    slow your program down badly and eat a lot of CPU time for nothing.
    For example, don't do this:

            for ( i = 0; i < some_outer_loop_limit; i++ ) {

                for ( j = 0; j < some_inner_loop_limit; j++ ) {

                    fl_check_forms(); /* A bad idea to put it here */



    do this:
            for ( i = 0; i < some_outer_loop_limit; i++ ) {

                for ( j = 0; j < some_inner_loop_limit; j++ ) {



                fl_check_forms(); /* A better idea to put it here */


    Assuming that the inner loop takes only a few milliseconds to execute,
    you will return control to XForms frequently enough to maintain
    interaction and call the idle callback.

    > How can i refresh the image without iddle callback?

    You can, of course, simply call the functions directly to update your
    Canvas display whenever you have new image data, rather than use the
    idle callback mechanism.

    To unsubscribe, send the message "unsubscribe" to or see
    XForms Home Page:
    List Archive:

    This archive was generated by hypermail 2b29 : Thu Jul 27 2000 - 05:55:07 EDT