[Libreoffice-commits] core.git: 6 commits - chart2/source editeng/source include/svx include/vcl offapi/com reportdesign/source svx/inc svx/source toolkit/source vcl/inc vcl/qa vcl/source

Michael Meeks michael.meeks at collabora.com
Wed Nov 5 12:59:24 PST 2014


 chart2/source/controller/drawinglayer/DrawViewWrapper.cxx |    4 
 editeng/source/editeng/impedit.hxx                        |    2 
 editeng/source/editeng/impedit2.cxx                       |    2 
 include/svx/svdpntv.hxx                                   |    2 
 include/vcl/timer.hxx                                     |   42 ++++
 offapi/com/sun/star/awt/XToolkitExperimental.idl          |    5 
 reportdesign/source/ui/dlg/Navigator.cxx                  |   37 +--
 svx/inc/sdr/overlay/overlaymanagerbuffered.hxx            |    2 
 svx/inc/svdibrow.hxx                                      |    2 
 svx/source/sdr/overlay/overlaymanagerbuffered.cxx         |   10 -
 svx/source/svdraw/svdibrow.cxx                            |    2 
 svx/source/svdraw/svdpntv.cxx                             |   10 -
 toolkit/source/awt/vclxtoolkit.cxx                        |    9 
 vcl/inc/window.h                                          |    4 
 vcl/qa/cppunit/timer.cxx                                  |   29 +++
 vcl/source/app/timer.cxx                                  |  131 ++++++++++++--
 vcl/source/window/paint.cxx                               |   16 -
 vcl/source/window/window.cxx                              |   14 -
 vcl/source/window/winproc.cxx                             |    2 
 19 files changed, 255 insertions(+), 70 deletions(-)

New commits:
commit 42019e2f25235f69ac5f8efdabedd99fca32f1a1
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Wed Nov 5 20:51:21 2014 +0000

    idle: unit test.
    
    Change-Id: Ie48fb4260bf580010715777bc63974e4d635aed8

diff --git a/vcl/qa/cppunit/timer.cxx b/vcl/qa/cppunit/timer.cxx
index a086000..4e2bb56 100644
--- a/vcl/qa/cppunit/timer.cxx
+++ b/vcl/qa/cppunit/timer.cxx
@@ -79,13 +79,31 @@ void TimerTest::testWatchdog()
 }
 #endif
 
+// --------------------------------------------------------------------
 
-void TimerTest::testIdle()
+class IdleBool : public Idle
 {
-//    Add an idle handler
-//        forcible execute that lot first ... and ...
+    bool &mrBool;
+public:
+    IdleBool( bool &rBool ) :
+        Idle( VCL_IDLE_PRIORITY_LOWEST ), mrBool( rBool )
+    {
+        Start();
+        mrBool = false;
+    }
+    virtual void Timeout() SAL_OVERRIDE
+    {
+        mrBool = true;
+        Application::EndYield();
+    }
+};
 
-// Error ...
+void TimerTest::testIdle()
+{
+    bool bTriggered = false;
+    IdleBool aTest( bTriggered );
+    Timer::ProcessAllIdleHandlers();
+    CPPUNIT_ASSERT_MESSAGE("watchdog triggered", bTriggered);
 }
 
 // --------------------------------------------------------------------
commit 4907c32bb8c51a47e379ca75abeaaca6e3ce248e
Author: László Németh <nemeth at numbertext.org>
Date:   Wed Nov 5 19:43:09 2014 +0100

    overlayermanagerbuffered: timer to idle
    
    Change-Id: I40d19b20259f2d2dada32467efe4defe3ed4b07c

diff --git a/svx/inc/sdr/overlay/overlaymanagerbuffered.hxx b/svx/inc/sdr/overlay/overlaymanagerbuffered.hxx
index 6bcd68f..7379597 100644
--- a/svx/inc/sdr/overlay/overlaymanagerbuffered.hxx
+++ b/svx/inc/sdr/overlay/overlaymanagerbuffered.hxx
@@ -42,7 +42,7 @@ namespace sdr
             VirtualDevice                           maOutputBufferDevice;
 
             // Timer for buffering
-            Timer                                   maBufferTimer;
+            Idle                                    maBufferIdle;
 
             // Range for buffering (in pixel to be independent from mapMode)
             basegfx::B2IRange                       maBufferRememberedRangePixel;
