ginput: blocking call for mouse input

How about giving flush_events() an until=condition and timeout=n keywords
so that flush_events becomes:

        if timeout > 0: set timer event which triggers out_of_time
  while get next event:
           process event
           if out_of_time or until(): break

Looking through wx I don't see how to "get next event", my choices being
run all events (MainLoop) or run pending events. I do see an "exit main
loop" function, so for wx at least one could redirect the event handler
for the window and run all the events, exiting the main loop when done,
but that seems ugly. I'll look around some more and see if I can find
the sleep until next event function in wx.

   - Paul

···

On Wed, Feb 06, 2008 at 12:38:32AM +0100, Gael Varoquaux wrote:

On Tue, Feb 05, 2008 at 06:30:53PM -0500, Paul Kienzle wrote:
> Setting the timeout to 0.01s for the busy loop in ginput seems excessive.
> Since it is waiting for human interaction, generally 0.1 seconds is good
> enough.

I had gone for that originally, but it looked quite ugly when moving the
window around. This busy waiting is quite ugly, but I have found a way of
avoid it. IMHO it should be done in the toolkit's event loop, but it
seems that trying to do it this would add gobbles of code for little
gain.

How about giving flush_events() an until=condition and timeout=n keywords
so that flush_events becomes:

        if timeout > 0: set timer event which triggers out_of_time
  while get next event:
           process event
           if out_of_time or until(): break

I'd say this is exactly the way to do it. The problem is that under GTK
is seems fairly easy to do, under Tk it seems feasible, but under Qt and
under Wx I have no clue how to do this. We can always fallback to
busy-waiting for these toolkits.

This indeed seems to be the way to go. Maybe I would empty the event
stack when the "until()" condition is met, before returning to the
caller, and thus blocking again.

I'll look around some more and see if I can find the sleep until next
event function in wx.

Yeah, sleep, I need more of that. Or maybe you can find wx.coffee ?

Cheers,

Ga�l

···

On Tue, Feb 05, 2008 at 07:16:59PM -0500, Paul Kienzle wrote: