Hello,
In FLTK 1.1.X, I'm observing unexpected delay in displaying window contents, if
I there is a CPU consuming operation before displaying the window. I'm
attaching an example code that shows this problem. To compile it save it as
test.cpp and just type:
g++ test.cpp -o test `fltk-config --ldflags`
Note that the tm_function executes a busy for loop followed by creating and
displaying a window. The problem is that the Fl_Button in the window is shown
about 1 or 2 seconds later than the window itself is shown.
I would expect both the window and the button in it to be shown at the same
time.
Any help in shedding light to this problem is appreciated.
Oguz
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <Fl/Fl_Button.H>
#include <cmath>
#include <cstdio>
#include <pthread.h>
void* tm_function(void* data)
{
for(int i = 0; i < 10000000; ++i)
{
double x = pow(i / 10000000., 2.2);
}
Fl_Double_Window* testWnd = new Fl_Double_Window(400, 400, "Test Window");
Fl_Button* btn = new Fl_Button(100, 100, 60, 25, "Button");
testWnd->end();
testWnd->redraw();
testWnd->show();
Fl::check();
}
void btn_callback(Fl_Widget* o, void* data)
{
Fl_Double_Window* mainWindow = (Fl_Double_Window*) o->parent();
mainWindow->hide();
//Fl::add_timeout(0.1, tm_function, NULL);
pthread_t tid;
pthread_create(&tid, NULL, tm_function, NULL);
}
int main(int argc, char *argv[])
{
Fl::scheme("plastic");
Fl_Double_Window* wnd2 = new Fl_Double_Window(800, 600, "Big Window");
wnd2->end();
wnd2->show();
Fl_Double_Window* wnd = new Fl_Double_Window(500, 500, "My Window");
Fl_Button* btn = new Fl_Button(100, 100, 100, 25, "Press Me!");
wnd->end();
wnd->show();
btn->callback(btn_callback, NULL);
Fl::run();
return 0;
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk