From e1bf590a1c928a6406936b4678e33c23ac5fc0b0 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Mon, 20 Jun 2011 21:56:56 +0200 Subject: [PATCH] =?UTF-8?q?-=20fixes=20calculation=20of=20WindowMotionMana?= =?UTF-8?q?ger=20in=20case=20a=20new=20destination=20is=20set=20when=20the?= =?UTF-8?q?=20window=20is=20not=20at=20its=20original=20position=20and=20p?= =?UTF-8?q?rovide=20a=20function=20to=20check=20if=20windows=20are=20curre?= =?UTF-8?q?ntly=20moving=20(by=20Thomas=20L=C3=BCbking)=20-=20make=20use?= =?UTF-8?q?=20of=20new=20function=20and=20bugfix=20in=20SlideBack=20effect?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- effects/slideback/slideback.cpp | 7 ++----- libkwineffects/kwineffects.cpp | 4 ++-- libkwineffects/kwineffects.h | 15 ++++++++++++++- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/effects/slideback/slideback.cpp b/effects/slideback/slideback.cpp index 8df2c4db30..2c87e5c146 100644 --- a/effects/slideback/slideback.cpp +++ b/effects/slideback/slideback.cpp @@ -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(); } diff --git a/libkwineffects/kwineffects.cpp b/libkwineffects/kwineffects.cpp index ffaeebfe96..aabcabf8b2 100644 --- a/libkwineffects/kwineffects.cpp +++ b/libkwineffects/kwineffects.cpp @@ -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 diff --git a/libkwineffects/kwineffects.h b/libkwineffects/kwineffects.h index 75af204da9..87a676de7f 100644 --- a/libkwineffects/kwineffects.h +++ b/libkwineffects/kwineffects.h @@ -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 Motion::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::Motion(T initial, double strength, double smoothness) template Motion::Motion(const Motion &other) : m_value(other.value()) + , m_start(other.target()) , m_target(other.target()) , m_velocity(other.velocity()) , m_strength(other.strength())