Question: non-blocking check for pending events...




Is it possible to do something like what I gather this is supposed to
do?  That is, make a _non-blocking_ check to see if there are any
events that need to be processed.  If there are no events to be
processed return 0 immediately, and if there are call
gtk_main_iteration to process them.

while(gtk_events_pending())
	gtk_main_iteration();

This will wait in XPending (called by gdk_events_pending(), called by
gtk_events_pending) if there are no incoming events.  So if the user
gets bored and starts waggling the mouse at the program, it will work,
but otherwise it just sits there.

Multithreading is obviously one answer, and I guess rewriting the
program to use timeouts or idle functions is another.  I've tried
various permutations of gtk_main_iteration do(FALSE), but that just
doesn't seem to ever do anything, although it doesn't block.
XEventsQueued(...) either blocks or never returns positive, even when
there should be events in the queue.

I've seen the above code fragment in the FAQ and other postings, and I
guess I just didn't understand exactly what it did.  So I am looking
to see if there is a way to do what I thought it did. *:-} (dazed
smiley struck by rock)

If you want to see an example of this, download gtkfind from
http://www.oz.net/~mattg/download.html, and look in gtkfind.c, line
197.  Just start up a find in a large directory and don't touch the
mouse.  This is with Gtk+ 1.0.6 (and all other versions).

Matt Grossman
mattg@oz.net
http://www.oz.net/~mattg




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