summaryrefslogtreecommitdiff
path: root/vcl/unx/gtk/app
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2015-01-31 17:40:48 +0100
committerLuboš Luňák <l.lunak@collabora.com>2015-02-04 15:44:09 +0100
commit06d731428ef6cf93c7333e8228bfb6088853b52f (patch)
treedbdcbed014fdbc7f1369e888a5903e493b3aabcb /vcl/unx/gtk/app
parente6a58b5e69b83e01b5291b1d8629927e05447797 (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/gtk/app')
-rw-r--r--vcl/unx/gtk/app/gtkdata.cxx14
1 files changed, 12 insertions, 2 deletions
diff --git a/vcl/unx/gtk/app/gtkdata.cxx b/vcl/unx/gtk/app/gtkdata.cxx
index 8e20f62c14ee..cdbfd0a1b7c7 100644
--- a/vcl/unx/gtk/app/gtkdata.cxx
+++ b/vcl/unx/gtk/app/gtkdata.cxx
@@ -502,6 +502,7 @@ GtkData::GtkData( SalInstance *pInstance )
#else
: SalGenericData( SAL_DATA_GTK, pInstance )
#endif
+ , blockIdleTimeout( false )
{
m_pUserEvent = NULL;
m_aDispatchMutex = osl_createMutex();
@@ -551,6 +552,7 @@ void GtkData::Dispose()
void GtkData::Yield( bool bWait, bool bHandleAllCurrentEvents )
{
+ blockIdleTimeout = !bWait;
/* #i33212# only enter g_main_context_iteration in one thread at any one
* time, else one of them potentially will never end as long as there is
* another thread in there. Having only one yieldin thread actually dispatch
@@ -564,7 +566,10 @@ void GtkData::Yield( bool bWait, bool bHandleAllCurrentEvents )
if( osl_tryToAcquireMutex( m_aDispatchMutex ) )
bDispatchThread = true;
else if( ! bWait )
+ {
+ blockIdleTimeout = false;
return; // someone else is waiting already, return
+ }
if( bDispatchThread )
{
@@ -596,6 +601,7 @@ void GtkData::Yield( bool bWait, bool bHandleAllCurrentEvents )
if( bWasEvent )
osl_setCondition( m_aDispatchCondition ); // trigger non dispatch thread yields
}
+ blockIdleTimeout = false;
}
void GtkData::Init()
@@ -822,7 +828,7 @@ extern "C" {
if( !pTSource->pInstance )
return FALSE;
- SalData *pSalData = GetSalData();
+ GtkData *pSalData = static_cast< GtkData* >( GetSalData());
osl::Guard< comphelper::SolarMutex > aGuard( pSalData->m_pInstance->GetYieldMutex() );
@@ -830,7 +836,11 @@ extern "C" {
ImplSVData* pSVData = ImplGetSVData();
if( pSVData->mpSalTimer )
- pSVData->mpSalTimer->CallCallback();
+ {
+ // TODO: context_pending should be probably checked too, but it causes locking assertion failures
+ bool idle = !pSalData->BlockIdleTimeout() && /*!g_main_context_pending( NULL ) &&*/ !gdk_events_pending();
+ pSVData->mpSalTimer->CallCallback( idle );
+ }
return TRUE;
}