diff --git a/svx/source/sdr/overlay/overlaymanagerbuffered.cxx b/svx/source/sdr/overlay/overlaymanagerbuffered.cxx
index 175e12e..dde69b3 100644
--- a/svx/source/sdr/overlay/overlaymanagerbuffered.cxx
+++ b/svx/source/sdr/overlay/overlaymanagerbuffered.cxx
@@ -257,7 +257,7 @@ namespace sdr
             rtl::Reference<OverlayManager> xRef(this);
 
             // stop timer
-            maBufferTimer.Stop();
+            maBufferIdle.Stop();
 
             if(!maBufferRememberedRangePixel.isEmpty())
             {
@@ -428,8 +428,8 @@ namespace sdr
             mbRefreshWithPreRendering(bRefreshWithPreRendering)
         {
             // Init timer
-            maBufferTimer.SetTimeout(1);
-            maBufferTimer.SetTimeoutHdl(LINK(this, OverlayManagerBuffered, ImpBufferTimerHandler));
+            maBufferIdle.SetPriority( VCL_IDLE_PRIORITY_HIGH );
+            maBufferIdle.SetTimeoutHdl(LINK(this, OverlayManagerBuffered, ImpBufferTimerHandler));
         }
 
         rtl::Reference<OverlayManager> OverlayManagerBuffered::create(
@@ -443,7 +443,7 @@ namespace sdr
         OverlayManagerBuffered::~OverlayManagerBuffered()
         {
             // Clear timer
-            maBufferTimer.Stop();
+            maBufferIdle.Stop();
 
             if(!maBufferRememberedRangePixel.isEmpty())
             {
@@ -493,7 +493,7 @@ namespace sdr
             {
                 // buffered output, do not invalidate but use the timer
                 // to trigger a timer event for refresh
-                maBufferTimer.Start();
+                maBufferIdle.Start();
 
                 // add the discrete range to the remembered region
                 // #i75163# use double precision and floor/ceil rounding to get overlapped pixel region, even
commit a1c4d878ef6247aa239035a8ffc71a4737cf2995
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Wed Nov 5 18:01:50 2014 +0000

    idle: allow processing pending handlers remotely.
    
    Change-Id: Idb835f1fb04a3f9ca2430781cabeb785285ccf7b

diff --git a/offapi/com/sun/star/awt/XToolkitExperimental.idl b/offapi/com/sun/star/awt/XToolkitExperimental.idl
index 8cbd88d..349c205 100644
--- a/offapi/com/sun/star/awt/XToolkitExperimental.idl
+++ b/offapi/com/sun/star/awt/XToolkitExperimental.idl
@@ -41,6 +41,11 @@ interface XToolkitExperimental : XToolkit2
                                                                         [in] long XOffset,
                                                                         [in] long YOffset,
                                                                         [in] hyper AddressOfMemoryBufferForSharedArrayWrapper );
+
+  /** Process all pending idle events
+   */
+  void processEventsToIdle();
+
 };
 
 }; }; }; };
diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx
index 4fd8d23..932ac88 100644
--- a/toolkit/source/awt/vclxtoolkit.cxx
+++ b/toolkit/source/awt/vclxtoolkit.cxx
@@ -196,6 +196,8 @@ public:
     // css::awt::XToolkitExperimental
     css::uno::Reference< css::awt::XDevice >      SAL_CALL createScreenCompatibleDeviceUsingBuffer( sal_Int32 Width, sal_Int32 Height, sal_Int32 ScaleNumerator, sal_Int32 ScaleDenominator, sal_Int32 XOffset, sal_Int32 YOffset, sal_Int64 AddressOfMemoryBufferForSharedArrayWrapper ) throw
 (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+    virtual void SAL_CALL processEventsToIdle()
+        throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
 
     // css::awt::XToolkit
     css::uno::Reference< css::awt::XWindowPeer >  SAL_CALL getDesktopWindow(  ) throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
@@ -1884,6 +1886,13 @@ void SAL_CALL VCLXToolkit::reschedule()
     Application::Reschedule(true);
 }
 
+void SAL_CALL VCLXToolkit::processEventsToIdle()
+    throw (::com::sun::star::uno::RuntimeException, std::exception)
+{
+    SolarMutexGuard aSolarGuard;
+    Timer::ProcessAllIdleHandlers();
+}
+
 }
 
 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
