[Libreoffice-commits] core.git: Branch 'feature/fixes21' - 2 commits - include/sfx2 sfx2/source

Jan Holesovsky kendy at collabora.com
Fri May 13 20:48:56 UTC 2016


 include/sfx2/bindings.hxx        |    7 +-
 sfx2/source/control/bindings.cxx |   96 +++++++++++++--------------------------
 2 files changed, 36 insertions(+), 67 deletions(-)

New commits:
commit 702718d3b49780c165afe59d2a7de950209dcaa8
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Mon Oct 26 08:35:25 2015 +0100

    tdf#94236: Change Timer in SfxRequest to an Idle to improve feedback.
    
    This is one of the annoying (and very visible) Timers that should be an Idle
    in fact.  This affects things like repainting of the ruler in Writer, zoom in
    the statusbar, or changes in the toolbars.
    
    Whith this commit in, they should no longer be delayed, instead processed
    immediately when possible, which gives much better feedback to the user's
    actions.
    
    Change-Id: I17ee85b2c05fa0fcd72f10fc2f7a91b7c2398307

diff --git a/include/sfx2/bindings.hxx b/include/sfx2/bindings.hxx
index bbe5cc4..1daec4e 100644
--- a/include/sfx2/bindings.hxx
+++ b/include/sfx2/bindings.hxx
@@ -35,6 +35,7 @@
 
 //  forwards, typedefs, declarations
 
+class Idle;
 class SystemWindow;
 class SfxSlot;
 class SfxSlotServer;
@@ -44,7 +45,6 @@ class SfxItemSet;
 class SfxDispatcher;
 class SfxBindings;
 class SfxBindings_Impl;
-class Timer;
 class SfxWorkWindow;
 class SfxUnoControllerItem;
 struct SfxFoundCache_Impl;
@@ -131,8 +131,9 @@ private:
                             const SfxPoolItem *pItem,
                             SfxItemState eItemState );
     SAL_DLLPRIVATE SfxStateCache* GetStateCache( sal_uInt16 nId, sal_uInt16 *pPos);
-    DECL_DLLPRIVATE_LINK_TYPED( NextJob, Timer *, void );
-    SAL_DLLPRIVATE bool NextJob_Impl(Timer * pTimer);
+
+    DECL_DLLPRIVATE_LINK_TYPED(NextJob, Idle *, void);
+    SAL_DLLPRIVATE bool NextJob_Impl(Idle * pIdle);
 
 public:
                      SfxBindings();
diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx
index 98388a8..49f4b17 100644
--- a/sfx2/source/control/bindings.cxx
+++ b/sfx2/source/control/bindings.cxx
@@ -71,15 +71,8 @@ using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::util;
 
-static sal_uInt16 nTimeOut = 300;
-
-#define TIMEOUT_FIRST       nTimeOut
-#define TIMEOUT_UPDATING     20
-
 typedef std::unordered_map< sal_uInt16, bool > InvalidateSlotMap;
 
-
-
 typedef std::vector<SfxStateCache*> SfxStateCacheArr_Impl;
 
 struct SfxFoundCache_Impl
@@ -217,7 +210,7 @@ public:
     bool                    bAllMsgDirty;   //  Has a MessageServer been invalidated?
     bool                    bAllDirty;      // After InvalidateAll
     bool                    bCtrlReleased;  // while EnterRegistrations
-    AutoTimer               aTimer;         // for volatile Slots
+    Idle                    maIdle;         // for volatile Slots
     bool                    bInUpdate;      // for Assertions
     bool                    bInNextJob;     // for Assertions
     bool                    bFirstRound;    // First round in Update
@@ -252,9 +245,10 @@ SfxBindings::SfxBindings()
     // all caches are valid (no pending invalidate-job)
     // create the list of caches
     pImp->pCaches = new SfxStateCacheArr_Impl;
-    pImp->aTimer.SetTimeoutHdl( LINK(this, SfxBindings, NextJob) );
-}
 
+    pImp->maIdle.SetPriority(SchedulerPriority::MEDIUM);
+    pImp->maIdle.SetIdleHdl(LINK(this, SfxBindings, NextJob));
+}
 
 
 SfxBindings::~SfxBindings()
@@ -277,7 +271,9 @@ SfxBindings::~SfxBindings()
 
     ENTERREGISTRATIONS();
 
