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=1062214icc-effect-5.14.5
parent
12bba19ee1
commit
239fa294b8
|
@ -1139,7 +1139,7 @@ Motion2D::~Motion2D()
|
||||||
|
|
||||||
WindowMotionManager::WindowMotionManager( bool useGlobalAnimationModifier )
|
WindowMotionManager::WindowMotionManager( bool useGlobalAnimationModifier )
|
||||||
: m_useGlobalAnimationModifier( useGlobalAnimationModifier )
|
: m_useGlobalAnimationModifier( useGlobalAnimationModifier )
|
||||||
, m_movingWindows( 0 )
|
|
||||||
{ // TODO: Allow developer to modify motion attributes
|
{ // TODO: Allow developer to modify motion attributes
|
||||||
} // TODO: What happens when the window moves by an external force?
|
} // 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 diffT = m_managedWindows[ w ].translation.distance();
|
||||||
QPointF diffS = m_managedWindows[ w ].scale.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 );
|
m_managedWindows.remove( w );
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowMotionManager::unmanageAll()
|
void WindowMotionManager::unmanageAll()
|
||||||
{
|
{
|
||||||
m_managedWindows.clear();
|
m_managedWindows.clear();
|
||||||
m_movingWindows = 0;
|
m_movingWindowsSet.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowMotionManager::calculate( int time )
|
void WindowMotionManager::calculate( int time )
|
||||||
{
|
{
|
||||||
if( !effects->animationTimeFactor() )
|
if( !effects->animationTimeFactor() )
|
||||||
{ // Just skip it completely if the user wants no animation
|
{ // Just skip it completely if the user wants no animation
|
||||||
m_movingWindows = 0;
|
m_movingWindowsSet.clear();
|
||||||
QHash<EffectWindow*, WindowMotion>::iterator it = m_managedWindows.begin();
|
QHash<EffectWindow*, WindowMotion>::iterator it = m_managedWindows.begin();
|
||||||
for(; it != m_managedWindows.end(); it++ )
|
for(; it != m_managedWindows.end(); it++ )
|
||||||
{
|
{
|
||||||
|
@ -1242,7 +1241,7 @@ void WindowMotionManager::calculate( int time )
|
||||||
|
|
||||||
// We just finished this window's motion
|
// We just finished this window's motion
|
||||||
if( stopped && diffT == QPoint( 0.0, 0.0 ) && diffS == QPoint( 0.0, 0.0 ))
|
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 ].translation.setTarget( target );
|
||||||
m_managedWindows[ w ].scale.setTarget( scalePoint );
|
m_managedWindows[ w ].scale.setTarget( scalePoint );
|
||||||
|
|
||||||
if( m_managedWindows[ w ].translation.velocity() == QPointF( 0.0, 0.0 ) &&
|
m_movingWindowsSet << w;
|
||||||
m_managedWindows[ w ].scale.velocity() == QPointF( 0.0, 0.0 ))
|
|
||||||
m_movingWindows++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF WindowMotionManager::transformedGeometry( EffectWindow *w ) const
|
QRectF WindowMotionManager::transformedGeometry( EffectWindow *w ) const
|
||||||
|
|
|
@ -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_MAKE_VERSION( major, minor ) (( major ) << 8 | ( minor ))
|
||||||
#define KWIN_EFFECT_API_VERSION_MAJOR 0
|
#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( \
|
#define KWIN_EFFECT_API_VERSION KWIN_EFFECT_API_MAKE_VERSION( \
|
||||||
KWIN_EFFECT_API_VERSION_MAJOR, KWIN_EFFECT_API_VERSION_MINOR )
|
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
|
* or not. Can be used to see if an effect should be
|
||||||
* processed and displayed or not.
|
* processed and displayed or not.
|
||||||
*/
|
*/
|
||||||
inline bool areWindowsMoving() { return m_movingWindows > 0; }
|
inline bool areWindowsMoving() { return !m_movingWindowsSet.isEmpty(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_useGlobalAnimationModifier;
|
bool m_useGlobalAnimationModifier;
|
||||||
|
@ -1602,7 +1602,7 @@ class KWIN_EXPORT WindowMotionManager
|
||||||
Motion2D scale; // xScale and yScale
|
Motion2D scale; // xScale and yScale
|
||||||
};
|
};
|
||||||
QHash<EffectWindow*, WindowMotion> m_managedWindows;
|
QHash<EffectWindow*, WindowMotion> m_managedWindows;
|
||||||
uint m_movingWindows;
|
QSet<EffectWindow*> m_movingWindowsSet;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue