From 49b84ddf8c21bc6abf6ccaad268fefa48aaee414 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Fri, 20 Oct 2023 14:53:36 +0300 Subject: [PATCH] Avoid destroying effects if animation speed changes It makes little sense to destroy effects if the animation speed changes. The effects are written with the assumption that the animation time can change and therefore they handle this case in reconfigure(). --- src/compositor.cpp | 1 - src/effects.cpp | 10 ++++++++++ src/effects.h | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/compositor.cpp b/src/compositor.cpp index 21a988a225..27ce49e243 100644 --- a/src/compositor.cpp +++ b/src/compositor.cpp @@ -42,7 +42,6 @@ Compositor::Compositor(QObject *workspace) : QObject(workspace) { connect(options, &Options::configChanged, this, &Compositor::configChanged); - connect(options, &Options::animationSpeedChanged, this, &Compositor::configChanged); // 2 sec which should be enough to restart the compositor. static const int compositorLostMessageDelay = 2000; diff --git a/src/effects.cpp b/src/effects.cpp index e805d7b938..ba62a648e8 100644 --- a/src/effects.cpp +++ b/src/effects.cpp @@ -140,6 +140,8 @@ EffectsHandlerImpl::EffectsHandlerImpl(Compositor *compositor, WorkspaceScene *s QDBusConnection dbus = QDBusConnection::sessionBus(); dbus.registerObject(QStringLiteral("/Effects"), this); + connect(options, &Options::animationSpeedChanged, this, &EffectsHandlerImpl::reconfigureEffects); + Workspace *ws = Workspace::self(); VirtualDesktopManager *vds = VirtualDesktopManager::self(); connect(ws, &Workspace::showingDesktopChanged, this, [this](bool showing, bool animated) { @@ -1240,6 +1242,14 @@ void EffectsHandlerImpl::destroyEffect(Effect *effect) delete effect; } +void EffectsHandlerImpl::reconfigureEffects() +{ + makeOpenGLContextCurrent(); + for (const EffectPair &pair : loaded_effects) { + pair.second->reconfigure(Effect::ReconfigureAll); + } +} + void EffectsHandlerImpl::reconfigureEffect(const QString &name) { for (QList::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) { diff --git a/src/effects.h b/src/effects.h index 2785fbcddc..0078c39899 100644 --- a/src/effects.h +++ b/src/effects.h @@ -304,6 +304,7 @@ protected: private: void registerPropertyType(long atom, bool reg); void destroyEffect(Effect *effect); + void reconfigureEffects(); typedef QList EffectsList; typedef EffectsList::const_iterator EffectsIterator;