commit a74cb8c392a057899c8aafa74c90664b4f6270b9
Author: László Németh <nemeth at numbertext.org>
Date:   Wed Nov 5 17:57:15 2014 +0100

    idle: implement ProcessAllIdleHandlers.
    
    It is often useful to flush all pending idle / GUI work for testing
    and/or profiling - so make that easy to do with this new method.
    Also tag idle Timers with a boolean, for ease of use.
    
    Change-Id: I57e883be8fe8637b3715008e8074d0fa258ca0c3

diff --git a/include/vcl/timer.hxx b/include/vcl/timer.hxx
index 10dd3fc..11e8f3f 100644
--- a/include/vcl/timer.hxx
+++ b/include/vcl/timer.hxx
@@ -35,8 +35,11 @@ protected:
     sal_uLong       mnTimeout;
     bool            mbActive;
     bool            mbAuto;
+    bool            mbIdle;
     Link            maTimeoutHdl;
 
+    friend struct ImplTimerData;
+
 public:
                     Timer();
                     Timer( const Timer& rTimer );
@@ -60,6 +63,9 @@ public:
 
     static void ImplDeInitTimer();
     static void ImplTimerCallbackProc();
+
+    /// Process all pending idle tasks ahead of time in priority order.
+    static void ProcessAllIdleHandlers();
 };
 
 /// An auto-timer is a multi-shot timer re-emitting itself at
diff --git a/vcl/qa/cppunit/timer.cxx b/vcl/qa/cppunit/timer.cxx
index 84dd40a..a086000 100644
--- a/vcl/qa/cppunit/timer.cxx
+++ b/vcl/qa/cppunit/timer.cxx
@@ -46,6 +46,7 @@ class TimerTest : public test::BootstrapFixture
 public:
     TimerTest() : BootstrapFixture(true, false) {}
 
+    void testIdle();
 #ifdef TEST_WATCHDOG
     void testWatchdog();
 #endif
@@ -55,6 +56,7 @@ public:
     void testSlowTimerCallback();
 
     CPPUNIT_TEST_SUITE(TimerTest);
+    CPPUNIT_TEST(testIdle);
 #ifdef TEST_WATCHDOG
     CPPUNIT_TEST(testWatchdog);
 #endif
@@ -77,6 +79,15 @@ void TimerTest::testWatchdog()
 }
 #endif
 
+
+void TimerTest::testIdle()
+{
+//    Add an idle handler
+//        forcible execute that lot first ... and ...
+
+// Error ...
+}
+
 // --------------------------------------------------------------------
 
 class TimerBool : public Timer
diff --git a/vcl/source/app/timer.cxx b/vcl/source/app/timer.cxx
index 5f706ab..529c8b5 100644
--- a/vcl/source/app/timer.cxx
+++ b/vcl/source/app/timer.cxx
@@ -36,6 +36,50 @@ struct ImplTimerData
     sal_uLong       mnTimerUpdate;  // TimerCallbackProcs on stack
     bool            mbDelete;       // Was timer deleted during Update()?
     bool            mbInTimeout;    // Are we in a timeout handler?
+
+    void Invoke()
+    {
+        if (mbDelete || mbInTimeout )
+            return;
+
+        // if no AutoTimer than stop
+        if ( !mpTimer->mbAuto )
+        {
+            mbDelete = true;
+            mpTimer->mbActive = false;
+        }
+
+        // invoke it
+        mbInTimeout = true;
+        mpTimer->Timeout();
+        mbInTimeout = false;
+    }
+
+    sal_uLong GetDeadline()
+    {
+        return mnUpdateTime + mpTimer->mnTimeout;
+    }
+    static ImplTimerData *GetFirstIdle()
+    {
+        ImplSVData*     pSVData = ImplGetSVData();
+        ImplTimerData *pMostUrgent = NULL;
+
+        for ( ImplTimerData *p = pSVData->mpFirstTimerData; p; p = p->mpNext )
+        {
+            if ( !p->mpTimer || p->mbDelete || !p->mpTimer->mbIdle )
+                continue;
+            if (!pMostUrgent)
+                pMostUrgent = p;
+            else
+            {
+                // Find the highest priority one somehow.
+                if ( p->GetDeadline() < pMostUrgent->GetDeadline() )
+                    pMostUrgent = p;
+            }
+        }
+
+        return pMostUrgent;
+    }
 };
 
 void Timer::ImplDeInitTimer()
