summaryrefslogtreecommitdiff
path: root/vcl/win
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2017-08-29 10:29:51 +0200
committerJan-Marek Glogowski <glogow@fbihome.de>2017-09-26 13:53:28 +0200
commit9679fb26558ea42e47ac9936cef329115a8fdf65 (patch)
treeeee6c65d50667fc5b9924f98ce8f87a6df9d707a /vcl/win
parent808d048694630303d895e818cfd5fb48c9d16738 (diff)
tdf#112288 Clarify Reschedule implementations
Application::Reschedule(true) must just process all currently pending events and ignore all new events generated while processing them. In contrast to Scheduler::ProcessEventsToIdle, this way it can't busy-lock the application with background jobs. This way we also can drop nMaxEvents from the Windows backend. This limit was also never implemented on OSX and for the KDE4 backend it's actually impossible to handle single events, and a call to QAbstractEventDispatcher::processEvents works like this. Also changes various call sites to just process all pending events instead of some made up number of times. Change-Id: I1ab95df89b079cc8c6319a808194fe3127144d1c Reviewed-on: https://gerrit.libreoffice.org/42659 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl/win')
-rw-r--r--vcl/win/app/salinst.cxx38
1 files changed, 25 insertions, 13 deletions
diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx
index be96ed17c654..23e48532d3b9 100644
--- a/vcl/win/app/salinst.cxx
+++ b/vcl/win/app/salinst.cxx
@@ -506,12 +506,17 @@ static void ImplSalDispatchMessage( MSG* pMsg )
static bool ImplSalYield( bool bWait, bool bHandleAllCurrentEvents )
{
+ static sal_uInt32 nLastTicks = 0;
MSG aMsg;
bool bWasMsg = false, bOneEvent = false;
ImplSVData *const pSVData = ImplGetSVData();
WinSalTimer* pTimer = static_cast<WinSalTimer*>( pSVData->maSchedCtx.mpSalTimer );
- int nMaxEvents = bHandleAllCurrentEvents ? 100 : 1;
+ sal_uInt32 nCurTicks = 0;
+ if ( bHandleAllCurrentEvents )
+ nCurTicks = GetTickCount();
+
+ bool bHadNewerEvent = false;
do
{
bOneEvent = PeekMessageW( &aMsg, nullptr, 0, 0, PM_REMOVE );
@@ -520,20 +525,26 @@ static bool ImplSalYield( bool bWait, bool bHandleAllCurrentEvents )
bWasMsg = true;
TranslateMessage( &aMsg );
ImplSalDispatchMessage( &aMsg );
+ if ( bHandleAllCurrentEvents
+ && !bHadNewerEvent && aMsg.time > nCurTicks
+ && (nLastTicks <= nCurTicks || aMsg.time < nLastTicks) )
+ bHadNewerEvent = true;
+ bOneEvent = !bHadNewerEvent;
}
- else
- // busy loop to catch the 0ms timeout
- // We don't need to busy loop, if we wait anyway.
- // Even if we didn't process the event directly, report it.
- if ( pTimer && pTimer->PollForMessage() && !bWait )
- {
- SwitchToThread();
- nMaxEvents++;
- bOneEvent = true;
- bWasMsg = true;
- }
+ // busy loop to catch a message, eventually the 0ms timer.
+ // we don't need to loop, if we wait anyway.
+ if ( !bWait && !bWasMsg && pTimer && pTimer->PollForMessage() )
+ {
+ SwitchToThread();
+ continue;
+ }
+ if ( !(bHandleAllCurrentEvents && bOneEvent) )
+ break;
}
- while( --nMaxEvents && bOneEvent );
+ while( true );
+
+ if ( bHandleAllCurrentEvents )
+ nLastTicks = nCurTicks;
// Also check that we don't wait when application already has quit
if ( bWait && !bWasMsg && !pSVData->maAppData.mbAppQuit )
@@ -545,6 +556,7 @@ static bool ImplSalYield( bool bWait, bool bHandleAllCurrentEvents )
ImplSalDispatchMessage( &aMsg );
}
}
+
return bWasMsg;
}