From 239fa294b88ac3161f9b8798f7b9b9debeb4c0c6 Mon Sep 17 00:00:00 2001 From: Jacopo De Simoi Date: Mon, 14 Dec 2009 08:48:54 +0000 Subject: [PATCH] Use a set instead of a counter to keep track of moving windows, this is much less error-prone and allows to avoid corner cases such as motions for the same window starting in the same frame. BUG: 205632 svn path=/trunk/KDE/kdebase/workspace/; revision=1062214 --- lib/kwineffects.cpp | 15 ++++++--------- lib/kwineffects.h | 6 +++--- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/lib/kwineffects.cpp b/lib/kwineffects.cpp index 7245c7363c..d166bb67c3 100644 --- a/lib/kwineffects.cpp +++ b/lib/kwineffects.cpp @@ -1139,7 +1139,7 @@ Motion2D::~Motion2D() WindowMotionManager::WindowMotionManager( bool useGlobalAnimationModifier ) : m_useGlobalAnimationModifier( useGlobalAnimationModifier ) - , m_movingWindows( 0 ) + { // TODO: Allow developer to modify motion attributes } // TODO: What happens when the window moves by an external force? @@ -1177,23 +1177,22 @@ void WindowMotionManager::unmanage( EffectWindow *w ) QPointF diffT = m_managedWindows[ w ].translation.distance(); QPointF diffS = m_managedWindows[ w ].scale.distance(); - if( diffT.x() != 0.0 || diffT.y() != 0.0 || diffS.x() != 0.0 || diffS.y() != 0.0 ) - m_movingWindows--; // Window was moving + m_movingWindowsSet.remove( w ); m_managedWindows.remove( w ); } void WindowMotionManager::unmanageAll() { m_managedWindows.clear(); - m_movingWindows = 0; + m_movingWindowsSet.clear(); } void WindowMotionManager::calculate( int time ) { if( !effects->animationTimeFactor() ) { // Just skip it completely if the user wants no animation - m_movingWindows = 0; + m_movingWindowsSet.clear(); QHash::iterator it = m_managedWindows.begin(); for(; it != m_managedWindows.end(); it++ ) { @@ -1242,7 +1241,7 @@ void WindowMotionManager::calculate( int time ) // We just finished this window's motion if( stopped && diffT == QPoint( 0.0, 0.0 ) && diffS == QPoint( 0.0, 0.0 )) - m_movingWindows--; + m_movingWindowsSet.remove( it.key() ); } } @@ -1302,9 +1301,7 @@ void WindowMotionManager::moveWindow( EffectWindow *w, QPoint target, double sca m_managedWindows[ w ].translation.setTarget( target ); m_managedWindows[ w ].scale.setTarget( scalePoint ); - if( m_managedWindows[ w ].translation.velocity() == QPointF( 0.0, 0.0 ) && - m_managedWindows[ w ].scale.velocity() == QPointF( 0.0, 0.0 )) - m_movingWindows++; + m_movingWindowsSet << w; } QRectF WindowMotionManager::transformedGeometry( EffectWindow *w ) const diff --git a/lib/kwineffects.h b/lib/kwineffects.h index 458a035b4d..fb42ce33eb 100644 --- a/lib/kwineffects.h +++ b/lib/kwineffects.h @@ -170,7 +170,7 @@ X-KDE-Library=kwin4_effect_cooleffect #define KWIN_EFFECT_API_MAKE_VERSION( major, minor ) (( major ) << 8 | ( minor )) #define KWIN_EFFECT_API_VERSION_MAJOR 0 -#define KWIN_EFFECT_API_VERSION_MINOR 108 +#define KWIN_EFFECT_API_VERSION_MINOR 109 #define KWIN_EFFECT_API_VERSION KWIN_EFFECT_API_MAKE_VERSION( \ KWIN_EFFECT_API_VERSION_MAJOR, KWIN_EFFECT_API_VERSION_MINOR ) @@ -1592,7 +1592,7 @@ class KWIN_EXPORT WindowMotionManager * or not. Can be used to see if an effect should be * processed and displayed or not. */ - inline bool areWindowsMoving() { return m_movingWindows > 0; } + inline bool areWindowsMoving() { return !m_movingWindowsSet.isEmpty(); } private: bool m_useGlobalAnimationModifier; @@ -1602,7 +1602,7 @@ class KWIN_EXPORT WindowMotionManager Motion2D scale; // xScale and yScale }; QHash m_managedWindows; - uint m_movingWindows; + QSet m_movingWindowsSet; }; /**