-    pImp->aTimer.Stop();
+    pImp->maIdle.SetIdleHdl(Link<Idle *, void>());
+    pImp->maIdle.Stop();
+
     DeleteControllers_Impl();
 
     // Delete Caches
@@ -702,11 +698,11 @@ void SfxBindings::InvalidateAll
         (*pImp->pCaches)[n]->Invalidate(bWithMsg);
 
     pImp->nMsgPos = 0;
+
     if ( !nRegLevel )
     {
-        pImp->aTimer.Stop();
-        pImp->aTimer.SetTimeout(TIMEOUT_FIRST);
-        pImp->aTimer.Start();
+        pImp->maIdle.Stop();
+        pImp->maIdle.Start();
     }
 }
 
@@ -754,11 +750,11 @@ void SfxBindings::Invalidate
 
     // if not enticed to start update timer
     pImp->nMsgPos = 0;
+
     if ( !nRegLevel )
     {
-        pImp->aTimer.Stop();
-        pImp->aTimer.SetTimeout(TIMEOUT_FIRST);
-        pImp->aTimer.Start();
+        pImp->maIdle.Stop();
+        pImp->maIdle.Start();
     }
 }
 
@@ -808,11 +804,11 @@ void SfxBindings::InvalidateShell
                 pCache->Invalidate(false);
         }
         pImp->nMsgPos = 0;
+
         if ( !nRegLevel )
         {
-            pImp->aTimer.Stop();
-            pImp->aTimer.SetTimeout(TIMEOUT_FIRST);
-            pImp->aTimer.Start();
+            pImp->maIdle.Stop();
+            pImp->maIdle.Start();
             pImp->bFirstRound = true;
             pImp->nFirstShell = nLevel;
         }
@@ -845,11 +841,11 @@ void SfxBindings::Invalidate
     {
         pCache->Invalidate(false);
         pImp->nMsgPos = std::min(GetSlotPos(nId), pImp->nMsgPos);
+
         if ( !nRegLevel )
         {
-            pImp->aTimer.Stop();
-            pImp->aTimer.SetTimeout(TIMEOUT_FIRST);
-            pImp->aTimer.Start();
+            pImp->maIdle.Stop();
+            pImp->maIdle.Start();
         }
     }
 }
@@ -882,11 +878,11 @@ void SfxBindings::Invalidate
             return;
 
         pImp->nMsgPos = std::min(GetSlotPos(nId), pImp->nMsgPos);
+
         if ( !nRegLevel )
         {
-            pImp->aTimer.Stop();
-            pImp->aTimer.SetTimeout(TIMEOUT_FIRST);
-            pImp->aTimer.Start();
+            pImp->maIdle.Stop();
+            pImp->maIdle.Start();
         }
     }
 }
@@ -1544,12 +1540,12 @@ void SfxBindings::UpdateControllers_Impl
     }
 }
 
-IMPL_LINK_TYPED( SfxBindings, NextJob, Timer *, pTimer, void )
+IMPL_LINK_TYPED(SfxBindings, NextJob, Idle *, pIdle, void)
 {
-    NextJob_Impl(pTimer);
+    NextJob_Impl(pIdle);
 }
 
