From 5140c872cb035e451965013e1ced9c26310acfe0 Mon Sep 17 00:00:00 2001 From: GleammerRay <101527589+GleammerRay@users.noreply.github.com> Date: Thu, 2 May 2024 11:25:10 +0100 Subject: [PATCH 1/3] Disabling paint before animating --- src/YetAnotherMagicLampEffect.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/YetAnotherMagicLampEffect.cc b/src/YetAnotherMagicLampEffect.cc index 2661a33..ee1967e 100644 --- a/src/YetAnotherMagicLampEffect.cc +++ b/src/YetAnotherMagicLampEffect.cc @@ -204,10 +204,10 @@ void YetAnotherMagicLampEffect::slotWindowMinimized(KWin::EffectWindow* w) } AnimationData& data = m_animations[w]; + data.visibleRef = KWin::EffectWindowVisibleRef(w, KWin::EffectWindow::PAINT_DISABLED_BY_MINIMIZE); data.model.setWindow(w); data.model.setParameters(m_modelParameters); data.model.start(Model::AnimationKind::Minimize); - data.visibleRef = KWin::EffectWindowVisibleRef(w, KWin::EffectWindow::PAINT_DISABLED_BY_MINIMIZE); redirect(w); @@ -226,6 +226,7 @@ void YetAnotherMagicLampEffect::slotWindowUnminimized(KWin::EffectWindow* w) } AnimationData& data = m_animations[w]; + data.visibleRef = KWin::EffectWindowVisibleRef(w, KWin::EffectWindow::PAINT_DISABLED_BY_MINIMIZE); data.model.setWindow(w); data.model.setParameters(m_modelParameters); data.model.start(Model::AnimationKind::Unminimize); From 8b14c355cffa3406dac0613b183ffa00ea27c9a9 Mon Sep 17 00:00:00 2001 From: GleammerRay <101527589+GleammerRay@users.noreply.github.com> Date: Thu, 2 May 2024 11:26:33 +0100 Subject: [PATCH 2/3] Now animating in prePaintWindow --- src/YetAnotherMagicLampEffect.cc | 17 +++++++++++++---- src/YetAnotherMagicLampEffect.h | 1 + 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/YetAnotherMagicLampEffect.cc b/src/YetAnotherMagicLampEffect.cc index ee1967e..6b8ea3b 100644 --- a/src/YetAnotherMagicLampEffect.cc +++ b/src/YetAnotherMagicLampEffect.cc @@ -124,15 +124,24 @@ void YetAnotherMagicLampEffect::reconfigure(ReconfigureFlags flags) void YetAnotherMagicLampEffect::prePaintScreen(KWin::ScreenPrePaintData& data, std::chrono::milliseconds presentTime) { - for (AnimationData& data : m_animations) { - data.model.advance(presentTime); - } - data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS; KWin::effects->prePaintScreen(data, presentTime); } +void YetAnotherMagicLampEffect::prePaintWindow(KWin::EffectWindow* w, KWin::WindowPrePaintData& data, std::chrono::milliseconds presentTime) +{ + // Schedule window for transformation if the animation is still in + // progress + auto animationIt = m_animations.find(w); + if (animationIt != m_animations.end()) { + (*animationIt).model.advance(presentTime); + data.setTransformed(); + } + + KWin::effects->prePaintWindow(w, data, presentTime); +} + void YetAnotherMagicLampEffect::postPaintScreen() { for (auto it = m_animations.begin(); it != m_animations.end();) { diff --git a/src/YetAnotherMagicLampEffect.h b/src/YetAnotherMagicLampEffect.h index e53d474..056341f 100644 --- a/src/YetAnotherMagicLampEffect.h +++ b/src/YetAnotherMagicLampEffect.h @@ -39,6 +39,7 @@ class YetAnotherMagicLampEffect : public KWin::OffscreenEffect { void reconfigure(ReconfigureFlags flags) override; void prePaintScreen(KWin::ScreenPrePaintData& data, std::chrono::milliseconds presentTime) override; + void prePaintWindow(KWin::EffectWindow* w, KWin::WindowPrePaintData& data, std::chrono::milliseconds presentTime) override; void postPaintScreen() override; void paintWindow(KWin::EffectWindow* w, int mask, QRegion region, KWin::WindowPaintData& data) override; From 88e4a33a1cc15f38da244bbca4285c30c297adfb Mon Sep 17 00:00:00 2001 From: GleammerRay <101527589+GleammerRay@users.noreply.github.com> Date: Thu, 2 May 2024 11:27:32 +0100 Subject: [PATCH 3/3] Setting vertex snapping mode to none --- src/YetAnotherMagicLampEffect.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/YetAnotherMagicLampEffect.cc b/src/YetAnotherMagicLampEffect.cc index 6b8ea3b..53d4b99 100644 --- a/src/YetAnotherMagicLampEffect.cc +++ b/src/YetAnotherMagicLampEffect.cc @@ -49,6 +49,8 @@ YetAnotherMagicLampEffect::YetAnotherMagicLampEffect() this, &YetAnotherMagicLampEffect::slotWindowDeleted); connect(KWin::effects, &KWin::EffectsHandler::activeFullScreenEffectChanged, this, &YetAnotherMagicLampEffect::slotActiveFullScreenEffectChanged); + + setVertexSnappingMode(KWin::RenderGeometry::VertexSnappingMode::None); } YetAnotherMagicLampEffect::~YetAnotherMagicLampEffect()