[fpc-pascal] fpSelect() with very small timeout?

Martin Schreiber fpmse at bluewin.ch
Mon Oct 20 10:59:50 CEST 2008


On Monday 20 October 2008 10.36:48 Graeme Geldenhuys wrote:
> On Mon, Oct 20, 2008 at 10:19 AM, Martin Schreiber <fpmse at bluewin.ch> wrote:
> > [...]
> > You could send a wakeup message to the X event queue if a widget has been
> > invalidated instead of polling. See MSEgui lib/common/msegui.pas
> > tguiapplication.invalidated and the postevent infrastructure for an
> > example.
>
> Thanks Martin.  I take it, your method would be a bit more efficient
> than polling? Or wouldn't it make much difference because the event
> loop keeps looping anyway?
>
The MSEgui main event loop waits on a poll() call for X messages. There is a 
emergency timeout of one second because the new xcb library seems to have a 
problem by sometimes not to deliver client messages in time.

> For example: Using the wakeup event, it will simply break out of the
> message handling a bit quicker. "if XPending(display) > 0" would have
> a "else" part where it fires the OnIdle event and then breaks out.
> Skipping (or making redundant) the "if needToWait ..." block of code.
>

No, the purpose of the wakeup message is to terminate the poll() call. 
Updating the widgets and call of OnIdle will be done before poll() is called 
again.

Martin



More information about the fpc-pascal mailing list