diff --git a/src/plugins/shakecursor/shakecursor.cpp b/src/plugins/shakecursor/shakecursor.cpp index 0e16fc03d9..179bc4cf82 100644 --- a/src/plugins/shakecursor/shakecursor.cpp +++ b/src/plugins/shakecursor/shakecursor.cpp @@ -24,8 +24,19 @@ ShakeCursorEffect::ShakeCursorEffect() m_resetCursorScaleTimer.setSingleShot(true); connect(&m_resetCursorScaleTimer, &QTimer::timeout, this, [this]() { + m_resetCursorScaleAnimation.setStartValue(m_cursorMagnification); + m_resetCursorScaleAnimation.setEndValue(1.0); + m_resetCursorScaleAnimation.setDuration(animationTime(150)); + m_resetCursorScaleAnimation.setEasingCurve(QEasingCurve::InOutCubic); + m_resetCursorScaleAnimation.start(); + }); + + connect(&m_resetCursorScaleAnimation, &QVariantAnimation::valueChanged, this, [this]() { update(Transaction{ - .magnification = 1.0, + .position = m_cursor->pos(), + .hotspot = m_cursor->hotspot(), + .size = m_cursor->geometry().size(), + .magnification = m_resetCursorScaleAnimation.currentValue().toReal(), }); }); @@ -73,11 +84,13 @@ void ShakeCursorEffect::pointerEvent(MouseEvent *event) .magnification = std::max(m_cursorMagnification, 1.0 + ShakeCursorConfig::magnification() * shakeFactor.value()), }); m_resetCursorScaleTimer.start(1000); + m_resetCursorScaleAnimation.stop(); } else { update(Transaction{ .magnification = 1.0, }); m_resetCursorScaleTimer.stop(); + m_resetCursorScaleAnimation.stop(); } } diff --git a/src/plugins/shakecursor/shakecursor.h b/src/plugins/shakecursor/shakecursor.h index ad353c8a06..05f2726676 100644 --- a/src/plugins/shakecursor/shakecursor.h +++ b/src/plugins/shakecursor/shakecursor.h @@ -11,6 +11,7 @@ #include "plugins/shakecursor/shakedetector.h" #include +#include namespace KWin { @@ -51,6 +52,7 @@ private: void update(const Transaction &transaction); QTimer m_resetCursorScaleTimer; + QVariantAnimation m_resetCursorScaleAnimation; ShakeDetector m_shakeDetector; Cursor *m_cursor;