diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2015-11-16 20:59:58 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2015-11-17 09:20:58 +0000 |
commit | eca4c54e52363f80db26e228e586aeb7732c7100 (patch) | |
tree | f96c872d02d15044279c5c49097aa8ea70a8f967 /vcl | |
parent | 2ee802245ed9614734506a9d46edcbcee53ea2cc (diff) |
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/20006
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/headless/svpinst.cxx | 4 | ||||
-rw-r--r-- | vcl/inc/headless/svpinst.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/osx/salinst.h | 2 | ||||
-rw-r--r-- | vcl/inc/salinst.hxx | 11 | ||||
-rw-r--r-- | vcl/inc/unx/gtk/gtkdata.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/unx/gtk/gtkinst.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/unx/saldisp.hxx | 4 | ||||
-rw-r--r-- | vcl/inc/unx/salinst.h | 2 | ||||
-rw-r--r-- | vcl/inc/win/salinst.h | 2 | ||||
-rw-r--r-- | vcl/osx/salinst.cxx | 9 | ||||
-rw-r--r-- | vcl/unx/generic/app/saldata.cxx | 11 | ||||
-rw-r--r-- | vcl/unx/generic/app/saldisp.cxx | 9 | ||||
-rw-r--r-- | vcl/unx/generic/app/salinst.cxx | 4 | ||||
-rw-r--r-- | vcl/unx/gtk/gtkdata.cxx | 8 | ||||
-rw-r--r-- | vcl/unx/gtk/gtkinst.cxx | 4 | ||||
-rw-r--r-- | vcl/win/source/app/salinst.cxx | 9 |
16 files changed, 54 insertions, 31 deletions
diff --git a/vcl/headless/svpinst.cxx b/vcl/headless/svpinst.cxx index c5df6b760863..9c941a069f07 100644 --- a/vcl/headless/svpinst.cxx +++ b/vcl/headless/svpinst.cxx @@ -261,7 +261,7 @@ SalBitmap* SvpSalInstance::CreateSalBitmap() #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; assert(nReleased == 0); // not implemented @@ -328,6 +328,8 @@ void SvpSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLong DoReleaseYield(nTimeoutMS); } + + return bEvent; } void SvpSalInstance::DoReleaseYield( int nTimeoutMS ) diff --git a/vcl/inc/headless/svpinst.hxx b/vcl/inc/headless/svpinst.hxx index 9599d3217ee5..5f9d9806e4b6 100644 --- a/vcl/inc/headless/svpinst.hxx +++ b/vcl/inc/headless/svpinst.hxx @@ -159,7 +159,7 @@ public: // wait next event and dispatch // must returned by UserEvent (SalFrame::PostEvent) // 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; // may return NULL to disable session management diff --git a/vcl/inc/osx/salinst.h b/vcl/inc/osx/salinst.h index b8d45f0f2903..2e909ee1174c 100644 --- a/vcl/inc/osx/salinst.h +++ b/vcl/inc/osx/salinst.h @@ -107,7 +107,7 @@ public: virtual sal_uLong ReleaseYieldMutex() override; virtual void AcquireYieldMutex( sal_uLong nCount ) override; virtual bool CheckYieldMutex() override; - virtual void DoYield(bool bWait, bool bHandleAllCurrentEvents, + virtual bool DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLong nReleased) override; virtual bool AnyInput( VclInputFlags nType ) override; virtual SalMenu* CreateMenu( bool bMenuBar, Menu* pVCLMenu ) override; diff --git a/vcl/inc/salinst.hxx b/vcl/inc/salinst.hxx index 34be18878dd3..8f1a4a595886 100644 --- a/vcl/inc/salinst.hxx +++ b/vcl/inc/salinst.hxx @@ -125,10 +125,13 @@ public: // return true, if yield mutex is owned by this thread, else false virtual bool CheckYieldMutex() = 0; - // wait next event and dispatch - // must returned by UserEvent (SalFrame::PostEvent) - // and timer - virtual void DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLong nReleased) = 0; + /** + * Wait for the next event (if @bWait) and dispatch it, + * includes posted events, and timers. + * 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; // menus diff --git a/vcl/inc/unx/gtk/gtkdata.hxx b/vcl/inc/unx/gtk/gtkdata.hxx index 43ec0e1dbdb7..aa513ceddb4f 100644 --- a/vcl/inc/unx/gtk/gtkdata.hxx +++ b/vcl/inc/unx/gtk/gtkdata.hxx @@ -115,7 +115,7 @@ public: static gboolean userEventFn( gpointer data ); void PostUserEvent(); - void Yield( bool bWait, bool bHandleAllCurrentEvents ); + bool Yield( bool bWait, bool bHandleAllCurrentEvents ); inline GdkDisplay *GetGdkDisplay(); virtual void ErrorTrapPush() override; diff --git a/vcl/inc/unx/gtk/gtkinst.hxx b/vcl/inc/unx/gtk/gtkinst.hxx index 48701bafb3d6..60bf1f9b3d33 100644 --- a/vcl/inc/unx/gtk/gtkinst.hxx +++ b/vcl/inc/unx/gtk/gtkinst.hxx @@ -80,7 +80,7 @@ public: const SystemGraphicsData* ) 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 GenPspGraphics *CreatePrintGraphics() override; diff --git a/vcl/inc/unx/saldisp.hxx b/vcl/inc/unx/saldisp.hxx index b1a01e04eb34..e6c2a0fcef72 100644 --- a/vcl/inc/unx/saldisp.hxx +++ b/vcl/inc/unx/saldisp.hxx @@ -153,7 +153,7 @@ public: virtual ~SalXLib(); virtual void Init(); - virtual void Yield( bool bWait, bool bHandleAllCurrentEvents ); + virtual bool Yield( bool bWait, bool bHandleAllCurrentEvents ); virtual void Wakeup(); virtual void PostUserEvent(); @@ -365,7 +365,7 @@ public: virtual ~SalX11Display(); virtual bool Dispatch( XEvent *pEvent ) override; - virtual void Yield(); + virtual bool Yield(); virtual void PostUserEvent() override; bool IsEvent(); diff --git a/vcl/inc/unx/salinst.h b/vcl/inc/unx/salinst.h index 74e1cb296bb6..083200c14e3b 100644 --- a/vcl/inc/unx/salinst.h +++ b/vcl/inc/unx/salinst.h @@ -71,7 +71,7 @@ public: virtual SalBitmap* CreateSalBitmap() 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 void* GetConnectionIdentifier( ConnectionIdentifierType& rReturnedType, int& rReturnedBytes ) override; diff --git a/vcl/inc/win/salinst.h b/vcl/inc/win/salinst.h index 2d3cadc3a725..601159a26fb0 100644 --- a/vcl/inc/win/salinst.h +++ b/vcl/inc/win/salinst.h @@ -72,7 +72,7 @@ public: virtual void AcquireYieldMutex( sal_uIntPtr nCount ) 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 SalMenu* CreateMenu( bool bMenuBar, Menu* ) override; virtual void DestroyMenu( SalMenu* ) override; diff --git a/vcl/osx/salinst.cxx b/vcl/osx/salinst.cxx index b4c4eec621f6..f2afec8c71d6 100644 --- a/vcl/osx/salinst.cxx +++ b/vcl/osx/salinst.cxx @@ -559,10 +559,11 @@ class ReleasePoolHolder ~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; assert(nReleased == 0); // not implemented + // ensure that the per thread autorelease pool is top level and // will therefore not be destroyed by cocoa implicitly SalData::ensureThreadAutoreleasePool(); @@ -599,12 +600,13 @@ void AquaSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLon osl_setCondition( maWaitingYieldCond ); // return if only one event is asked for if( ! bHandleAllCurrentEvents ) - return; + return true; } } // handle cocoa event queue // cocoa events may be only handled in the thread the NSApp was created + bool bHadEvent = false; if( isNSAppThread() && mnActivePrintJobs == 0 ) { // we need to be woken up by a cocoa-event @@ -614,7 +616,6 @@ void AquaSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLon // handle available events NSEvent* pEvent = nil; - bool bHadEvent = false; do { sal_uLong nCount = ReleaseYieldMutex(); @@ -709,6 +710,8 @@ void AquaSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLon bInAppEvent = false; } } + + return bHadEvent; } bool AquaSalInstance::AnyInput( VclInputFlags nType ) diff --git a/vcl/unx/generic/app/saldata.cxx b/vcl/unx/generic/app/saldata.cxx index fc1e72dd4431..8d5d0486158d 100644 --- a/vcl/unx/generic/app/saldata.cxx +++ b/vcl/unx/generic/app/saldata.cxx @@ -607,7 +607,7 @@ bool SalXLib::CheckTimeout( bool bExecuteTimers ) return bRet; } -void SalXLib::Yield( bool bWait, bool bHandleAllCurrentEvents ) +bool SalXLib::Yield( bool bWait, bool bHandleAllCurrentEvents ) { blockIdleTimeout = !bWait; // check for timeouts here if you want to make screenshots @@ -630,7 +630,7 @@ void SalXLib::Yield( bool bWait, bool bHandleAllCurrentEvents ) if( ! bHandleAllCurrentEvents ) { blockIdleTimeout = false; - return; + return true; } } } @@ -645,6 +645,8 @@ void SalXLib::Yield( bool bWait, bool bHandleAllCurrentEvents ) timeval Timeout = noyield__; timeval *pTimeout = &Timeout; + bool bHandledEvent = false; + if (bWait) { pTimeout = nullptr; @@ -705,7 +707,7 @@ void SalXLib::Yield( bool bWait, bool bHandleAllCurrentEvents ) if (nFound == 0) { blockIdleTimeout = false; - return; + return false; } for ( int nFD = 0; nFD < nFDs_; nFD++ ) @@ -724,6 +726,7 @@ void SalXLib::Yield( bool bWait, bool bHandleAllCurrentEvents ) for( int i = 0; pEntry->IsEventQueued() && i < nMaxEvents; i++ ) { pEntry->HandleNextEvent(); + bHandledEvent = true; // if a recursive call has done the job // so abort here } @@ -733,6 +736,8 @@ void SalXLib::Yield( bool bWait, bool bHandleAllCurrentEvents ) } } blockIdleTimeout = false; + + return bHandledEvent; } void SalXLib::Wakeup() diff --git a/vcl/unx/generic/app/saldisp.cxx b/vcl/unx/generic/app/saldisp.cxx index 49e00de430b9..9296a6fd3f5e 100644 --- a/vcl/unx/generic/app/saldisp.cxx +++ b/vcl/unx/generic/app/saldisp.cxx @@ -1886,10 +1886,10 @@ bool SalX11Display::IsEvent() return false; } -void SalX11Display::Yield() +bool SalX11Display::Yield() { if( DispatchInternalEvent() ) - return; + return true; XEvent aEvent; DBG_ASSERT( static_cast<SalYieldMutex*>(GetSalData()->m_pInstance->GetYieldMutex())->GetThreadId() == @@ -1898,7 +1898,8 @@ void SalX11Display::Yield() XNextEvent( pDisp_, &aEvent ); - Dispatch( &aEvent ); + // FIXME: under-convinced by Dispatch boolean return value vs. salframe. + bool bProcessedEvent = Dispatch( &aEvent ); #ifdef DBG_UTIL if( GetX11SalData()->HasXErrorOccurred() ) @@ -1908,6 +1909,8 @@ void SalX11Display::Yield() } #endif GetX11SalData()->ResetXErrorOccurred(); + + return bProcessedEvent; } bool SalX11Display::Dispatch( XEvent *pEvent ) diff --git a/vcl/unx/generic/app/salinst.cxx b/vcl/unx/generic/app/salinst.cxx index 057b9894c504..457fc52c5f50 100644 --- a/vcl/unx/generic/app/salinst.cxx +++ b/vcl/unx/generic/app/salinst.cxx @@ -151,11 +151,11 @@ bool X11SalInstance::AnyInput(VclInputFlags nType) 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; assert(nReleased == 0); // not implemented - mpXLib->Yield( bWait, bHandleAllCurrentEvents ); + return mpXLib->Yield( bWait, bHandleAllCurrentEvents ); } void* X11SalInstance::GetConnectionIdentifier( ConnectionIdentifierType& rReturnedType, diff --git a/vcl/unx/gtk/gtkdata.cxx b/vcl/unx/gtk/gtkdata.cxx index 5fd4c0ecb5b3..02ad2b81468c 100644 --- a/vcl/unx/gtk/gtkdata.cxx +++ b/vcl/unx/gtk/gtkdata.cxx @@ -578,9 +578,11 @@ void GtkData::Dispose() 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; + /* #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 yielding thread actually dispatch @@ -596,7 +598,7 @@ void GtkData::Yield( bool bWait, bool bHandleAllCurrentEvents ) else if( ! bWait ) { blockIdleTimeout = false; - return; // someone else is waiting already, return + return false; // someone else is waiting already, return } if( bDispatchThread ) @@ -630,6 +632,8 @@ void GtkData::Yield( bool bWait, bool bHandleAllCurrentEvents ) osl_setCondition( m_aDispatchCondition ); // trigger non dispatch thread yields } blockIdleTimeout = false; + + return bWasEvent; } void GtkData::Init() diff --git a/vcl/unx/gtk/gtkinst.cxx b/vcl/unx/gtk/gtkinst.cxx index eeb75de2c902..0e7ba5e7e0cd 100644 --- a/vcl/unx/gtk/gtkinst.cxx +++ b/vcl/unx/gtk/gtkinst.cxx @@ -396,12 +396,12 @@ void GtkInstance::RemoveTimer (SalTimer *pTimer) 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; assert(nReleased == 0); // not implemented EnsureInit(); - GetGtkSalData()->Yield( bWait, bHandleAllCurrentEvents ); + return GetGtkSalData()->Yield( bWait, bHandleAllCurrentEvents ); } bool GtkInstance::IsTimerExpired() diff --git a/vcl/win/source/app/salinst.cxx b/vcl/win/source/app/salinst.cxx index f8a96dad2754..4ddf3a9e616c 100644 --- a/vcl/win/source/app/salinst.cxx +++ b/vcl/win/source/app/salinst.cxx @@ -621,7 +621,7 @@ static void ImplSalDispatchMessage( MSG* pMsg ) ImplSalPostDispatchMsg( pMsg, lResult ); } -void ImplSalYield( bool bWait, bool bHandleAllCurrentEvents ) +bool ImplSalYield( bool bWait, bool bHandleAllCurrentEvents ) { MSG aMsg; bool bWasMsg = false, bOneEvent = false; @@ -648,10 +648,12 @@ void ImplSalYield( bool bWait, bool bHandleAllCurrentEvents ) 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 // so don't do anything dangerous before releasing it here SalYieldMutex* pYieldMutex = mpSalYieldMutex; @@ -692,7 +694,7 @@ void WinSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLong } else { - ImplSalYield( bWait, bHandleAllCurrentEvents ); + bDidWork = ImplSalYield( bWait, bHandleAllCurrentEvents ); n = nCount; while ( n ) @@ -701,6 +703,7 @@ void WinSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents, sal_uLong n--; } } + return bDidWork; } LRESULT CALLBACK SalComWndProc( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam, int& rDef ) |