[9591] in The GTK GIMP ToolKit mailing list archive

home help back first fref pref prev next nref lref last post

[gtk-list] Re: Question: non-blocking check for pending events...

daemon@ATHENA.MIT.EDU (Owen Taylor)
Tue Oct 27 12:07:52 1998

To: mattg@oz.net
Cc: gtk-list@redhat.com
From: Owen Taylor <otaylor@redhat.com>
Date: 27 Oct 1998 12:06:58 -0500
In-Reply-To: Matt Grossman's message of "Tue, 27 Oct 1998 08:14:41 -0800 (PST)"
Resent-From: gtk-list@redhat.com
Reply-To: gtk-list@redhat.com


Matt Grossman <mattg@oz.net> writes:

> 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.

XPending does not block ... I'm confused
 
> 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.

the 'block' parameter to gtk_main_iteration_do () doesn't work as
advertised, but gtk_events_pending() does...

You could also write the program to fork() off a separate
process to do the find, communicate back via a pipe, and
use gdk_input_add().
 
> 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).

Works fine for me (1.1.3, but that part hasn't changed IIRC)... I'm
still confused.

Regards,
                                        Owen

-- 
To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null


home help back first fref pref prev next nref lref last post