@@ -110,22 +154,12 @@ void Timer::ImplTimerCallbackProc()
              !pTimerData->mbDelete && !pTimerData->mbInTimeout )
         {
             // time has expired
-            if ( (pTimerData->mnUpdateTime+pTimerData->mpTimer->mnTimeout) <= nTime )
+            if ( pTimerData->GetDeadline() <= nTime )
             {
                 // set new update time
                 pTimerData->mnUpdateTime = nTime;
 
-                // if no AutoTimer than stop
-                if ( !pTimerData->mpTimer->mbAuto )
-                {
-                    pTimerData->mpTimer->mbActive = false;
-                    pTimerData->mbDelete = true;
-                }
-
-                // call Timeout
-                pTimerData->mbInTimeout = true;
-                pTimerData->mpTimer->Timeout();
-                pTimerData->mbInTimeout = false;
+                pTimerData->Invoke();
             }
         }
 
@@ -197,11 +231,22 @@ void Timer::ImplTimerCallbackProc()
     pSVData->mbNotAllTimerCalled = false;
 }
 
+void Timer::ProcessAllIdleHandlers()
+{
+    // process all pending Idle timers
+    while (ImplTimerData* pTimerData =
+                ImplTimerData::GetFirstIdle())
+    {
+        pTimerData->Invoke();
+    }
+}
+
 Timer::Timer():
     mpTimerData(NULL),
     mnTimeout(1),
     mbActive(false),
-    mbAuto(false)
+    mbAuto(false),
+    mbIdle(false)
 {
 }
 
@@ -210,6 +255,7 @@ Timer::Timer( const Timer& rTimer ):
     mnTimeout(rTimer.mnTimeout),
     mbActive(false),
     mbAuto(false),
+    mbIdle(false),
     maTimeoutHdl(rTimer.maTimeoutHdl)
 {
     if ( rTimer.IsActive() )
@@ -339,12 +385,14 @@ AutoTimer& AutoTimer::operator=( const AutoTimer& rTimer )
 Idle::Idle()
     : Timer()
 {
+    mbIdle = true;
     SetPriority(VCL_IDLE_PRIORITY_LOWEST);
 }
 
 Idle::Idle( IdlePriority ePriority )
     : Timer()
 {
+    mbIdle = true;
     SetPriority( ePriority );
 }
 
commit edabf0c5c1e7a74262e4e4e04da9760ede15f86d
Author: Jennifer Liebel <jliebel94 at gmail.com>
Date:   Tue Nov 4 11:51:15 2014 +0000

    changed some timer to idle
    
    Change-Id: Ifd5e2d87732d3e537c7754e52be24ef768ecb8d9

diff --git a/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx b/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx
index 63d093f..0870786 100644
--- a/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx
+++ b/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx
@@ -154,8 +154,8 @@ void DrawViewWrapper::ReInit()
 
 DrawViewWrapper::~DrawViewWrapper()
 {
-    aComeBackTimer.Stop();//@todo this should be done in destructor of base class
-    UnmarkAllObj();//necessary to aavoid a paint call during the destructor hierarchy
+    aComeBackIdle.Stop();//@todo this should be done in destructor of base class
+    UnmarkAllObj();//necessary to avoid a paint call during the destructor hierarchy
 }
 
 SdrPageView* DrawViewWrapper::GetPageView() const
diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx
index 68ef6ed..9c44b36 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -182,7 +182,7 @@ struct FormatterFontMetric
     sal_uInt16  GetHeight() const       { return nMaxAscent+nMaxDescent; }
 };
 
