[Libreoffice-commits] core.git: vcl/headless vcl/inc vcl/osx vcl/unx vcl/win

Michael Meeks michael.meeks at collabora.com
Tue Nov 17 01:21:23 PST 2015


 vcl/headless/svpinst.cxx        |    4 +++-
 vcl/inc/headless/svpinst.hxx    |    2 +-
 vcl/inc/osx/salinst.h           |    2 +-
 vcl/inc/salinst.hxx             |   11 +++++++----
 vcl/inc/unx/gtk/gtkdata.hxx     |    2 +-
 vcl/inc/unx/gtk/gtkinst.hxx     |    2 +-
 vcl/inc/unx/saldisp.hxx         |    4 ++--
 vcl/inc/unx/salinst.h           |    2 +-
 vcl/inc/win/salinst.h           |    2 +-
 vcl/osx/salinst.cxx             |    9 ++++++---
 vcl/unx/generic/app/saldata.cxx |   11 ++++++++---
 vcl/unx/generic/app/saldisp.cxx |    9 ++++++---
 vcl/unx/generic/app/salinst.cxx |    4 ++--
 vcl/unx/gtk/gtkdata.cxx         |    8 ++++++--
 vcl/unx/gtk/gtkinst.cxx         |    4 ++--
 vcl/win/source/app/salinst.cxx  |    9 ++++++---
 16 files changed, 54 insertions(+), 31 deletions(-)

New commits:
commit eca4c54e52363f80db26e228e586aeb7732c7100
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Mon Nov 16 20:59:58 2015 +0000

    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 at libreoffice.org>
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/vcl/headless/svpinst.cxx b/vcl/headless/svpinst.cxx
index c5df6b7..9c941a0 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 9599d32..5f9d980 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 b8d45f0..2e909ee 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 34be188..8f1a4a5 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 43ec0e1..aa513ce 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 48701ba..60bf1f9 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 b1a01e0..e6c2a0f 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 74e1cb2..083200c 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 2d3cadc..601159a 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 b4c4eec..f2afec8 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 fc1e72d..8d5d048 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 49e00de..9296a6f 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 057b9894..457fc52 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 5fd4c0e..02ad2b8 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 eeb75de..0e7ba5e 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 f8a96da..4ddf3a9 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 )


More information about the Libreoffice-commits mailing list