-bool SfxBindings::NextJob_Impl(Timer * pTimer)
+bool SfxBindings::NextJob_Impl(Idle * pIdle)
 {
 #ifdef DBG_UTIL
     // on Windows very often C++ Exceptions (GPF etc.) are caught by MSVCRT
@@ -1557,16 +1553,9 @@ bool SfxBindings::NextJob_Impl(Timer * pTimer)
     try
     {
 #endif
-    const unsigned MAX_INPUT_DELAY = 200;
 
     DBG_ASSERT( pImp->pCaches != nullptr, "SfxBindings not initialized" );
 
-    if ( Application::GetLastInputInterval() < MAX_INPUT_DELAY && pTimer )
-    {
-        pImp->aTimer.SetTimeout(TIMEOUT_UPDATING);
-        return true;
-    }
-
     SfxApplication *pSfxApp = SfxGetpApp();
 
     if( pDispatcher )
@@ -1591,10 +1580,9 @@ bool SfxBindings::NextJob_Impl(Timer * pTimer)
     }
 
     pImp->bAllDirty = false;
-    pImp->aTimer.SetTimeout(TIMEOUT_UPDATING);
 
     // at least 10 loops and further if more jobs are available but no input
-    bool bPreEmptive = pTimer && !pSfxApp->Get_Impl()->nInReschedule;
+    bool bPreEmptive = pIdle && !pSfxApp->Get_Impl()->nInReschedule;
     sal_uInt16 nLoops = 10;
     pImp->bInNextJob = true;
     const sal_uInt16 nCount = pImp->pCaches->size();
@@ -1639,7 +1627,7 @@ bool SfxBindings::NextJob_Impl(Timer * pTimer)
 
     pImp->nMsgPos = 0;
 
-    pImp->aTimer.Stop();
+    pImp->maIdle.Stop();
 
     // Update round is finished
     pImp->bInNextJob = false;
@@ -1686,7 +1674,7 @@ sal_uInt16 SfxBindings::EnterRegistrations(const char *pFile, int nLine)
     if ( ++nRegLevel == 1 )
     {
         // stop background-processing
-        pImp->aTimer.Stop();
+        pImp->maIdle.Stop();
 
         // flush the cache
         pImp->nCachedFunc1 = 0;
@@ -1754,9 +1742,8 @@ void SfxBindings::LeaveRegistrations( sal_uInt16 nLevel, const char *pFile, int
             return;
         if ( pImp->pCaches && !pImp->pCaches->empty() )
         {
-            pImp->aTimer.Stop();
-            pImp->aTimer.SetTimeout(TIMEOUT_FIRST);
-            pImp->aTimer.Start();
+            pImp->maIdle.Stop();
+            pImp->maIdle.Start();
         }
     }
 
@@ -1852,7 +1839,7 @@ void SfxBindings::StartUpdate_Impl( bool bComplete )
 
     if ( !bComplete )
         // Update may be interrupted
-        NextJob_Impl(&pImp->aTimer);
+        NextJob_Impl(&pImp->maIdle);
     else
         // Update all slots in a row
         NextJob_Impl(nullptr);
commit fbd9ed91192aafa32723d0257b5bcfa7ceb5ff90
Author: Noel Grandin <noel at peralex.com>
Date:   Thu Feb 4 12:47:08 2016 +0200

    remove unused SlotId/Volatile from .SDI files
    
    Change-Id: I29f039c2fec8433fa062c603b64afffa60e7b0d0

diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx
index 5d13693..98388a8 100644
--- a/sfx2/source/control/bindings.cxx
+++ b/sfx2/source/control/bindings.cxx
@@ -75,7 +75,6 @@ static sal_uInt16 nTimeOut = 300;
 
 #define TIMEOUT_FIRST       nTimeOut
 #define TIMEOUT_UPDATING     20
-#define TIMEOUT_IDLE       2500
 
 typedef std::unordered_map< sal_uInt16, bool > InvalidateSlotMap;
 
@@ -505,9 +504,7 @@ void SfxBindings::Update
             {
                 // Query Status
                 const SfxSlotServer* pMsgServer = pDispatcher ? pCache->GetSlotServer(*pDispatcher, pImp->xProv) : nullptr;
-                if ( !pCache->IsControllerDirty() &&
-                    ( !pMsgServer ||
-                    !pMsgServer->GetSlot()->IsMode(SfxSlotMode::VOLATILE) ) )
+                if ( !pCache->IsControllerDirty() )
                 {
                     pImp->bInUpdate = false;
                     InvalidateSlotsInMap_Impl();
@@ -1642,23 +1639,7 @@ bool SfxBindings::NextJob_Impl(Timer * pTimer)
 
     pImp->nMsgPos = 0;
 
-    // check for volatile slots
-    bool bVolatileSlotsPresent = false;
-    for ( sal_uInt16 n = 0; n < nCount; ++n )
-    {
-        SfxStateCache* pCache = (*pImp->pCaches)[n];
-        const SfxSlotServer *pSlotServer = pCache->GetSlotServer(*pDispatcher, pImp->xProv);
-        if ( pSlotServer && pSlotServer->GetSlot()->IsMode(SfxSlotMode::VOLATILE) )
-        {
-            pCache->Invalidate(false);
-            bVolatileSlotsPresent = true;
-        }
-    }
-
-    if (bVolatileSlotsPresent)
-        pImp->aTimer.SetTimeout(TIMEOUT_IDLE);
-    else
-        pImp->aTimer.Stop();
+    pImp->aTimer.Stop();
 
     // Update round is finished
     pImp->bInNextJob = false;


More information about the Libreoffice-commits mailing list