Commit 84acb768 authored by Xaver Hugl's avatar Xaver Hugl
Browse files

effects: modernize some code

Mostly port away from manual memory management and clean up some headers
parent 24dfdd70
Pipeline #196967 canceled with stage
in 13 minutes and 3 seconds
......@@ -1576,9 +1576,9 @@ KWaylandServer::Display *EffectsHandlerImpl::waylandDisplay() const
return nullptr;
}
EffectFrame *EffectsHandlerImpl::effectFrame(EffectFrameStyle style, bool staticSize, const QPoint &position, Qt::Alignment alignment) const
std::unique_ptr<EffectFrame> EffectsHandlerImpl::effectFrame(EffectFrameStyle style, bool staticSize, const QPoint &position, Qt::Alignment alignment) const
{
return new EffectFrameImpl(style, staticSize, position, alignment);
return std::make_unique<EffectFrameImpl>(style, staticSize, position, alignment);
}
QVariant EffectsHandlerImpl::kwinOption(KWinOption kwopt)
......
......@@ -166,7 +166,7 @@ public:
bool decorationsHaveAlpha() const override;
EffectFrame *effectFrame(EffectFrameStyle style, bool staticSize, const QPoint &position, Qt::Alignment alignment) const override;
std::unique_ptr<EffectFrame> effectFrame(EffectFrameStyle style, bool staticSize, const QPoint &position, Qt::Alignment alignment) const override;
QVariant kwinOption(KWinOption kwopt) override;
bool isScreenLocked() const override;
......
......@@ -29,14 +29,14 @@ QTimer *ContrastEffect::s_contrastManagerRemoveTimer = nullptr;
ContrastEffect::ContrastEffect()
{
shader = ContrastShader::create();
shader->init();
m_shader = std::make_unique<ContrastShader>();
m_shader->init();
// ### Hackish way to announce support.
// Should be included in _NET_SUPPORTED instead.
if (shader && shader->isValid()) {
if (m_shader && m_shader->isValid()) {
if (effects->xcbConnection()) {
net_wm_contrast_region = effects->announceSupportProperty(s_contrastAtomName, this);
m_net_wm_contrast_region = effects->announceSupportProperty(s_contrastAtomName, this);
}
if (effects->waylandDisplay()) {
if (!s_contrastManagerRemoveTimer) {
......@@ -59,8 +59,8 @@ ContrastEffect::ContrastEffect()
connect(effects, &EffectsHandler::propertyNotify, this, &ContrastEffect::slotPropertyNotify);
connect(effects, &EffectsHandler::virtualScreenGeometryChanged, this, &ContrastEffect::slotScreenGeometryChanged);
connect(effects, &EffectsHandler::xcbConnectionChanged, this, [this]() {
if (shader && shader->isValid()) {
net_wm_contrast_region = effects->announceSupportProperty(s_contrastAtomName, this);
if (m_shader && m_shader->isValid()) {
m_net_wm_contrast_region = effects->announceSupportProperty(s_contrastAtomName, this);
}
});
......@@ -77,7 +77,6 @@ ContrastEffect::~ContrastEffect()
if (s_contrastManager) {
s_contrastManagerRemoveTimer->start(1000);
}
delete shader;
}
void ContrastEffect::slotScreenGeometryChanged()
......@@ -100,8 +99,8 @@ void ContrastEffect::updateContrastRegion(EffectWindow *w)
float colorTransform[16];
bool valid = false;
if (net_wm_contrast_region != XCB_ATOM_NONE) {
const QByteArray value = w->readProperty(net_wm_contrast_region, net_wm_contrast_region, 32);
if (m_net_wm_contrast_region != XCB_ATOM_NONE) {
const QByteArray value = w->readProperty(m_net_wm_contrast_region, m_net_wm_contrast_region, 32);
if (value.size() > 0 && !((value.size() - (16 * sizeof(uint32_t))) % ((4 * sizeof(uint32_t))))) {
const uint32_t *cardinals = reinterpret_cast<const uint32_t *>(value.constData());
......@@ -211,7 +210,7 @@ void ContrastEffect::slotWindowDeleted(EffectWindow *w)
void ContrastEffect::slotPropertyNotify(EffectWindow *w, long atom)
{
if (w && atom == net_wm_contrast_region && net_wm_contrast_region != XCB_ATOM_NONE) {
if (w && atom == m_net_wm_contrast_region && m_net_wm_contrast_region != XCB_ATOM_NONE) {
updateContrastRegion(w);
}
}
......@@ -347,7 +346,7 @@ void ContrastEffect::uploadGeometry(GLVertexBuffer *vbo, const QRegion &region)
bool ContrastEffect::shouldContrast(const EffectWindow *w, int mask, const WindowPaintData &data) const
{
if (!shader || !shader->isValid()) {
if (!m_shader || !m_shader->isValid()) {
return false;
}
......@@ -435,17 +434,17 @@ void ContrastEffect::doContrast(EffectWindow *w, const QRegion &shape, const QRe
// Draw the texture on the offscreen framebuffer object, while blurring it horizontally
shader->setColorMatrix(m_colorMatrices.value(w));
shader->bind();
m_shader->setColorMatrix(m_colorMatrices.value(w));
m_shader->bind();
shader->setOpacity(opacity);
m_shader->setOpacity(opacity);
// Set up the texture matrix to transform from screen coordinates
// to texture coordinates.
QMatrix4x4 textureMatrix;
textureMatrix.scale(1.0 / r.width(), -1.0 / r.height(), 1);
textureMatrix.translate(-r.x(), -r.height() - r.y(), 0);
shader->setTextureMatrix(textureMatrix);
shader->setModelViewProjectionMatrix(screenProjection);
m_shader->setTextureMatrix(textureMatrix);
m_shader->setModelViewProjectionMatrix(screenProjection);
vbo->draw(GL_TRIANGLES, 0, actualShape.rectCount() * 6);
......@@ -458,7 +457,7 @@ void ContrastEffect::doContrast(EffectWindow *w, const QRegion &shape, const QRe
glDisable(GL_BLEND);
}
shader->unbind();
m_shader->unbind();
}
bool ContrastEffect::isActive() const
......
......@@ -65,8 +65,8 @@ private:
void uploadGeometry(GLVertexBuffer *vbo, const QRegion &region);
private:
ContrastShader *shader;
long net_wm_contrast_region = 0;
std::unique_ptr<ContrastShader> m_shader;
long m_net_wm_contrast_region = 0;
QHash<const EffectWindow *, QMatrix4x4> m_colorMatrices;
QHash<const EffectWindow *, QMetaObject::Connection> m_contrastChangedConnections; // used only in Wayland to keep track of effect changed
static KWaylandServer::ContrastManagerInterface *s_contrastManager;
......
......@@ -21,26 +21,15 @@ namespace KWin
{
ContrastShader::ContrastShader()
: mValid(false)
, shader(nullptr)
: m_valid(false)
, m_shader(nullptr)
, m_opacity(1)
{
}
ContrastShader::~ContrastShader()
{
reset();
}
ContrastShader *ContrastShader::create()
{
return new ContrastShader();
}
void ContrastShader::reset()
{
delete shader;
shader = nullptr;
m_shader.reset();
setIsValid(false);
}
......@@ -49,8 +38,8 @@ void ContrastShader::setOpacity(float opacity)
{
m_opacity = opacity;
ShaderManager::instance()->pushShader(shader);
shader->setUniform(opacityLocation, opacity);
ShaderManager::instance()->pushShader(m_shader.get());
m_shader->setUniform(m_opacityLocation, opacity);
ShaderManager::instance()->popShader();
}
......@@ -65,8 +54,8 @@ void ContrastShader::setColorMatrix(const QMatrix4x4 &matrix)
return;
}
ShaderManager::instance()->pushShader(shader);
shader->setUniform(colorMatrixLocation, matrix);
ShaderManager::instance()->pushShader(m_shader.get());
m_shader->setUniform(m_colorMatrixLocation, matrix);
ShaderManager::instance()->popShader();
}
......@@ -76,7 +65,7 @@ void ContrastShader::setTextureMatrix(const QMatrix4x4 &matrix)
return;
}
shader->setUniform(textureMatrixLocation, matrix);
m_shader->setUniform(m_textureMatrixLocation, matrix);
}
void ContrastShader::setModelViewProjectionMatrix(const QMatrix4x4 &matrix)
......@@ -85,7 +74,7 @@ void ContrastShader::setModelViewProjectionMatrix(const QMatrix4x4 &matrix)
return;
}
shader->setUniform(mvpMatrixLocation, matrix);
m_shader->setUniform(m_mvpMatrixLocation, matrix);
}
void ContrastShader::bind()
......@@ -94,7 +83,7 @@ void ContrastShader::bind()
return;
}
ShaderManager::instance()->pushShader(shader);
ShaderManager::instance()->pushShader(m_shader.get());
}
void ContrastShader::unbind()
......@@ -179,26 +168,36 @@ void ContrastShader::init()
stream2 << "}\n";
stream2.flush();
shader = ShaderManager::instance()->loadShaderFromCode(vertexSource, fragmentSource);
m_shader = ShaderManager::instance()->loadShaderFromCode(vertexSource, fragmentSource);
if (shader->isValid()) {
colorMatrixLocation = shader->uniformLocation("colorMatrix");
textureMatrixLocation = shader->uniformLocation("textureMatrix");
mvpMatrixLocation = shader->uniformLocation("modelViewProjectionMatrix");
opacityLocation = shader->uniformLocation("opacity");
if (m_shader->isValid()) {
m_colorMatrixLocation = m_shader->uniformLocation("colorMatrix");
m_textureMatrixLocation = m_shader->uniformLocation("textureMatrix");
m_mvpMatrixLocation = m_shader->uniformLocation("modelViewProjectionMatrix");
m_opacityLocation = m_shader->uniformLocation("opacity");
QMatrix4x4 modelViewProjection;
const QSize screenSize = effects->virtualScreenSize();
modelViewProjection.ortho(0, screenSize.width(), screenSize.height(), 0, 0, 65535);
ShaderManager::instance()->pushShader(shader);
shader->setUniform(colorMatrixLocation, QMatrix4x4());
shader->setUniform(textureMatrixLocation, QMatrix4x4());
shader->setUniform(mvpMatrixLocation, modelViewProjection);
shader->setUniform(opacityLocation, (float)1.0);
ShaderManager::instance()->pushShader(m_shader.get());
m_shader->setUniform(m_colorMatrixLocation, QMatrix4x4());
m_shader->setUniform(m_textureMatrixLocation, QMatrix4x4());
m_shader->setUniform(m_mvpMatrixLocation, modelViewProjection);
m_shader->setUniform(m_opacityLocation, (float)1.0);
ShaderManager::instance()->popShader();
}
setIsValid(shader->isValid());
setIsValid(m_shader->isValid());
}
void ContrastShader::setIsValid(bool value)
{
m_valid = value;
}
bool ContrastShader::isValid() const
{
return m_valid;
}
} // namespace KWin
......@@ -19,42 +19,30 @@ class ContrastShader
{
public:
ContrastShader();
virtual ~ContrastShader();
void init();
static ContrastShader *create();
bool isValid() const
{
return mValid;
}
void setColorMatrix(const QMatrix4x4 &matrix);
void setTextureMatrix(const QMatrix4x4 &matrix);
void setModelViewProjectionMatrix(const QMatrix4x4 &matrix);
void setOpacity(float opacity);
float opacity() const;
bool isValid() const;
void bind();
void unbind();
void setOpacity(float opacity);
float opacity() const;
protected:
void setIsValid(bool value)
{
mValid = value;
}
void setIsValid(bool value);
void reset();
private:
bool mValid;
GLShader *shader;
int mvpMatrixLocation;
int textureMatrixLocation;
int colorMatrixLocation;
int opacityLocation;
bool m_valid;
std::unique_ptr<GLShader> m_shader;
int m_mvpMatrixLocation;
int m_textureMatrixLocation;
int m_colorMatrixLocation;
int m_opacityLocation;
float m_opacity;
};
......
......@@ -23,25 +23,25 @@ BlurShader::BlurShader(QObject *parent)
{
ensureResources();
m_shaderDownsample.reset(ShaderManager::instance()->generateShaderFromFile(
m_shaderDownsample = ShaderManager::instance()->generateShaderFromFile(
ShaderTrait::MapTexture,
QStringLiteral(":/effects/blur/shaders/vertex.vert"),
QStringLiteral(":/effects/blur/shaders/downsample.frag")));
QStringLiteral(":/effects/blur/shaders/downsample.frag"));
m_shaderUpsample.reset(ShaderManager::instance()->generateShaderFromFile(
m_shaderUpsample = ShaderManager::instance()->generateShaderFromFile(
ShaderTrait::MapTexture,
QStringLiteral(":/effects/blur/shaders/vertex.vert"),
QStringLiteral(":/effects/blur/shaders/upsample.frag")));
QStringLiteral(":/effects/blur/shaders/upsample.frag"));
m_shaderCopysample.reset(ShaderManager::instance()->generateShaderFromFile(
m_shaderCopysample = ShaderManager::instance()->generateShaderFromFile(
ShaderTrait::MapTexture,
QStringLiteral(":/effects/blur/shaders/vertex.vert"),
QStringLiteral(":/effects/blur/shaders/copy.frag")));
QStringLiteral(":/effects/blur/shaders/copy.frag"));
m_shaderNoisesample.reset(ShaderManager::instance()->generateShaderFromFile(
m_shaderNoisesample = ShaderManager::instance()->generateShaderFromFile(
ShaderTrait::MapTexture,
QStringLiteral(":/effects/blur/shaders/vertex.vert"),
QStringLiteral(":/effects/blur/shaders/noise.frag")));
QStringLiteral(":/effects/blur/shaders/noise.frag"));
m_valid = m_shaderDownsample->isValid() && m_shaderUpsample->isValid() && m_shaderCopysample->isValid() && m_shaderNoisesample->isValid();
......@@ -72,27 +72,27 @@ BlurShader::BlurShader(QObject *parent)
modelViewProjection.ortho(0, screenSize.width(), screenSize.height(), 0, 0, 65535);
// Add default values to the uniforms of the shaders
ShaderManager::instance()->pushShader(m_shaderDownsample.data());
ShaderManager::instance()->pushShader(m_shaderDownsample.get());
m_shaderDownsample->setUniform(m_mvpMatrixLocationDownsample, modelViewProjection);
m_shaderDownsample->setUniform(m_offsetLocationDownsample, float(1.0));
m_shaderDownsample->setUniform(m_renderTextureSizeLocationDownsample, QVector2D(1.0, 1.0));
m_shaderDownsample->setUniform(m_halfpixelLocationDownsample, QVector2D(1.0, 1.0));
ShaderManager::instance()->popShader();
ShaderManager::instance()->pushShader(m_shaderUpsample.data());
ShaderManager::instance()->pushShader(m_shaderUpsample.get());
m_shaderUpsample->setUniform(m_mvpMatrixLocationUpsample, modelViewProjection);
m_shaderUpsample->setUniform(m_offsetLocationUpsample, float(1.0));
m_shaderUpsample->setUniform(m_renderTextureSizeLocationUpsample, QVector2D(1.0, 1.0));
m_shaderUpsample->setUniform(m_halfpixelLocationUpsample, QVector2D(1.0, 1.0));
ShaderManager::instance()->popShader();
ShaderManager::instance()->pushShader(m_shaderCopysample.data());
ShaderManager::instance()->pushShader(m_shaderCopysample.get());
m_shaderCopysample->setUniform(m_mvpMatrixLocationCopysample, modelViewProjection);
m_shaderCopysample->setUniform(m_renderTextureSizeLocationCopysample, QVector2D(1.0, 1.0));
m_shaderCopysample->setUniform(m_blurRectLocationCopysample, QVector4D(1.0, 1.0, 1.0, 1.0));
ShaderManager::instance()->popShader();
ShaderManager::instance()->pushShader(m_shaderNoisesample.data());
ShaderManager::instance()->pushShader(m_shaderNoisesample.get());
m_shaderNoisesample->setUniform(m_mvpMatrixLocationNoisesample, modelViewProjection);
m_shaderNoisesample->setUniform(m_offsetLocationNoisesample, float(1.0));
m_shaderNoisesample->setUniform(m_renderTextureSizeLocationNoisesample, QVector2D(1.0, 1.0));
......@@ -269,19 +269,19 @@ void BlurShader::bind(SampleType sampleType)
switch (sampleType) {
case CopySampleType:
ShaderManager::instance()->pushShader(m_shaderCopysample.data());
ShaderManager::instance()->pushShader(m_shaderCopysample.get());
break;
case UpSampleType:
ShaderManager::instance()->pushShader(m_shaderUpsample.data());
ShaderManager::instance()->pushShader(m_shaderUpsample.get());
break;
case DownSampleType:
ShaderManager::instance()->pushShader(m_shaderDownsample.data());
ShaderManager::instance()->pushShader(m_shaderDownsample.get());
break;
case NoiseSampleType:
ShaderManager::instance()->pushShader(m_shaderNoisesample.data());
ShaderManager::instance()->pushShader(m_shaderNoisesample.get());
break;
default:
......
......@@ -47,10 +47,10 @@ public:
void setBlurRect(const QRect &blurRect, const QSize &screenSize);
private:
QScopedPointer<GLShader> m_shaderDownsample;
QScopedPointer<GLShader> m_shaderUpsample;
QScopedPointer<GLShader> m_shaderCopysample;
QScopedPointer<GLShader> m_shaderNoisesample;
std::unique_ptr<GLShader> m_shaderDownsample;
std::unique_ptr<GLShader> m_shaderUpsample;
std::unique_ptr<GLShader> m_shaderCopysample;
std::unique_ptr<GLShader> m_shaderNoisesample;
int m_mvpMatrixLocationDownsample;
int m_offsetLocationDownsample;
......
......@@ -38,12 +38,10 @@ DesktopGridEffectConfigForm::DesktopGridEffectConfigForm(QWidget *parent)
DesktopGridEffectConfig::DesktopGridEffectConfig(QWidget *parent, const QVariantList &args)
: KCModule(parent, args)
, m_ui(this)
{
m_ui = new DesktopGridEffectConfigForm(this);
QVBoxLayout *layout = new QVBoxLayout(this);
layout->addWidget(m_ui);
layout->addWidget(&m_ui);
// Shortcut config. The shortcut belongs to the component "kwin"!
m_actionCollection = new KActionCollection(this, QStringLiteral("kwin"));
......@@ -58,36 +56,36 @@ DesktopGridEffectConfig::DesktopGridEffectConfig(QWidget *parent, const QVariant
KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << (Qt::CTRL | Qt::Key_F8));
KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << (Qt::CTRL | Qt::Key_F8));
m_ui->shortcutEditor->addCollection(m_actionCollection);
m_ui.shortcutEditor->addCollection(m_actionCollection);
m_ui->desktopNameAlignmentCombo->addItem(i18nc("Desktop name alignment:", "Disabled"), QVariant(Qt::Alignment()));
m_ui->desktopNameAlignmentCombo->addItem(i18n("Top"), QVariant(Qt::AlignHCenter | Qt::AlignTop));
m_ui->desktopNameAlignmentCombo->addItem(i18n("Top-Right"), QVariant(Qt::AlignRight | Qt::AlignTop));
m_ui->desktopNameAlignmentCombo->addItem(i18n("Right"), QVariant(Qt::AlignRight | Qt::AlignVCenter));
m_ui->desktopNameAlignmentCombo->addItem(i18n("Bottom-Right"), QVariant(Qt::AlignRight | Qt::AlignBottom));
m_ui->desktopNameAlignmentCombo->addItem(i18n("Bottom"), QVariant(Qt::AlignHCenter | Qt::AlignBottom));
m_ui->desktopNameAlignmentCombo->addItem(i18n("Bottom-Left"), QVariant(Qt::AlignLeft | Qt::AlignBottom));
m_ui->desktopNameAlignmentCombo->addItem(i18n("Left"), QVariant(Qt::AlignLeft | Qt::AlignVCenter));
m_ui->desktopNameAlignmentCombo->addItem(i18n("Top-Left"), QVariant(Qt::AlignLeft | Qt::AlignTop));
m_ui->desktopNameAlignmentCombo->addItem(i18n("Center"), QVariant(Qt::AlignCenter));
m_ui.desktopNameAlignmentCombo->addItem(i18nc("Desktop name alignment:", "Disabled"), QVariant(Qt::Alignment()));
m_ui.desktopNameAlignmentCombo->addItem(i18n("Top"), QVariant(Qt::AlignHCenter | Qt::AlignTop));
m_ui.desktopNameAlignmentCombo->addItem(i18n("Top-Right"), QVariant(Qt::AlignRight | Qt::AlignTop));
m_ui.desktopNameAlignmentCombo->addItem(i18n("Right"), QVariant(Qt::AlignRight | Qt::AlignVCenter));
m_ui.desktopNameAlignmentCombo->addItem(i18n("Bottom-Right"), QVariant(Qt::AlignRight | Qt::AlignBottom));
m_ui.desktopNameAlignmentCombo->addItem(i18n("Bottom"), QVariant(Qt::AlignHCenter | Qt::AlignBottom));
m_ui.desktopNameAlignmentCombo->addItem(i18n("Bottom-Left"), QVariant(Qt::AlignLeft | Qt::AlignBottom));
m_ui.desktopNameAlignmentCombo->addItem(i18n("Left"), QVariant(Qt::AlignLeft | Qt::AlignVCenter));
m_ui.desktopNameAlignmentCombo->addItem(i18n("Top-Left"), QVariant(Qt::AlignLeft | Qt::AlignTop));
m_ui.desktopNameAlignmentCombo->addItem(i18n("Center"), QVariant(Qt::AlignCenter));
DesktopGridConfig::instance(KWIN_CONFIG);
addConfig(DesktopGridConfig::self(), m_ui);
connect(m_ui->kcfg_DesktopLayoutMode, qOverload<int>(&QComboBox::currentIndexChanged), this, &DesktopGridEffectConfig::desktopLayoutSelectionChanged);
connect(m_ui->desktopNameAlignmentCombo, qOverload<int>(&QComboBox::currentIndexChanged), this, &DesktopGridEffectConfig::markAsChanged);
connect(m_ui->shortcutEditor, &KShortcutsEditor::keyChange, this, &DesktopGridEffectConfig::markAsChanged);
addConfig(DesktopGridConfig::self(), &m_ui);
connect(m_ui.kcfg_DesktopLayoutMode, qOverload<int>(&QComboBox::currentIndexChanged), this, &DesktopGridEffectConfig::desktopLayoutSelectionChanged);
connect(m_ui.desktopNameAlignmentCombo, qOverload<int>(&QComboBox::currentIndexChanged), this, &DesktopGridEffectConfig::markAsChanged);
connect(m_ui.shortcutEditor, &KShortcutsEditor::keyChange, this, &DesktopGridEffectConfig::markAsChanged);
}
DesktopGridEffectConfig::~DesktopGridEffectConfig()
{
// If save() is called undo() has no effect
m_ui->shortcutEditor->undo();
m_ui.shortcutEditor->undo();
}
void DesktopGridEffectConfig::save()
{
m_ui->shortcutEditor->save();
DesktopGridConfig::setDesktopNameAlignment(m_ui->desktopNameAlignmentCombo->itemData(m_ui->desktopNameAlignmentCombo->currentIndex()).toInt());
m_ui.shortcutEditor->save();
DesktopGridConfig::setDesktopNameAlignment(m_ui.desktopNameAlignmentCombo->itemData(m_ui.desktopNameAlignmentCombo->currentIndex()).toInt());
KCModule::save();
DesktopGridConfig::self()->save();
......@@ -100,26 +98,26 @@ void DesktopGridEffectConfig::save()
void DesktopGridEffectConfig::load()
{
KCModule::load();
m_ui->desktopNameAlignmentCombo->setCurrentIndex(m_ui->desktopNameAlignmentCombo->findData(QVariant(DesktopGridConfig::desktopNameAlignment())));
m_ui.desktopNameAlignmentCombo->setCurrentIndex(m_ui.desktopNameAlignmentCombo->findData(QVariant(DesktopGridConfig::desktopNameAlignment())));
desktopLayoutSelectionChanged();
}
void DesktopGridEffectConfig::desktopLayoutSelectionChanged()
{
if (m_ui->kcfg_DesktopLayoutMode->currentIndex() == int(DesktopGridEffect::DesktopLayoutMode::LayoutCustom)) {
m_ui->layoutRowsLabel->setEnabled(true);
m_ui->kcfg_CustomLayoutRows->setEnabled(true);
if (m_ui.kcfg_DesktopLayoutMode->currentIndex() == int(DesktopGridEffect::DesktopLayoutMode::LayoutCustom)) {
m_ui.layoutRowsLabel->setEnabled(true);
m_ui.kcfg_CustomLayoutRows->setEnabled(true);
} else {
m_ui->layoutRowsLabel->setEnabled(false);
m_ui->kcfg_CustomLayoutRows->setEnabled(false);
m_ui.layoutRowsLabel->setEnabled(false);
m_ui.kcfg_CustomLayoutRows->setEnabled(false);
}
}
void DesktopGridEffectConfig::defaults()
{
KCModule::defaults();
m_ui->desktopNameAlignmentCombo->setCurrentIndex(0);
m_ui.desktopNameAlignmentCombo->setCurrentIndex(0);
}
} // namespace
......
......@@ -42,7 +42,7 @@ private Q_SLOTS:
void desktopLayoutSelectionChanged();
private:
DesktopGridEffectConfigForm *m_ui;
DesktopGridEffectConfigForm m_ui;
KActionCollection *m_actionCollection;
};
......
......@@ -56,10 +56,7 @@ InvertEffect::InvertEffect()
connect(effects, &EffectsHandler::windowClosed, this, &InvertEffect::slotWindowClosed);
}
InvertEffect::~InvertEffect()
{
delete m_shader;
}
InvertEffect::~InvertEffect() = default;
bool InvertEffect::supported()
{
......@@ -90,9 +87,9 @@ void InvertEffect::drawWindow(EffectWindow *w, int mask, const QRegion &region,
bool useShader = m_valid && (m_allWindows != m_windows.contains(w));
if (useShader) {
ShaderManager *shaderManager = ShaderManager::instance();
shaderManager->pushShader(m_shader);
shaderManager->pushShader(m_shader.get());
data.shader = m_shader;
data.shader = m_shader.get();
}
effects->drawWindow(w, mask, region, data);
......
......@@ -21,8 +21,7 @@ class GLShader;
/**
* Inverts desktop's colors
*/
class InvertEffect
: public Effect
class InvertEffect : public Effect
{
Q_OBJECT
public:
......@@ -48,7 +47,7 @@ protected:
private:
bool m_inited;
bool m_valid;
GLShader *m_shader;
std::unique_ptr<GLShader> m_shader;
bool m_allWindows;
QList<EffectWindow *> m_windows;
};
......
......@@ -73,13 +73,7 @@ LookingGlassEffect::LookingGlassEffect()
reconfigure(ReconfigureAll);
}
LookingGlassEffect::~LookingGlassEffect()
{
delete m_texture;
delete m_fbo;
delete m_shader;
delete m_vbo;
}
LookingGlassEffect::~LookingGlassEffect() = default