when do application do not have a display ?

Xt is also a powerful general purpose environment for event-driven programming. Input events, timers, now signals ... all handled pretty well. Originally the big drawback was that XtAppMainLoop would *never* return, but this ExitFlag stuff appears to be an attempt to allow it. I also think it should return when there's no chance of ever getting another event: if there's no display, no input sources are defined, no signals are being watched, and no timers are set. Someday I'll see if I can come up with a patch for that, but in the mean time changing the main loop would be a good thing.

Here's some code that shows the problem:

#include <X11/Intrinsic.h>

static void _Tick(XtPointer baton, XtIntervalId* id) {
   static int count = 0;

   printf("%d beep!\n", ++count);

   XtAppContext app = (XtAppContext)baton;
   if (3 == count)
       XtAppSetExitFlag(app);
   else
       XtAppAddTimeOut(app, 3000, _Tick, app);
}

int main(int argc, char** argv) {
   XtToolkitInitialize();
   XtAppContext app = XtCreateApplicationContext();
   XtAppAddTimeOut(app, 3000, _Tick, app);

#ifdef    SHOWBUG
   XtAppMainLoop(app);
#else
   for (;;) {
       XtAppProcessEvent(app, XtIMAll);
       if (XtAppGetExitFlag(app))
           break;
   }
#endif

   return 0;
}

I wrote this paper nearly 20 years ago about it :-)

http://bitway.com/jordan/papers/USENIX/AppDev.html

/jordan
_______________________________________________
[email protected]: X.Org support
Archives: http://lists.freedesktop.org/archives/xorg
Info: http://lists.freedesktop.org/mailman/listinfo/xorg
Your subscription address: [email protected]

Reply via email to