include/vcl/timer.hxx | 35 +++++++++++++++++++++++++++++++++ vcl/inc/window.h | 4 +-- vcl/source/app/timer.cxx | 45 +++++++++++++++++++++++++++++++++++++++++++ vcl/source/window/window.cxx | 8 +++---- 4 files changed, 86 insertions(+), 6 deletions(-)
New commits: commit ad71bd6715be6b37ecc3af1beef96e22caa5b394 Author: Jennifer Liebel <jliebe...@gmail.com> Date: Fri Oct 31 08:17:33 2014 +0000 applied patch from Michael Meeks Change-Id: I57f22b6d9bfbef4a50d162076b01e8e64edb4718 diff --git a/include/vcl/timer.hxx b/include/vcl/timer.hxx index d3ebe1a..5c3a49a 100644 --- a/include/vcl/timer.hxx +++ b/include/vcl/timer.hxx @@ -73,6 +73,41 @@ 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 : private Timer +{ + public: + 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() = 0; + + 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..60a4489 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 maResizeTimer; //< 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..e38c347 100644 --- a/vcl/source/app/timer.cxx +++ b/vcl/source/app/timer.cxx @@ -336,4 +336,49 @@ AutoTimer& AutoTimer::operator=( const AutoTimer& rTimer ) return *this; } +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 ); +} + +Idle::~Idle() +{ +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index 606a4f5..a1ac1a1 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() ) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits