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



Quoting Owen Taylor (otaylor@redhat.com):

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

The problem is not XPending() itself. It's the way gtk works: If you
do something, it's usually not done instantly (ie. when the function
returns) but a signal is emitted. Signals are processed in an idle
proc. Now what happens is this: When all events are processed, there
are some idle procs but no events pending. So the loop above exits
and the idle proc is not executed -> the GUI is dead. When you move
the mouse, an event happens and this can *sometimes* wake the
idle proc !

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

You must make sure that all events are processed - In this case, the idle
proc won't be called (same for timeout functions) because that happens
only in gtk_main_iteration() which isn't called because no events are
pending...

I have the same problem here with my threads. Owen, can you *please* have a
look at this ASAP. It *really* sux :-)

--
Dipl. Inf. (FH) Aaron "Optimizer" Digulla     Assistent im BIKS Labor, FB WI
"(to) optimize: Make a program faster by      FH Konstanz, Brauneggerstr. 55
improving the algorithms rather than by       Tel:+49-7531-206-514
buying a faster machine."                     EMail: digulla@fh-konstanz.de



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