diff --git a/plugins/scenes/opengl/lanczosfilter.cpp b/plugins/scenes/opengl/lanczosfilter.cpp index a83917c2e4..66fb47e41c 100644 --- a/plugins/scenes/opengl/lanczosfilter.cpp +++ b/plugins/scenes/opengl/lanczosfilter.cpp @@ -394,18 +394,10 @@ void LanczosFilter::timerEvent(QTimerEvent *event) delete m_offscreenTex; m_offscreenTarget = nullptr; m_offscreenTex = nullptr; - foreach (X11Client *c, Workspace::self()->clientList()) { - discardCacheTexture(c->effectWindow()); - } - foreach (X11Client *c, Workspace::self()->desktopList()) { - discardCacheTexture(c->effectWindow()); - } - foreach (Unmanaged *u, Workspace::self()->unmanagedList()) { - discardCacheTexture(u->effectWindow()); - } - foreach (Deleted *d, Workspace::self()->deletedList()) { - discardCacheTexture(d->effectWindow()); - } + + workspace()->forEachToplevel([this](Toplevel *toplevel) { + discardCacheTexture(toplevel->effectWindow()); + }); } } diff --git a/workspace.cpp b/workspace.cpp index 8b35459ac2..bbbdb910a9 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -1720,6 +1720,15 @@ Toplevel *Workspace::findToplevel(std::function func) co return nullptr; } +void Workspace::forEachToplevel(std::function func) +{ + std::for_each(m_allClients.constBegin(), m_allClients.constEnd(), func); + std::for_each(desktops.constBegin(), desktops.constEnd(), func); + std::for_each(deleted.constBegin(), deleted.constEnd(), func); + std::for_each(unmanaged.constBegin(), unmanaged.constEnd(), func); + std::for_each(m_internalClients.constBegin(), m_internalClients.constEnd(), func); +} + bool Workspace::hasClient(const AbstractClient *c) { if (auto cc = dynamic_cast(c)) { diff --git a/workspace.h b/workspace.h index e14641557f..27d33a4aed 100644 --- a/workspace.h +++ b/workspace.h @@ -133,6 +133,7 @@ public: Unmanaged *findUnmanaged(xcb_window_t w) const; void forEachUnmanaged(std::function func); Toplevel *findToplevel(std::function func) const; + void forEachToplevel(std::function func); /** * @brief Finds a Toplevel for the internal window @p w. *