Path: utzoo!attcan!uunet!husc6!bloom-beacon!WSL.DEC.COM!haynes From: haynes@WSL.DEC.COM Newsgroups: comp.windows.x Subject: Re: X Toolkit and continuous graphic output Message-ID: <8807251653.AA22284@gilroy.pa.dec.com> Date: 25 Jul 88 16:53:32 GMT Sender: daemon@bloom-beacon.MIT.EDU Organization: The Internet Lines: 41 Suppose I have a program that continuously computes and generates graphic output; how can I wrap the toolkit around this program? It seems to me that once I call XtMainLoop() I've given up control and there's no way for me to get to the main routine of my program that generates the output. As usual with the toolkit there are at least four equally valid ways of solving your problem, depending on your exact requirements. They are: Work Procs Timer Events Custom XtMainLoop "Pull" instead of "Push" The Work Proc solution would be to divide your program into small pieces, each of which would be expected to finish in a small amount of time (say 100 millisecs) and register each piece as a work proc. If your graphics program can be decomposed into a 100 millisec task that is run over and over, this would be your best solution. Timer Events are a way of getting the toolkit to "wake up" every so often and call some procedure of yours. This solution is almost always inferior to work procs, but if you already have some work procs and want to guarantee that your program runs every n milliseconds, this is the route to take. A Custom XtMainLoop is another possibility. Write your own XtMainLoop with your graphics processing interspersed between the calls to XtNextEvent and XtDispatchEvent. Further, you can avoid blocking by use of XtPending. The last alternative "pull" instead of "push" is actually an elaboration of the custom XtMainLoop. Take your existing graphics program and sprinkle "XtNextEvent" followed by "XtDispatchEvent" in appropriate places. You can even look at the event delivered by XtNextEvent to decide exactly what it is you want to do. Good luck. -- Charles