diff --git a/effects/backgroundcontrast/contrast.cpp b/effects/backgroundcontrast/contrast.cpp index 71a7563d7e..168deb02b4 100644 --- a/effects/backgroundcontrast/contrast.cpp +++ b/effects/backgroundcontrast/contrast.cpp @@ -37,11 +37,6 @@ static const QByteArray s_contrastAtomName = QByteArrayLiteral("_KDE_NET_WM_BACK ContrastEffect::ContrastEffect() { - KWayland::Server::Display *display = effects->waylandDisplay(); - if (display) { - display->createContrastManager(this)->create(); - } - shader = ContrastShader::create(); reconfigure(ReconfigureAll); @@ -50,6 +45,11 @@ ContrastEffect::ContrastEffect() // Should be included in _NET_SUPPORTED instead. if (shader && shader->isValid()) { net_wm_contrast_region = effects->announceSupportProperty(s_contrastAtomName, this); + KWayland::Server::Display *display = effects->waylandDisplay(); + if (display) { + m_contrastManager = display->createContrastManager(this); + m_contrastManager->create(); + } } else { net_wm_contrast_region = 0; } @@ -81,8 +81,11 @@ void ContrastEffect::reconfigure(ReconfigureFlags flags) if (shader) shader->init(); - if (!shader || !shader->isValid()) + if (!shader || !shader->isValid()) { effects->removeSupportProperty(s_contrastAtomName, this); + delete m_contrastManager; + m_contrastManager = nullptr; + } } void ContrastEffect::updateContrastRegion(EffectWindow *w) const diff --git a/effects/backgroundcontrast/contrast.h b/effects/backgroundcontrast/contrast.h index 1bdc55a7a2..688fe2203d 100644 --- a/effects/backgroundcontrast/contrast.h +++ b/effects/backgroundcontrast/contrast.h @@ -28,6 +28,14 @@ #include #include +namespace KWayland +{ +namespace Server +{ +class ContrastManagerInterface; +} +} + namespace KWin { @@ -76,6 +84,7 @@ private: QRegion m_paintedArea; // actually painted area which is greater than m_damagedArea QRegion m_currentContrast; // keeps track of the currently contrasted area of non-caching windows(from bottom to top) QHash< const EffectWindow*, QMetaObject::Connection > m_contrastChangedConnections; // used only in Wayland to keep track of effect changed + KWayland::Server::ContrastManagerInterface *m_contrastManager = nullptr; }; inline diff --git a/effects/blur/blur.cpp b/effects/blur/blur.cpp index 7603a55ee3..8ba13542c9 100644 --- a/effects/blur/blur.cpp +++ b/effects/blur/blur.cpp @@ -39,11 +39,6 @@ static const QByteArray s_blurAtomName = QByteArrayLiteral("_KDE_NET_WM_BLUR_BEH BlurEffect::BlurEffect() { - KWayland::Server::Display *display = effects->waylandDisplay(); - if (display) { - display->createBlurManager(this)->create(); - } - shader = BlurShader::create(); // Offscreen texture that's used as the target for the horizontal blur pass @@ -60,6 +55,11 @@ BlurEffect::BlurEffect() // Should be included in _NET_SUPPORTED instead. if (shader && shader->isValid() && target->valid()) { net_wm_blur_region = effects->announceSupportProperty(s_blurAtomName, this); + KWayland::Server::Display *display = effects->waylandDisplay(); + if (display) { + m_blurManager = display->createBlurManager(this); + m_blurManager->create(); + } } else { net_wm_blur_region = 0; } @@ -100,8 +100,11 @@ void BlurEffect::reconfigure(ReconfigureFlags flags) windows.clear(); - if (!shader || !shader->isValid()) + if (!shader || !shader->isValid()) { effects->removeSupportProperty(s_blurAtomName, this); + delete m_blurManager; + m_blurManager = nullptr; + } } void BlurEffect::updateBlurRegion(EffectWindow *w) const diff --git a/effects/blur/blur.h b/effects/blur/blur.h index c908ede8d8..1495a6f361 100644 --- a/effects/blur/blur.h +++ b/effects/blur/blur.h @@ -27,6 +27,14 @@ #include #include +namespace KWayland +{ +namespace Server +{ +class BlurManagerInterface; +} +} + namespace KWin { @@ -98,6 +106,7 @@ private: QHash< const EffectWindow*, BlurWindowInfo > windows; typedef QHash::iterator CacheEntry; + KWayland::Server::BlurManagerInterface *m_blurManager = nullptr; }; inline