[effects] Properly announce/remove support in blur/contrast if shader fails
Following the approach how it's done for X11: only create the interface if the shader succeeded to compile and remove support again if it failed to compile after a reconfigure. REVIEW: 125444
This commit is contained in:
parent
0e0c76e080
commit
044e2a05b2
4 changed files with 36 additions and 12 deletions
|
@ -37,11 +37,6 @@ static const QByteArray s_contrastAtomName = QByteArrayLiteral("_KDE_NET_WM_BACK
|
||||||
|
|
||||||
ContrastEffect::ContrastEffect()
|
ContrastEffect::ContrastEffect()
|
||||||
{
|
{
|
||||||
KWayland::Server::Display *display = effects->waylandDisplay();
|
|
||||||
if (display) {
|
|
||||||
display->createContrastManager(this)->create();
|
|
||||||
}
|
|
||||||
|
|
||||||
shader = ContrastShader::create();
|
shader = ContrastShader::create();
|
||||||
|
|
||||||
reconfigure(ReconfigureAll);
|
reconfigure(ReconfigureAll);
|
||||||
|
@ -50,6 +45,11 @@ ContrastEffect::ContrastEffect()
|
||||||
// Should be included in _NET_SUPPORTED instead.
|
// Should be included in _NET_SUPPORTED instead.
|
||||||
if (shader && shader->isValid()) {
|
if (shader && shader->isValid()) {
|
||||||
net_wm_contrast_region = effects->announceSupportProperty(s_contrastAtomName, this);
|
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 {
|
} else {
|
||||||
net_wm_contrast_region = 0;
|
net_wm_contrast_region = 0;
|
||||||
}
|
}
|
||||||
|
@ -81,8 +81,11 @@ void ContrastEffect::reconfigure(ReconfigureFlags flags)
|
||||||
if (shader)
|
if (shader)
|
||||||
shader->init();
|
shader->init();
|
||||||
|
|
||||||
if (!shader || !shader->isValid())
|
if (!shader || !shader->isValid()) {
|
||||||
effects->removeSupportProperty(s_contrastAtomName, this);
|
effects->removeSupportProperty(s_contrastAtomName, this);
|
||||||
|
delete m_contrastManager;
|
||||||
|
m_contrastManager = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContrastEffect::updateContrastRegion(EffectWindow *w) const
|
void ContrastEffect::updateContrastRegion(EffectWindow *w) const
|
||||||
|
|
|
@ -28,6 +28,14 @@
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QVector2D>
|
#include <QVector2D>
|
||||||
|
|
||||||
|
namespace KWayland
|
||||||
|
{
|
||||||
|
namespace Server
|
||||||
|
{
|
||||||
|
class ContrastManagerInterface;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
namespace KWin
|
namespace KWin
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -76,6 +84,7 @@ private:
|
||||||
QRegion m_paintedArea; // actually painted area which is greater than m_damagedArea
|
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)
|
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
|
QHash< const EffectWindow*, QMetaObject::Connection > m_contrastChangedConnections; // used only in Wayland to keep track of effect changed
|
||||||
|
KWayland::Server::ContrastManagerInterface *m_contrastManager = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline
|
inline
|
||||||
|
|
|
@ -39,11 +39,6 @@ static const QByteArray s_blurAtomName = QByteArrayLiteral("_KDE_NET_WM_BLUR_BEH
|
||||||
|
|
||||||
BlurEffect::BlurEffect()
|
BlurEffect::BlurEffect()
|
||||||
{
|
{
|
||||||
KWayland::Server::Display *display = effects->waylandDisplay();
|
|
||||||
if (display) {
|
|
||||||
display->createBlurManager(this)->create();
|
|
||||||
}
|
|
||||||
|
|
||||||
shader = BlurShader::create();
|
shader = BlurShader::create();
|
||||||
|
|
||||||
// Offscreen texture that's used as the target for the horizontal blur pass
|
// 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.
|
// Should be included in _NET_SUPPORTED instead.
|
||||||
if (shader && shader->isValid() && target->valid()) {
|
if (shader && shader->isValid() && target->valid()) {
|
||||||
net_wm_blur_region = effects->announceSupportProperty(s_blurAtomName, this);
|
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 {
|
} else {
|
||||||
net_wm_blur_region = 0;
|
net_wm_blur_region = 0;
|
||||||
}
|
}
|
||||||
|
@ -100,8 +100,11 @@ void BlurEffect::reconfigure(ReconfigureFlags flags)
|
||||||
|
|
||||||
windows.clear();
|
windows.clear();
|
||||||
|
|
||||||
if (!shader || !shader->isValid())
|
if (!shader || !shader->isValid()) {
|
||||||
effects->removeSupportProperty(s_blurAtomName, this);
|
effects->removeSupportProperty(s_blurAtomName, this);
|
||||||
|
delete m_blurManager;
|
||||||
|
m_blurManager = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlurEffect::updateBlurRegion(EffectWindow *w) const
|
void BlurEffect::updateBlurRegion(EffectWindow *w) const
|
||||||
|
|
|
@ -27,6 +27,14 @@
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QVector2D>
|
#include <QVector2D>
|
||||||
|
|
||||||
|
namespace KWayland
|
||||||
|
{
|
||||||
|
namespace Server
|
||||||
|
{
|
||||||
|
class BlurManagerInterface;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
namespace KWin
|
namespace KWin
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -98,6 +106,7 @@ private:
|
||||||
|
|
||||||
QHash< const EffectWindow*, BlurWindowInfo > windows;
|
QHash< const EffectWindow*, BlurWindowInfo > windows;
|
||||||
typedef QHash<const EffectWindow*, BlurWindowInfo>::iterator CacheEntry;
|
typedef QHash<const EffectWindow*, BlurWindowInfo>::iterator CacheEntry;
|
||||||
|
KWayland::Server::BlurManagerInterface *m_blurManager = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline
|
inline
|
||||||
|
|
Loading…
Reference in a new issue