diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2015-01-31 17:40:48 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2015-02-04 15:44:09 +0100 |
commit | 06d731428ef6cf93c7333e8228bfb6088853b52f (patch) | |
tree | dbdcbed014fdbc7f1369e888a5903e493b3aabcb /vcl/unx/generic | |
parent | e6a58b5e69b83e01b5291b1d8629927e05447797 (diff) |
make idle timers actually activate only when idle
Without this, they can activate after any call to the event processing,
so they may activate in cases such as when updating progressbar while
loading a document, or on repeated user input (so things like showing
spellchecking get updated when the app is busy redrawing). This change
makes idle timers activate only when there's nothing more for the event
loop to process. It's a bit of a question if this doesn't break something
that happens to expect idle timers to be not-really-idle timers, but oh well.
No change for non-X11 platforms, as there's I don't know how to check
the event queues.
Change-Id: I074a88f2f5eeb4b456a11916a0ec2ad6f54dfbab
Diffstat (limited to 'vcl/unx/generic')
-rw-r--r-- | vcl/unx/generic/app/saldata.cxx | 23 | ||||
-rw-r--r-- | vcl/unx/generic/app/saltimer.cxx | 4 |
2 files changed, 24 insertions, 3 deletions
diff --git a/vcl/unx/generic/app/saldata.cxx b/vcl/unx/generic/app/saldata.cxx index 317c16e16452..2a90eb7dc49d 100644 --- a/vcl/unx/generic/app/saldata.cxx +++ b/vcl/unx/generic/app/saldata.cxx @@ -336,6 +336,7 @@ void X11SalData::PopXErrorLevel() } SalXLib::SalXLib() + : blockIdleTimeout( false ) { m_aTimeout.tv_sec = 0; m_aTimeout.tv_usec = 0; @@ -646,8 +647,20 @@ bool SalXLib::CheckTimeout( bool bExecuteTimers ) * timers are being dispatched. */ m_aTimeout += m_nTimeoutMS; + // Determine if the app is idle (for idle timers). If there's user input pending, + // if there's IO pending or if we're called inside a temporary yield (=blockIdleTimeout), + // then the app is not idle. + bool idle = true; + if( blockIdleTimeout || XPending( vcl_sal::getSalDisplay(GetGenericData())->GetDisplay())) + idle = false; + for ( int nFD = 0; idle && nFD < nFDs_; nFD++ ) + { + YieldEntry* pEntry = &(yieldTable[nFD]); + if ( pEntry->fd && pEntry->HasPendingEvent()) + idle = false; + } // notify - GetX11SalData()->Timeout(); + GetX11SalData()->Timeout( idle ); } } } @@ -656,6 +669,7 @@ bool SalXLib::CheckTimeout( bool bExecuteTimers ) void SalXLib::Yield( bool bWait, bool bHandleAllCurrentEvents ) { + blockIdleTimeout = !bWait; // check for timeouts here if you want to make screenshots static char* p_prioritize_timer = getenv ("SAL_HIGHPRIORITY_REPAINT"); if (p_prioritize_timer != NULL) @@ -674,7 +688,10 @@ void SalXLib::Yield( bool bWait, bool bHandleAllCurrentEvents ) { pEntry->HandleNextEvent(); if( ! bHandleAllCurrentEvents ) + { + blockIdleTimeout = false; return; + } } } } @@ -746,7 +763,10 @@ void SalXLib::Yield( bool bWait, bool bHandleAllCurrentEvents ) // someone-else has done the job for us if (nFound == 0) + { + blockIdleTimeout = false; return; + } for ( int nFD = 0; nFD < nFDs_; nFD++ ) { @@ -772,6 +792,7 @@ void SalXLib::Yield( bool bWait, bool bHandleAllCurrentEvents ) } } } + blockIdleTimeout = false; } void SalXLib::Wakeup() diff --git a/vcl/unx/generic/app/saltimer.cxx b/vcl/unx/generic/app/saltimer.cxx index 19b44955cfe0..fc55afb85c48 100644 --- a/vcl/unx/generic/app/saltimer.cxx +++ b/vcl/unx/generic/app/saltimer.cxx @@ -29,11 +29,11 @@ #include <unx/saltimer.h> #include <unx/salinst.h> -void X11SalData::Timeout() const +void X11SalData::Timeout( bool idle ) const { ImplSVData* pSVData = ImplGetSVData(); if( pSVData->mpSalTimer ) - pSVData->mpSalTimer->CallCallback(); + pSVData->mpSalTimer->CallCallback( idle ); } void SalXLib::StopTimer() |