Re: delays in event dispatching ???



Diego Zuccato <cssl@geocities.com> writes:

> Hello all.
> 
> In a program I'm developing, it seems that events take some time to be
> dispatched. So, if in a dialog window I :
> 0) show dialog
> 1) update text and percentage in a progress bar
> 2) process event queue
> 3) loop 1)
> I see updates starting from the second (and it seems the window is
> completly redrawn, infact sometimes other content get "blanked out").
> BUT, if :
> 2a) sleep(1);
> 2b) process event queue
> I see the first update, too.
> 
> To "process event queue" I tries all I could think:
> * while(gtk_events_pending()) gtk_main_iteration();
> * while(gtk_events_pending()) gtk_main_iteration_do(TRUE);
> * while(gtk_events_pending()) gtk_main_iteration_do(FALSE);
> * gtk_main_iteration_do(TRUE);
> * gtk_main_iteration_do(FALSE);
> (possibly some others I don't remember).
> 
> Am I missing something (probably, since I'm quite new to GTK
> programming) ?

The problem is you are using gtk_widget_show() to show the dialog -
this asks the window manager to show the dialog but doesn't 
wait for it to do so, so when you process the event queue, the
window may not yet be there to draw on.

Instead you should call gtk_widget_show_now() which asks the
window manager to show the dialog and waits for it to become
visible.

If you do this, things will probably work OK, but there is still
a theoretical problem that could occur - your application could
receive notification of the window becoming visible, but still
not get the actual expose events that will ask it to draw
on the window.

So, to be absolutely safe, you probably should call
gtk_widget_draw(dialog) after processing the event queue the first
time.

Regards,
                                        Owen 




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]