Re: Label wont show right.

NGUYEN <> writes:

> > See the FAQ question 4.11 (whose name I'm gonna have to change).
> I still get unexpected behaviour even with
> 	 while(gtk_event_pending())
> 		gtk_main_iteration();
> in the function. The label showes up once or twice or whenever it feels like it..:). Am i doing something wrong? This isnt the X server queing on me , is it?.
> Doesnt gdk_flush() take care of that?. Here's the codes again. And thanks for your help.

The problem is that the while (gtk_events_pending())... code fragment
basically checks if there is something for GTK to do, _right now_.
But in the process of putting the window on screen, GTK momentarily
has to wait for X. At that point, the while() terminates, and your
code executes.

I thought the following:

	while (1)
	    if (!gtk_events_pending())
		if (!gtk_events_pending())

Might be guaranteed way of doing it. (It says, "if there is nothing
for GTK to do, wait until X has processed all our events, then
see if there is _still_ nothing for us to do".) But that doesn't
seem to help. Apparently the expose events are not generated
until after gdk_flush() (which calls XSync()) returns.

So, my best advice is that you should call the 
while (gtk_events_pending()) stuff not just once at the beginning
of your processing, but occasionally during the execution of
your long-processing code. (If possible). This will have the
nice side effect that your window will get redrawn if it 
is obscured during the processing.

The other thing to do is:


	gdk_flush ();
        gtk_widget_draw (label);

Which draws the label immediately instead of waiting for it
to get exposed by Expose events.


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