-class IdleFormattter : public Timer
+class IdleFormattter : public Idle
 {
 private:
     EditView*   pView;
diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index 9a46f58..27c2ad9 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -145,7 +145,7 @@ ImpEditEngine::ImpEditEngine( EditEngine* pEE, SfxItemPool* pItemPool ) :
     aStatusTimer.SetTimeout( 200 );
     aStatusTimer.SetTimeoutHdl( LINK( this, ImpEditEngine, StatusTimerHdl ) );
 
-    aIdleFormatter.SetTimeout( 5 );
+    aIdleFormatter.SetPriority( VCL_IDLE_PRIORITY_REPAINT );
     aIdleFormatter.SetTimeoutHdl( LINK( this, ImpEditEngine, IdleFormatHdl ) );
 
     aOnlineSpellTimer.SetTimeout( 100 );
diff --git a/include/svx/svdpntv.hxx b/include/svx/svdpntv.hxx
index a7788dc..21d4474 100644
--- a/include/svx/svdpntv.hxx
+++ b/include/svx/svdpntv.hxx
@@ -152,7 +152,7 @@ protected:
     SdrDragStat                 aDragStat;
     Rectangle                   aMaxWorkArea;
     SfxItemSet                  aDefaultAttr;
-    Timer                       aComeBackTimer;
+    Idle                        aComeBackIdle;
 
     SdrAnimationMode            eAnimationMode;
 
diff --git a/reportdesign/source/ui/dlg/Navigator.cxx b/reportdesign/source/ui/dlg/Navigator.cxx
index 13c9dad..d36b761 100644
--- a/reportdesign/source/ui/dlg/Navigator.cxx
+++ b/reportdesign/source/ui/dlg/Navigator.cxx
@@ -423,29 +423,24 @@ IMPL_LINK_NOARG(NavigatorTree, OnDropActionTimer)
 
     switch ( m_aDropActionType )
     {
-    case DA_EXPANDNODE:
-    {
-        SvTreeListEntry* pToExpand = GetEntry(m_aTimerTriggered);
-        if (pToExpand && (GetChildCount(pToExpand) > 0) &&  !IsExpanded(pToExpand))
-            // tja, eigentlich muesste ich noch testen, ob die Node nicht schon expandiert ist, aber ich
-            // habe dazu weder in den Basisklassen noch im Model eine Methode gefunden ...
-            // aber ich denke, die BK sollte es auch so vertragen
-            Expand(pToExpand);
-
-        // nach dem Expand habe ich im Gegensatz zum Scrollen natuerlich nix mehr zu tun
-        m_aDropActionTimer.Stop();
-    }
-    break;
-
-    case DA_SCROLLUP :
-        ScrollOutputArea( 1 );
-        m_nTimerCounter = DROP_ACTION_TIMER_SCROLL_TICKS;
+        case DA_EXPANDNODE:
+        {
+            SvTreeListEntry* pToExpand = GetEntry(m_aTimerTriggered);
+            if (pToExpand && (GetChildCount(pToExpand) > 0) &&  !IsExpanded(pToExpand))
+                Expand(pToExpand);
+            m_aDropActionTimer.Stop();
+        }
         break;
 
-    case DA_SCROLLDOWN :
-        ScrollOutputArea( -1 );
-        m_nTimerCounter = DROP_ACTION_TIMER_SCROLL_TICKS;
-        break;
+        case DA_SCROLLUP :
+            ScrollOutputArea( 1 );
+            m_nTimerCounter = DROP_ACTION_TIMER_SCROLL_TICKS;
+            break;
+
+        case DA_SCROLLDOWN :
+            ScrollOutputArea( -1 );
+            m_nTimerCounter = DROP_ACTION_TIMER_SCROLL_TICKS;
+            break;
 
     }
 
diff --git a/svx/inc/svdibrow.hxx b/svx/inc/svdibrow.hxx
index 52965b1..f4c4a0f 100644
--- a/svx/inc/svdibrow.hxx
+++ b/svx/inc/svdibrow.hxx
@@ -114,7 +114,7 @@ public:
 class SdrView;
 
 class SdrItemBrowser: public _SdrItemBrowserWindow {
-    Timer aIdleTimer;
+    Idle aIdleTimer;
     SdrView* pView;
     bool bDirty;
 private:
diff --git a/svx/source/svdraw/svdibrow.cxx b/svx/source/svdraw/svdibrow.cxx
index 2123500..2694111 100644
--- a/svx/source/svdraw/svdibrow.cxx
+++ b/svx/source/svdraw/svdibrow.cxx
@@ -1107,7 +1107,7 @@ void SdrItemBrowser::SetDirty()
 {
     if (!bDirty) {
         bDirty = true;
-        aIdleTimer.SetTimeout(1);
+        aIdleTimer.SetPriority(VCL_IDLE_PRIORITY_HIGH);
         aIdleTimer.Start();
     }
 }
diff --git a/svx/source/svdraw/svdpntv.cxx b/svx/source/svdraw/svdpntv.cxx
index e633106..4ea0087 100644
--- a/svx/source/svdraw/svdpntv.cxx
+++ b/svx/source/svdraw/svdpntv.cxx
@@ -190,8 +190,8 @@ void SdrPaintView::ImpClearVars()
     pDefaultStyleSheet=NULL;
     bSomeObjChgdFlag=false;
     nGraphicManagerDrawMode = GRFMGR_DRAW_STANDARD;
-    aComeBackTimer.SetTimeout(1);
-    aComeBackTimer.SetTimeoutHdl(LINK(this,SdrPaintView,ImpComeBackHdl));
+    aComeBackIdle.SetPriority(VCL_IDLE_PRIORITY_HIGH);
+    aComeBackIdle.SetTimeoutHdl(LINK(this,SdrPaintView,ImpComeBackHdl));
 
     if (pMod)
         SetDefaultStyleSheet(pMod->GetDefaultStyleSheet(), true);
@@ -269,7 +269,7 @@ void SdrPaintView::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
             if (eKind==HINT_OBJCHG || eKind==HINT_OBJINSERTED || eKind==HINT_OBJREMOVED) {
                 if (bObjChg) {
                     bSomeObjChgdFlag=true;
-                    aComeBackTimer.Start();
+                    aComeBackIdle.Start();
                 }
             }
             if (eKind==HINT_PAGEORDERCHG) {
@@ -309,8 +309,8 @@ void SdrPaintView::FlushComeBackTimer() const
 {
     if (bSomeObjChgdFlag) {
         // casting to nonconst
-        ((SdrPaintView*)this)->ImpComeBackHdl(&((SdrPaintView*)this)->aComeBackTimer);
-        ((SdrPaintView*)this)->aComeBackTimer.Stop();
+        ((SdrPaintView*)this)->ImpComeBackHdl(&((SdrPaintView*)this)->aComeBackIdle);
+        ((SdrPaintView*)this)->aComeBackIdle.Stop();
     }
 }
 
commit d6e89e7516271d246b255ec5ebc752713da3dfd5
Author: Tobias Madl <tobias.madl.dev at gmail.com>
Date:   Thu Oct 30 20:07:59 2014 +0100

    Basic Idle handler implementation
    
    An idle handler will ultimately be a zero time timeout with
    prioritisation layered on top of that.
    
    Change-Id: I3f0802d5001172fc7b8409274bc5a3632e5dad34

diff --git a/include/vcl/timer.hxx b/include/vcl/timer.hxx
index d3ebe1a..10dd3fc 100644
--- a/include/vcl/timer.hxx
+++ b/include/vcl/timer.hxx
@@ -73,6 +73,42 @@ public:
     AutoTimer&      operator=( const AutoTimer& rTimer );
 };
 
+enum IdlePriority {
+    VCL_IDLE_PRIORITY_HIGHEST, // -> 0ms
+    VCL_IDLE_PRIORITY_HIGH,    // -> 1ms
+    VCL_IDLE_PRIORITY_REPAINT, // -> 30ms
+    VCL_IDLE_PRIORITY_RESIZE,  // -> 50ms
+    VCL_IDLE_PRIORITY_MEDIUM,  // -> 50ms
+    VCL_IDLE_PRIORITY_LOW,     // -> 100ms
+    VCL_IDLE_PRIORITY_LOWER,   // -> 200ms
+    VCL_IDLE_PRIORITY_LOWEST   // -> 400ms
+};
+
+
+// To port from Timer -> Idle switch class name,
+// s/Timeout/DoIdle/ etc. and select priority
+class VCL_DLLPUBLIC Idle : public Timer
+{
+ public:
+    Idle();
+    Idle( IdlePriority ePriority );
+    virtual ~Idle();
+
+    void SetPriority( IdlePriority ePriority );
+
+    /// Make it possible to associate a callback with this idle handler
+    /// of course, you can also sub-class and override 'DoIdle'
+    void            SetIdleHdl( const Link& rLink ) { SetTimeoutHdl( rLink ); }
+    const Link&     GetIdleHdl() const              { return GetTimeoutHdl(); }
+
+    void            Start() { Timer::Start(); }
+    void            Stop()  { Timer::Stop();  }
+
+    virtual void    DoIdle();
+
+    virtual void    Timeout() SAL_OVERRIDE { DoIdle(); }
+};
+
 #endif // INCLUDED_VCL_TIMER_HXX
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/window.h b/vcl/inc/window.h
index 53d077f..2b2082e 100644
--- a/vcl/inc/window.h
+++ b/vcl/inc/window.h
@@ -127,8 +127,8 @@ struct ImplOverlapData
 
 struct ImplFrameData
 {
-    Timer               maPaintTimer;           //< paint timer
-    Timer               maResizeTimer;          //< resize timer
+    Idle                maPaintIdle;            //< paint idle handler
+    Idle                maResizeIdle;          //< resize timer
     InputContext        maOldInputContext;      //< last set Input Context
     vcl::Window*        mpNextFrame;            //< next frame window
     vcl::Window*        mpFirstOverlap;         //< first overlap vcl::Window
diff --git a/vcl/source/app/timer.cxx b/vcl/source/app/timer.cxx
index ecbfa74..5f706ab 100644
--- a/vcl/source/app/timer.cxx
+++ b/vcl/source/app/timer.cxx
@@ -336,4 +336,61 @@ AutoTimer& AutoTimer::operator=( const AutoTimer& rTimer )
     return *this;
 }
 
+Idle::Idle()
+    : Timer()
+{
+    SetPriority(VCL_IDLE_PRIORITY_LOWEST);
+}
+
+Idle::Idle( IdlePriority ePriority )
+    : Timer()
+{
+    SetPriority( ePriority );
+}
+
+void Idle::SetPriority( IdlePriority ePriority )
+{
+    sal_uLong nTimeoutMS = 0;
+
+    // Ultimately this will just be a sort key in a work queue.
+    switch (ePriority) {
+    case VCL_IDLE_PRIORITY_HIGHEST:
+        nTimeoutMS = 0;
+        break;
+    case VCL_IDLE_PRIORITY_HIGH:
+        nTimeoutMS = 1;
+        break;
+    case VCL_IDLE_PRIORITY_REPAINT:
+        nTimeoutMS = 30;
+        break;
+    case VCL_IDLE_PRIORITY_RESIZE:
+        nTimeoutMS = 50;
+        break;
+    case VCL_IDLE_PRIORITY_MEDIUM:
+        nTimeoutMS = 50;
+        break;
+    case VCL_IDLE_PRIORITY_LOW:
+        nTimeoutMS = 100;
+        break;
+    case VCL_IDLE_PRIORITY_LOWER:
+        nTimeoutMS = 200;
+        break;
+    case VCL_IDLE_PRIORITY_LOWEST:
+    default:
+        nTimeoutMS = 400;
+        break;
+    }
+    SetTimeout( nTimeoutMS );
+}
+
+void Idle::DoIdle()
+{
+    maTimeoutHdl.Call( this );
+}
+
+
+Idle::~Idle()
+{
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/window/paint.cxx b/vcl/source/window/paint.cxx
index ce10aba..7ec329c 100644
--- a/vcl/source/window/paint.cxx
+++ b/vcl/source/window/paint.cxx
@@ -283,8 +283,8 @@ void Window::ImplCallOverlapPaint()
 
 void Window::ImplPostPaint()
 {
-    if ( !ImplDoTiledRendering() && !mpWindowImpl->mpFrameData->maPaintTimer.IsActive() )
-        mpWindowImpl->mpFrameData->maPaintTimer.Start();
+    if ( !ImplDoTiledRendering() && !mpWindowImpl->mpFrameData->maPaintIdle.IsActive() )
+        mpWindowImpl->mpFrameData->maPaintIdle.Start();
 }
 
 IMPL_LINK_NOARG(Window, ImplHandlePaintHdl)
@@ -292,14 +292,14 @@ IMPL_LINK_NOARG(Window, ImplHandlePaintHdl)
     // save paint events until layout is done
     if (!ImplDoTiledRendering() && IsSystemWindow() && static_cast<const SystemWindow*>(this)->hasPendingLayout())
     {
-        mpWindowImpl->mpFrameData->maPaintTimer.Start();
+        mpWindowImpl->mpFrameData->maPaintIdle.Start();
         return 0;
     }
 
     // save paint events until resizing is done
     if( !ImplDoTiledRendering() &&
-        mpWindowImpl->mbFrame && mpWindowImpl->mpFrameData->maResizeTimer.IsActive() )
-        mpWindowImpl->mpFrameData->maPaintTimer.Start();
+        mpWindowImpl->mbFrame && mpWindowImpl->mpFrameData->maResizeIdle.IsActive() )
+        mpWindowImpl->mpFrameData->maPaintIdle.Start();
     else if ( mpWindowImpl->mbReallyVisible )
         ImplCallOverlapPaint();
     return 0;
@@ -314,10 +314,10 @@ IMPL_LINK_NOARG(Window, ImplHandleResizeTimerHdl)
         {
             ImplHandlePaintHdl(NULL);
         }
-        else if( mpWindowImpl->mpFrameData->maPaintTimer.IsActive() )
+        else if( mpWindowImpl->mpFrameData->maPaintIdle.IsActive() )
         {
-            mpWindowImpl->mpFrameData->maPaintTimer.Stop();
-            mpWindowImpl->mpFrameData->maPaintTimer.GetTimeoutHdl().Call( NULL );
+            mpWindowImpl->mpFrameData->maPaintIdle.Stop();
+            mpWindowImpl->mpFrameData->maPaintIdle.GetIdleHdl().Call( NULL );
         }
     }
 
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 606a4f5..b446884 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -1029,11 +1029,11 @@ void Window::ImplInit( vcl::Window* pParent, WinBits nStyle, SystemParentData* p
         mpWindowImpl->mpFrameData->mbSysObjFocus      = false;
         if (!ImplDoTiledRendering())
         {
-            mpWindowImpl->mpFrameData->maPaintTimer.SetTimeout( 30 );
-            mpWindowImpl->mpFrameData->maPaintTimer.SetTimeoutHdl( LINK( this, Window, ImplHandlePaintHdl ) );
+            mpWindowImpl->mpFrameData->maPaintIdle.SetPriority( VCL_IDLE_PRIORITY_REPAINT );
+            mpWindowImpl->mpFrameData->maPaintIdle.SetIdleHdl( LINK( this, Window, ImplHandlePaintHdl ) );
         }
-        mpWindowImpl->mpFrameData->maResizeTimer.SetTimeout( 50 );
-        mpWindowImpl->mpFrameData->maResizeTimer.SetTimeoutHdl( LINK( this, Window, ImplHandleResizeTimerHdl ) );
+        mpWindowImpl->mpFrameData->maResizeIdle.SetPriority( VCL_IDLE_PRIORITY_RESIZE );
+        mpWindowImpl->mpFrameData->maResizeIdle.SetIdleHdl( LINK( this, Window, ImplHandleResizeTimerHdl ) );
         mpWindowImpl->mpFrameData->mbInternalDragGestureRecognizer = false;
 
         if ( pRealParent && IsTopWindow() )
@@ -2476,11 +2476,11 @@ Size Window::GetSizePixel() const
     }
 
     // #i43257# trigger pending resize handler to assure correct window sizes
-    if( mpWindowImpl->mpFrameData->maResizeTimer.IsActive() )
+    if( mpWindowImpl->mpFrameData->maResizeIdle.IsActive() )
     {
         ImplDelData aDogtag( this );
-        mpWindowImpl->mpFrameData->maResizeTimer.Stop();
-        mpWindowImpl->mpFrameData->maResizeTimer.GetTimeoutHdl().Call( NULL );
+        mpWindowImpl->mpFrameData->maResizeIdle.Stop();
+        mpWindowImpl->mpFrameData->maResizeIdle.GetIdleHdl().Call( NULL );
         if( aDogtag.IsDead() )
             return Size(0,0);
     }
diff --git a/vcl/source/window/winproc.cxx b/vcl/source/window/winproc.cxx
index 62974ca..ee864f4 100644
--- a/vcl/source/window/winproc.cxx
+++ b/vcl/source/window/winproc.cxx
@@ -1596,7 +1596,7 @@ void ImplHandleResize( vcl::Window* pWindow, long nNewWidth, long nNewHeight )
                     bStartTimer = false;
 
                 if( bStartTimer )
-                    pWindow->ImplGetWindowImpl()->mpFrameData->maResizeTimer.Start();
+                    pWindow->ImplGetWindowImpl()->mpFrameData->maResizeIdle.Start();
                 else
                     pWindow->ImplCallResize(); // otherwise menus cannot be positioned
             }


More information about the Libreoffice-commits mailing list