On Oct 30, 2009, at 1:57 PM, Albrecht Schlosser wrote:
> Maybe you mean something like:
>
> Fl_Window main_win (...);
> // initialize program...
>
> bool quit = false;
> while (!quit) {
> main_win.show();
> Fl::run();
>
> // determine how long to wait ...
>
> if ( <end_of_program> )
> quit = true;
> else
> sleep(10); // e.g. replace by your own logic
> }
This wouldn't work for me because I need to keep calling Fl::run(). My
program takes commands from a pipe (in a second thread) which tells it
to show/hide and what to display. If I don't call Fl::run() then the
pipe thread won't be able to tell the main thread to show itself.
So, the logic is:
- Create main window
- Hide it
- Create pipe thread
- Pipe thread Fl::awake()'s the main thread
- perhaps show/hide the main window
- display what we're told to via the pipe
- repeat until told to quit
For now, my solution is the while(!quit) version of FL::run().
while (!quit) Fl::wait(1e20);
I'm using Fl::wait(1e20) because calling Fl::run() in this loop would
just result in a 100% cpu process when the main window was hidden.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk