Kaydet (Commit) eca4c54e authored tarafından Michael Meeks's avatar Michael Meeks

vcl: add parameter to detect if OS events are processed during Yield.

Intended as a non-functional change.

Change-Id: I1915aad03786540da1a4bfe9031d33f2c2a9b4e3
Reviewed-on: https://gerrit.libreoffice.org/20006Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMichael Meeks <michael.meeks@collabora.com>
üst 2ee80224
...@@ -261,7 +261,7 @@ SalBitmap* SvpSalInstance::CreateSalBitmap() ...@@ -261,7 +261,7 @@ SalBitmap* SvpSalInstance::CreateSalBitmap()
#endif #endif
} }
void SvpSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLong const nReleased) bool SvpSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLong const nReleased)
{ {
(void) nReleased; (void) nReleased;
assert(nReleased == 0); // not implemented assert(nReleased == 0); // not implemented
...@@ -328,6 +328,8 @@ void SvpSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLong ...@@ -328,6 +328,8 @@ void SvpSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLong
DoReleaseYield(nTimeoutMS); DoReleaseYield(nTimeoutMS);
} }
return bEvent;
} }
void SvpSalInstance::DoReleaseYield( int nTimeoutMS ) void SvpSalInstance::DoReleaseYield( int nTimeoutMS )
......
...@@ -159,7 +159,7 @@ public: ...@@ -159,7 +159,7 @@ public:
// wait next event and dispatch // wait next event and dispatch
// must returned by UserEvent (SalFrame::PostEvent) // must returned by UserEvent (SalFrame::PostEvent)
// and timer // and timer
virtual void DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLong nReleased) override; virtual bool DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLong nReleased) override;
virtual bool AnyInput( VclInputFlags nType ) override; virtual bool AnyInput( VclInputFlags nType ) override;
// may return NULL to disable session management // may return NULL to disable session management
......
...@@ -107,7 +107,7 @@ public: ...@@ -107,7 +107,7 @@ public:
virtual sal_uLong ReleaseYieldMutex() override; virtual sal_uLong ReleaseYieldMutex() override;
virtual void AcquireYieldMutex( sal_uLong nCount ) override; virtual void AcquireYieldMutex( sal_uLong nCount ) override;
virtual bool CheckYieldMutex() override; virtual bool CheckYieldMutex() override;
virtual void DoYield(bool bWait, bool bHandleAllCurrentEvents, virtual bool DoYield(bool bWait, bool bHandleAllCurrentEvents,
sal_uLong nReleased) override; sal_uLong nReleased) override;
virtual bool AnyInput( VclInputFlags nType ) override; virtual bool AnyInput( VclInputFlags nType ) override;
virtual SalMenu* CreateMenu( bool bMenuBar, Menu* pVCLMenu ) override; virtual SalMenu* CreateMenu( bool bMenuBar, Menu* pVCLMenu ) override;
......
...@@ -125,10 +125,13 @@ public: ...@@ -125,10 +125,13 @@ public:
// return true, if yield mutex is owned by this thread, else false // return true, if yield mutex is owned by this thread, else false
virtual bool CheckYieldMutex() = 0; virtual bool CheckYieldMutex() = 0;
// wait next event and dispatch /**
// must returned by UserEvent (SalFrame::PostEvent) * Wait for the next event (if @bWait) and dispatch it,
// and timer * includes posted events, and timers.
virtual void DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLong nReleased) = 0; * If @bHandleAllCurrentEvents - dispatch multiple posted
* user events. Returns true if events needed processing.
*/
virtual bool DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLong nReleased) = 0;
virtual bool AnyInput( VclInputFlags nType ) = 0; virtual bool AnyInput( VclInputFlags nType ) = 0;
// menus // menus
......
...@@ -115,7 +115,7 @@ public: ...@@ -115,7 +115,7 @@ public:
static gboolean userEventFn( gpointer data ); static gboolean userEventFn( gpointer data );
void PostUserEvent(); void PostUserEvent();
void Yield( bool bWait, bool bHandleAllCurrentEvents ); bool Yield( bool bWait, bool bHandleAllCurrentEvents );
inline GdkDisplay *GetGdkDisplay(); inline GdkDisplay *GetGdkDisplay();
virtual void ErrorTrapPush() override; virtual void ErrorTrapPush() override;
......
...@@ -80,7 +80,7 @@ public: ...@@ -80,7 +80,7 @@ public:
const SystemGraphicsData* ) override; const SystemGraphicsData* ) override;
virtual SalBitmap* CreateSalBitmap() override; virtual SalBitmap* CreateSalBitmap() override;
virtual void DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLong nReleased) override; virtual bool DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLong nReleased) override;
virtual bool AnyInput( VclInputFlags nType ) override; virtual bool AnyInput( VclInputFlags nType ) override;
virtual GenPspGraphics *CreatePrintGraphics() override; virtual GenPspGraphics *CreatePrintGraphics() override;
......
...@@ -153,7 +153,7 @@ public: ...@@ -153,7 +153,7 @@ public:
virtual ~SalXLib(); virtual ~SalXLib();
virtual void Init(); virtual void Init();
virtual void Yield( bool bWait, bool bHandleAllCurrentEvents ); virtual bool Yield( bool bWait, bool bHandleAllCurrentEvents );
virtual void Wakeup(); virtual void Wakeup();
virtual void PostUserEvent(); virtual void PostUserEvent();
...@@ -365,7 +365,7 @@ public: ...@@ -365,7 +365,7 @@ public:
virtual ~SalX11Display(); virtual ~SalX11Display();
virtual bool Dispatch( XEvent *pEvent ) override; virtual bool Dispatch( XEvent *pEvent ) override;
virtual void Yield(); virtual bool Yield();
virtual void PostUserEvent() override; virtual void PostUserEvent() override;
bool IsEvent(); bool IsEvent();
......
...@@ -71,7 +71,7 @@ public: ...@@ -71,7 +71,7 @@ public:
virtual SalBitmap* CreateSalBitmap() override; virtual SalBitmap* CreateSalBitmap() override;
virtual SalSession* CreateSalSession() override; virtual SalSession* CreateSalSession() override;
virtual void DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLong nReleased) override; virtual bool DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLong nReleased) override;
virtual bool AnyInput( VclInputFlags nType ) override; virtual bool AnyInput( VclInputFlags nType ) override;
virtual void* GetConnectionIdentifier( ConnectionIdentifierType& rReturnedType, int& rReturnedBytes ) override; virtual void* GetConnectionIdentifier( ConnectionIdentifierType& rReturnedType, int& rReturnedBytes ) override;
......
...@@ -72,7 +72,7 @@ public: ...@@ -72,7 +72,7 @@ public:
virtual void AcquireYieldMutex( sal_uIntPtr nCount ) override; virtual void AcquireYieldMutex( sal_uIntPtr nCount ) override;
virtual bool CheckYieldMutex() override; virtual bool CheckYieldMutex() override;
virtual void DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLong nReleased) override; virtual bool DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLong nReleased) override;
virtual bool AnyInput( VclInputFlags nType ) override; virtual bool AnyInput( VclInputFlags nType ) override;
virtual SalMenu* CreateMenu( bool bMenuBar, Menu* ) override; virtual SalMenu* CreateMenu( bool bMenuBar, Menu* ) override;
virtual void DestroyMenu( SalMenu* ) override; virtual void DestroyMenu( SalMenu* ) override;
......
...@@ -559,10 +559,11 @@ class ReleasePoolHolder ...@@ -559,10 +559,11 @@ class ReleasePoolHolder
~ReleasePoolHolder() { [mpPool release]; } ~ReleasePoolHolder() { [mpPool release]; }
}; };
void AquaSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLong const nReleased) bool AquaSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLong const nReleased)
{ {
(void) nReleased; (void) nReleased;
assert(nReleased == 0); // not implemented assert(nReleased == 0); // not implemented
// ensure that the per thread autorelease pool is top level and // ensure that the per thread autorelease pool is top level and
// will therefore not be destroyed by cocoa implicitly // will therefore not be destroyed by cocoa implicitly
SalData::ensureThreadAutoreleasePool(); SalData::ensureThreadAutoreleasePool();
...@@ -599,12 +600,13 @@ void AquaSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLon ...@@ -599,12 +600,13 @@ void AquaSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLon
osl_setCondition( maWaitingYieldCond ); osl_setCondition( maWaitingYieldCond );
// return if only one event is asked for // return if only one event is asked for
if( ! bHandleAllCurrentEvents ) if( ! bHandleAllCurrentEvents )
return; return true;
} }
} }
// handle cocoa event queue // handle cocoa event queue
// cocoa events may be only handled in the thread the NSApp was created // cocoa events may be only handled in the thread the NSApp was created
bool bHadEvent = false;
if( isNSAppThread() && mnActivePrintJobs == 0 ) if( isNSAppThread() && mnActivePrintJobs == 0 )
{ {
// we need to be woken up by a cocoa-event // we need to be woken up by a cocoa-event
...@@ -614,7 +616,6 @@ void AquaSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLon ...@@ -614,7 +616,6 @@ void AquaSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLon
// handle available events // handle available events
NSEvent* pEvent = nil; NSEvent* pEvent = nil;
bool bHadEvent = false;
do do
{ {
sal_uLong nCount = ReleaseYieldMutex(); sal_uLong nCount = ReleaseYieldMutex();
...@@ -709,6 +710,8 @@ void AquaSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLon ...@@ -709,6 +710,8 @@ void AquaSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLon
bInAppEvent = false; bInAppEvent = false;
} }
} }
return bHadEvent;
} }
bool AquaSalInstance::AnyInput( VclInputFlags nType ) bool AquaSalInstance::AnyInput( VclInputFlags nType )
......
...@@ -607,7 +607,7 @@ bool SalXLib::CheckTimeout( bool bExecuteTimers ) ...@@ -607,7 +607,7 @@ bool SalXLib::CheckTimeout( bool bExecuteTimers )
return bRet; return bRet;
} }
void SalXLib::Yield( bool bWait, bool bHandleAllCurrentEvents ) bool SalXLib::Yield( bool bWait, bool bHandleAllCurrentEvents )
{ {
blockIdleTimeout = !bWait; blockIdleTimeout = !bWait;
// check for timeouts here if you want to make screenshots // check for timeouts here if you want to make screenshots
...@@ -630,7 +630,7 @@ void SalXLib::Yield( bool bWait, bool bHandleAllCurrentEvents ) ...@@ -630,7 +630,7 @@ void SalXLib::Yield( bool bWait, bool bHandleAllCurrentEvents )
if( ! bHandleAllCurrentEvents ) if( ! bHandleAllCurrentEvents )
{ {
blockIdleTimeout = false; blockIdleTimeout = false;
return; return true;
} }
} }
} }
...@@ -645,6 +645,8 @@ void SalXLib::Yield( bool bWait, bool bHandleAllCurrentEvents ) ...@@ -645,6 +645,8 @@ void SalXLib::Yield( bool bWait, bool bHandleAllCurrentEvents )
timeval Timeout = noyield__; timeval Timeout = noyield__;
timeval *pTimeout = &Timeout; timeval *pTimeout = &Timeout;
bool bHandledEvent = false;
if (bWait) if (bWait)
{ {
pTimeout = nullptr; pTimeout = nullptr;
...@@ -705,7 +707,7 @@ void SalXLib::Yield( bool bWait, bool bHandleAllCurrentEvents ) ...@@ -705,7 +707,7 @@ void SalXLib::Yield( bool bWait, bool bHandleAllCurrentEvents )
if (nFound == 0) if (nFound == 0)
{ {
blockIdleTimeout = false; blockIdleTimeout = false;
return; return false;
} }
for ( int nFD = 0; nFD < nFDs_; nFD++ ) for ( int nFD = 0; nFD < nFDs_; nFD++ )
...@@ -724,6 +726,7 @@ void SalXLib::Yield( bool bWait, bool bHandleAllCurrentEvents ) ...@@ -724,6 +726,7 @@ void SalXLib::Yield( bool bWait, bool bHandleAllCurrentEvents )
for( int i = 0; pEntry->IsEventQueued() && i < nMaxEvents; i++ ) for( int i = 0; pEntry->IsEventQueued() && i < nMaxEvents; i++ )
{ {
pEntry->HandleNextEvent(); pEntry->HandleNextEvent();
bHandledEvent = true;
// if a recursive call has done the job // if a recursive call has done the job
// so abort here // so abort here
} }
...@@ -733,6 +736,8 @@ void SalXLib::Yield( bool bWait, bool bHandleAllCurrentEvents ) ...@@ -733,6 +736,8 @@ void SalXLib::Yield( bool bWait, bool bHandleAllCurrentEvents )
} }
} }
blockIdleTimeout = false; blockIdleTimeout = false;
return bHandledEvent;
} }
void SalXLib::Wakeup() void SalXLib::Wakeup()
......
...@@ -1886,10 +1886,10 @@ bool SalX11Display::IsEvent() ...@@ -1886,10 +1886,10 @@ bool SalX11Display::IsEvent()
return false; return false;
} }
void SalX11Display::Yield() bool SalX11Display::Yield()
{ {
if( DispatchInternalEvent() ) if( DispatchInternalEvent() )
return; return true;
XEvent aEvent; XEvent aEvent;
DBG_ASSERT( static_cast<SalYieldMutex*>(GetSalData()->m_pInstance->GetYieldMutex())->GetThreadId() == DBG_ASSERT( static_cast<SalYieldMutex*>(GetSalData()->m_pInstance->GetYieldMutex())->GetThreadId() ==
...@@ -1898,7 +1898,8 @@ void SalX11Display::Yield() ...@@ -1898,7 +1898,8 @@ void SalX11Display::Yield()
XNextEvent( pDisp_, &aEvent ); XNextEvent( pDisp_, &aEvent );
Dispatch( &aEvent ); // FIXME: under-convinced by Dispatch boolean return value vs. salframe.
bool bProcessedEvent = Dispatch( &aEvent );
#ifdef DBG_UTIL #ifdef DBG_UTIL
if( GetX11SalData()->HasXErrorOccurred() ) if( GetX11SalData()->HasXErrorOccurred() )
...@@ -1908,6 +1909,8 @@ void SalX11Display::Yield() ...@@ -1908,6 +1909,8 @@ void SalX11Display::Yield()
} }
#endif #endif
GetX11SalData()->ResetXErrorOccurred(); GetX11SalData()->ResetXErrorOccurred();
return bProcessedEvent;
} }
bool SalX11Display::Dispatch( XEvent *pEvent ) bool SalX11Display::Dispatch( XEvent *pEvent )
......
...@@ -151,11 +151,11 @@ bool X11SalInstance::AnyInput(VclInputFlags nType) ...@@ -151,11 +151,11 @@ bool X11SalInstance::AnyInput(VclInputFlags nType)
return bRet; return bRet;
} }
void X11SalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLong const nReleased) bool X11SalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLong const nReleased)
{ {
(void) nReleased; (void) nReleased;
assert(nReleased == 0); // not implemented assert(nReleased == 0); // not implemented
mpXLib->Yield( bWait, bHandleAllCurrentEvents ); return mpXLib->Yield( bWait, bHandleAllCurrentEvents );
} }
void* X11SalInstance::GetConnectionIdentifier( ConnectionIdentifierType& rReturnedType, void* X11SalInstance::GetConnectionIdentifier( ConnectionIdentifierType& rReturnedType,
......
...@@ -578,9 +578,11 @@ void GtkData::Dispose() ...@@ -578,9 +578,11 @@ void GtkData::Dispose()
deInitNWF(); deInitNWF();
} }
void GtkData::Yield( bool bWait, bool bHandleAllCurrentEvents ) /// Allows events to be processed, returns true if we processed an event.
bool GtkData::Yield( bool bWait, bool bHandleAllCurrentEvents )
{ {
blockIdleTimeout = !bWait; blockIdleTimeout = !bWait;
/* #i33212# only enter g_main_context_iteration in one thread at any one /* #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 * time, else one of them potentially will never end as long as there is
* another thread in there. Having only one yielding thread actually dispatch * another thread in there. Having only one yielding thread actually dispatch
...@@ -596,7 +598,7 @@ void GtkData::Yield( bool bWait, bool bHandleAllCurrentEvents ) ...@@ -596,7 +598,7 @@ void GtkData::Yield( bool bWait, bool bHandleAllCurrentEvents )
else if( ! bWait ) else if( ! bWait )
{ {
blockIdleTimeout = false; blockIdleTimeout = false;
return; // someone else is waiting already, return return false; // someone else is waiting already, return
} }
if( bDispatchThread ) if( bDispatchThread )
...@@ -630,6 +632,8 @@ void GtkData::Yield( bool bWait, bool bHandleAllCurrentEvents ) ...@@ -630,6 +632,8 @@ void GtkData::Yield( bool bWait, bool bHandleAllCurrentEvents )
osl_setCondition( m_aDispatchCondition ); // trigger non dispatch thread yields osl_setCondition( m_aDispatchCondition ); // trigger non dispatch thread yields
} }
blockIdleTimeout = false; blockIdleTimeout = false;
return bWasEvent;
} }
void GtkData::Init() void GtkData::Init()
......
...@@ -396,12 +396,12 @@ void GtkInstance::RemoveTimer (SalTimer *pTimer) ...@@ -396,12 +396,12 @@ void GtkInstance::RemoveTimer (SalTimer *pTimer)
m_aTimers.erase( it ); m_aTimers.erase( it );
} }
void GtkInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLong const nReleased) bool GtkInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLong const nReleased)
{ {
(void) nReleased; (void) nReleased;
assert(nReleased == 0); // not implemented assert(nReleased == 0); // not implemented
EnsureInit(); EnsureInit();
GetGtkSalData()->Yield( bWait, bHandleAllCurrentEvents ); return GetGtkSalData()->Yield( bWait, bHandleAllCurrentEvents );
} }
bool GtkInstance::IsTimerExpired() bool GtkInstance::IsTimerExpired()
......
...@@ -621,7 +621,7 @@ static void ImplSalDispatchMessage( MSG* pMsg ) ...@@ -621,7 +621,7 @@ static void ImplSalDispatchMessage( MSG* pMsg )
ImplSalPostDispatchMsg( pMsg, lResult ); ImplSalPostDispatchMsg( pMsg, lResult );
} }
void ImplSalYield( bool bWait, bool bHandleAllCurrentEvents ) bool ImplSalYield( bool bWait, bool bHandleAllCurrentEvents )
{ {
MSG aMsg; MSG aMsg;
bool bWasMsg = false, bOneEvent = false; bool bWasMsg = false, bOneEvent = false;
...@@ -648,10 +648,12 @@ void ImplSalYield( bool bWait, bool bHandleAllCurrentEvents ) ...@@ -648,10 +648,12 @@ void ImplSalYield( bool bWait, bool bHandleAllCurrentEvents )
ImplSalDispatchMessage( &aMsg ); ImplSalDispatchMessage( &aMsg );
} }
} }
return bWasMsg;
} }
void WinSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLong const nReleased) bool WinSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLong const nReleased)
{ {
bool bDidWork = false;
// NOTE: if nReleased != 0 this will be called without SolarMutex // NOTE: if nReleased != 0 this will be called without SolarMutex
// so don't do anything dangerous before releasing it here // so don't do anything dangerous before releasing it here
SalYieldMutex* pYieldMutex = mpSalYieldMutex; SalYieldMutex* pYieldMutex = mpSalYieldMutex;
...@@ -692,7 +694,7 @@ void WinSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLong ...@@ -692,7 +694,7 @@ void WinSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLong
} }
else else
{ {
ImplSalYield( bWait, bHandleAllCurrentEvents ); bDidWork = ImplSalYield( bWait, bHandleAllCurrentEvents );
n = nCount; n = nCount;
while ( n ) while ( n )
...@@ -701,6 +703,7 @@ void WinSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLong ...@@ -701,6 +703,7 @@ void WinSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLong
n--; n--;
} }
} }
return bDidWork;
} }
LRESULT CALLBACK SalComWndProc( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam, int& rDef ) LRESULT CALLBACK SalComWndProc( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam, int& rDef )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment