Re: forcing immediate redraw on widget
- From: Gus Koppel <gtk spamkiller bytechase cx>
- To: gtk-app-devel-list gnome org
- Subject: Re: forcing immediate redraw on widget
- Date: Tue, 27 Apr 2004 17:58:02 +0200
Harring Figueiredo wrote:
/* Process and remove all previously pending events */
while (gtk_events_pending ())
gtk_main_iteration ();
/* Verify that 0 == 0 still */
printf ("gtk_events_pending (should be 0): %d\n",
gtk_events_pending ());
/* Invalidate widget, should generate new event */
gtk_widget_queue_draw (widget_to_redraw);
/* Check whether GTK+ knows about a new event pending */
printf ("gtk_events_pending (should NOT be 0): %d\n",
gtk_events_pending ());
If especially the second result is "0" then I would suspect an
erroneous or missing implementation of gtk_widget_queue_draw () in
GTK+ 1.2.
Err, I beg to differ. This is a very erroneous assumption -- The
events are assynchronous and they could happen just "in between"
the call from gtk_envents_pending and printf.. This is very likely
since printf actually causes a hardware interrupt.
Again, don't assume that the program data will be unchanged on a
assynchroneous environment (Even if it is running on a single CPU).
Yes, I know about that situation. This test isn't 100% precise but it
should suffice. I think that chances are not too bad that no GDK / GTK+
event occurs between leaving the first while-loop and the 2nd printf ()
call. The test should be executed a few mnumber of times, of course.
Besides, the 1st printf () call is really dispensable.
For this test it is not important that gtk_events_pending () returns 0
at the first printf () call. It's rather important that 1 is returned at
the 2nd printf () call. Just discard the 1st printf () call and the
result of gtk_events_pending () without a prior call to printf () will
be printed. No falsification by printf () will be possible then.
I didn't expect + know that printf () could cause a hardware interrupt
in which GTK+ could be interested, since it's neither related to GTK+ /
GDK nor even an X server itself. Which interrupt do you have in mind?
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]