[Libreoffice-commits] core.git: vcl/inc vcl/osx
Jan-Marek Glogowski
glogow at fbihome.de
Fri Oct 20 12:51:34 UTC 2017
vcl/inc/osx/salinst.h | 1 +
vcl/inc/osx/saltimer.h | 9 ++++++++-
vcl/osx/salinst.cxx | 17 +++++++++++++++--
vcl/osx/saltimer.cxx | 19 ++++++++++++-------
4 files changed, 36 insertions(+), 10 deletions(-)
New commits:
commit fd5fa397a0a46470e034bb23789f7a17592cb070
Author: Jan-Marek Glogowski <glogow at fbihome.de>
Date: Wed Oct 18 17:00:53 2017 +0200
OSX implement direct timeout processing
Basically works in the same way then in the Windows backend.
Change-Id: If48e2b55f037563839a5e716830ce75ed78381e4
Reviewed-on: https://gerrit.libreoffice.org/43530
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Jan-Marek Glogowski <glogow at fbihome.de>
diff --git a/vcl/inc/osx/salinst.h b/vcl/inc/osx/salinst.h
index 272cfc722d64..01e50af77b99 100644
--- a/vcl/inc/osx/salinst.h
+++ b/vcl/inc/osx/salinst.h
@@ -77,6 +77,7 @@ public:
osl::Condition maWaitingYieldCond;
bool mbIsLiveResize;
bool mbNoYieldLock;
+ bool mbTimerProcessed;
static std::list<const ApplicationEvent*> aAppEventList;
diff --git a/vcl/inc/osx/saltimer.h b/vcl/inc/osx/saltimer.h
index c860ad5cbdda..a9934f280636 100644
--- a/vcl/inc/osx/saltimer.h
+++ b/vcl/inc/osx/saltimer.h
@@ -44,6 +44,7 @@ public:
class AquaSalTimer final : public SalTimer, protected VersionedEvent
{
NSTimer *m_pRunningTimer;
+ bool m_bDirectTimeout; ///< timeout can be processed directly
void queueDispatchTimerEvent( bool bAtStart );
void callTimerCallback();
@@ -56,13 +57,19 @@ public:
void Stop() override;
void handleStartTimerEvent( NSEvent* pEvent );
- void handleDispatchTimerEvent( NSEvent* pEvent );
+ bool handleDispatchTimerEvent( NSEvent* pEvent );
void handleTimerElapsed();
void handleWindowShouldClose();
bool IsTimerElapsed() const;
+ inline bool IsDirectTimeout() const;
};
+inline bool AquaSalTimer::IsDirectTimeout() const
+{
+ return m_bDirectTimeout;
+}
+
#endif // INCLUDED_VCL_INC_OSX_SALTIMER_H
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/osx/salinst.cxx b/vcl/osx/salinst.cxx
index d475f30275b0..922046bcbfe8 100644
--- a/vcl/osx/salinst.cxx
+++ b/vcl/osx/salinst.cxx
@@ -379,6 +379,7 @@ AquaSalInstance::AquaSalInstance()
: mnActivePrintJobs( 0 )
, mbIsLiveResize( false )
, mbNoYieldLock( false )
+ , mbTimerProcessed( false )
{
mpSalYieldMutex = new SalYieldMutex;
mpSalYieldMutex->acquire();
@@ -452,9 +453,12 @@ void AquaSalInstance::handleAppDefinedEvent( NSEvent* pEvent )
break;
}
case DispatchTimerEvent:
- if ( pTimer )
- pTimer->handleDispatchTimerEvent( pEvent );
+ {
+ AquaSalInstance *pInst = GetSalData()->mpInstance;
+ if ( pTimer && pInst )
+ pInst->mbTimerProcessed = pTimer->handleDispatchTimerEvent( pEvent );
break;
+ }
#if !HAVE_FEATURE_MACOSX_SANDBOX
case AppleRemoteControlEvent: // Defined in <apple_remote/RemoteMainController.h>
{
@@ -570,6 +574,8 @@ bool AquaSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents)
// handle available events
NSEvent* pEvent = nil;
NSTimeInterval now = [[NSProcessInfo processInfo] systemUptime];
+ mbTimerProcessed = false;
+
do
{
SolarMutexReleaser aReleaser;
@@ -596,6 +602,13 @@ SAL_WNODEPRECATED_DECLARATIONS_POP
}
while( true );
+ AquaSalTimer *pTimer = static_cast<AquaSalTimer*>( ImplGetSVData()->maSchedCtx.mpSalTimer );
+ if ( !mbTimerProcessed && pTimer && pTimer->IsDirectTimeout() )
+ {
+ pTimer->handleTimerElapsed();
+ bHadEvent = true;
+ }
+
// if we had no event yet, wait for one if requested
if( bWait && ! bHadEvent )
{
diff --git a/vcl/osx/saltimer.cxx b/vcl/osx/saltimer.cxx
index 34d46f08728a..3d74da42a3dc 100644
--- a/vcl/osx/saltimer.cxx
+++ b/vcl/osx/saltimer.cxx
@@ -74,6 +74,7 @@ SAL_WNODEPRECATED_DECLARATIONS_POP
void AquaSalTimer::queueDispatchTimerEvent( bool bAtStart )
{
Stop();
+ m_bDirectTimeout = true;
ImplNSAppPostEvent( AquaSalInstance::DispatchTimerEvent,
bAtStart, GetNextEventVersion() );
}
@@ -88,8 +89,9 @@ void AquaSalTimer::Start( sal_uLong nMS )
return;
}
- if ( 0 == nMS && !pSalData->mpInstance->mbIsLiveResize )
- queueDispatchTimerEvent( NO );
+ m_bDirectTimeout = (0 == nMS) && !pSalData->mpInstance->mbIsLiveResize;
+ if ( m_bDirectTimeout )
+ Stop();
else
{
NSTimeInterval aTI = double(nMS) / 1000.0;
@@ -139,13 +141,14 @@ void AquaSalTimer::callTimerCallback()
{
ImplSVData* pSVData = ImplGetSVData();
SolarMutexGuard aGuard;
+ m_bDirectTimeout = false;
if( pSVData->maSchedCtx.mpSalTimer )
pSVData->maSchedCtx.mpSalTimer->CallCallback();
}
void AquaSalTimer::handleTimerElapsed()
{
- if ( GetSalData()->mpInstance->mbIsLiveResize )
+ if ( m_bDirectTimeout || GetSalData()->mpInstance->mbIsLiveResize )
{
// Stop the timer, as it is just invalidated after the firing function
Stop();
@@ -155,10 +158,12 @@ void AquaSalTimer::handleTimerElapsed()
queueDispatchTimerEvent( YES );
}
-void AquaSalTimer::handleDispatchTimerEvent( NSEvent *pEvent )
+bool AquaSalTimer::handleDispatchTimerEvent( NSEvent *pEvent )
{
- if ( IsValidEventVersion( [pEvent data1] ) )
+ bool bIsValidEvent = IsValidEventVersion( [pEvent data1] );
+ if ( bIsValidEvent )
callTimerCallback();
+ return bIsValidEvent;
}
void AquaSalTimer::handleStartTimerEvent( NSEvent* pEvent )
@@ -177,8 +182,8 @@ void AquaSalTimer::handleStartTimerEvent( NSEvent* pEvent )
bool AquaSalTimer::IsTimerElapsed() const
{
- assert( !(ExistsValidEvent() && m_pRunningTimer) );
- if ( ExistsValidEvent() )
+ assert( !((ExistsValidEvent() || m_bDirectTimeout) && m_pRunningTimer) );
+ if ( ExistsValidEvent() || m_bDirectTimeout )
return true;
if ( !m_pRunningTimer )
return false;
More information about the Libreoffice-commits
mailing list