- fixes calculation of WindowMotionManager in case a new destination is set when the window is not at its original position and provide a function to check if windows

are currently moving (by Thomas Lübking)
- make use of new function and bugfix in SlideBack effect
This commit is contained in:
Michael Zanetti 2011-06-20 21:56:56 +02:00
parent 2f10503ee5
commit e1bf590a1c
3 changed files with 18 additions and 8 deletions

View file

@ -214,9 +214,7 @@ void SlideBackEffect::postPaintWindow(EffectWindow* w)
{
if (motionManager.isManaging(w)) {
if (destinationList.contains(w)) {
// has window reched its destination?
if ((qAbs(motionManager.transformedGeometry(w).x() - destinationList[w].x()) < 1) &&
(qAbs(motionManager.transformedGeometry(w).y() - destinationList[w].y()) < 1)) {
if (!motionManager.isWindowMoving(w)) { // has window reched its destination?
// If we are still intersecting with the activeWindow it is moving. slide to somewhere else
// restore the stacking order of all windows not intersecting any more except panels
if (coveringWindows.contains(w)) {
@ -258,8 +256,7 @@ void SlideBackEffect::postPaintWindow(EffectWindow* w)
}
} else {
// is window back at its original position?
if ((qAbs(motionManager.transformedGeometry(w).x() - w->geometry().x()) < 1) &&
(qAbs(motionManager.transformedGeometry(w).y() - w->geometry().y()) < 1)) {
if (!motionManager.isWindowMoving(w)) {
motionManager.unmanage(w);
effects->addRepaintFull();
}

View file

@ -905,8 +905,8 @@ void WindowMotionManager::calculate(int time)
else {
// Still moving
trans->calculate(time);
const short fx = trans->target().x() <= window->x() ? -1 : 1;
const short fy = trans->target().y() <= window->y() ? -1 : 1;
const short fx = trans->target().x() <= trans->startValue().x() ? -1 : 1;
const short fy = trans->target().y() <= trans->startValue().y() ? -1 : 1;
if (trans->distance().x()*fx/0.5 < 1.0 && trans->velocity().x()*fx/0.2 < 1.0 &&
trans->distance().y()*fy/0.5 < 1.0 && trans->velocity().y()*fy/0.2 < 1.0) {
// Hide tiny oscillations

View file

@ -1534,6 +1534,7 @@ public:
return m_target;
}
inline void setTarget(const T target) {
m_start = m_value;
m_target = target;
}
inline T velocity() const {
@ -1555,6 +1556,9 @@ public:
inline void setSmoothness(const double smoothness) {
m_smoothness = smoothness;
}
inline T startValue() {
return m_start;
}
/**
* The distance between the current position and the target.
@ -1576,7 +1580,7 @@ public:
private:
T m_value;
T m_start;
T m_target;
T m_velocity;
double m_strength;
@ -1753,6 +1757,13 @@ public:
inline bool areWindowsMoving() {
return !m_movingWindowsSet.isEmpty();
}
/**
* Returns whether a window has reached its targets yet
* or not.
*/
inline bool isWindowMoving(EffectWindow *w) {
return m_movingWindowsSet.contains(w);
}
private:
bool m_useGlobalAnimationModifier;
@ -2067,6 +2078,7 @@ double WindowQuad::originalBottom() const
template <typename T>
Motion<T>::Motion(T initial, double strength, double smoothness)
: m_value(initial)
, m_start(initial)
, m_target(initial)
, m_velocity()
, m_strength(strength)
@ -2077,6 +2089,7 @@ Motion<T>::Motion(T initial, double strength, double smoothness)
template <typename T>
Motion<T>::Motion(const Motion &other)
: m_value(other.value())
, m_start(other.target())
, m_target(other.target())
, m_velocity(other.velocity())
, m_strength(other.strength())