2013-06-25 14:07:48 +00:00
|
|
|
/**************************************************************************
|
|
|
|
* KWin - the KDE window manager *
|
|
|
|
* This file is part of the KDE project. *
|
|
|
|
* *
|
|
|
|
* Copyright (C) 2013 Antonis Tsiapaliokas <kok3rs@gmail.com> *
|
2013-12-02 08:55:21 +00:00
|
|
|
* Copyright (C) 2013 Martin Gräßlin <mgraesslin@kde.org> *
|
2013-06-25 14:07:48 +00:00
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
2014-05-23 08:11:02 +00:00
|
|
|
#include "ui_compositing.h"
|
KCM/Compositing: Use KConfig XT in UI
Summary:
Use KConfig XT to manage most fields of the KCM.
Simplify code.
Depends on D27955
Test Plan: No functional change
Reviewers: #kwin, ervin, crossi, bport, hchain, zzag
Reviewed By: #kwin, ervin, bport, zzag
Subscribers: anthonyfieroni, zzag, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D27988
2020-04-20 08:10:45 +00:00
|
|
|
#include <kwin_compositing_interface.h>
|
|
|
|
|
2018-02-28 18:02:33 +00:00
|
|
|
#include <QAction>
|
2013-06-25 14:07:48 +00:00
|
|
|
#include <QApplication>
|
2013-12-02 08:55:21 +00:00
|
|
|
#include <QLayout>
|
2013-06-25 14:07:48 +00:00
|
|
|
|
2013-12-02 08:55:21 +00:00
|
|
|
#include <kcmodule.h>
|
|
|
|
#include <kservice.h>
|
2013-09-10 08:41:42 +00:00
|
|
|
|
2019-09-25 13:49:52 +00:00
|
|
|
#include <algorithm>
|
|
|
|
#include <functional>
|
|
|
|
|
KCM/Compositing: Use KConfig XT in UI
Summary:
Use KConfig XT to manage most fields of the KCM.
Simplify code.
Depends on D27955
Test Plan: No functional change
Reviewers: #kwin, ervin, crossi, bport, hchain, zzag
Reviewed By: #kwin, ervin, bport, zzag
Subscribers: anthonyfieroni, zzag, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D27988
2020-04-20 08:10:45 +00:00
|
|
|
#include "kwincompositing_setting.h"
|
|
|
|
|
|
|
|
static bool isRunningPlasma()
|
|
|
|
{
|
|
|
|
return qgetenv("XDG_CURRENT_DESKTOP") == "KDE";
|
|
|
|
}
|
|
|
|
|
2020-03-20 09:34:08 +00:00
|
|
|
class KWinCompositingKCM : public KCModule
|
2014-03-07 09:09:47 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
KCM/Compositing: Use KConfig XT in UI
Summary:
Use KConfig XT to manage most fields of the KCM.
Simplify code.
Depends on D27955
Test Plan: No functional change
Reviewers: #kwin, ervin, crossi, bport, hchain, zzag
Reviewed By: #kwin, ervin, bport, zzag
Subscribers: anthonyfieroni, zzag, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D27988
2020-04-20 08:10:45 +00:00
|
|
|
enum CompositingTypeIndex {
|
|
|
|
OPENGL31_INDEX = 0,
|
|
|
|
OPENGL20_INDEX,
|
|
|
|
XRENDER_INDEX
|
|
|
|
};
|
|
|
|
|
2020-03-20 09:34:08 +00:00
|
|
|
explicit KWinCompositingKCM(QWidget *parent = nullptr, const QVariantList &args = QVariantList());
|
2014-05-23 08:11:02 +00:00
|
|
|
|
|
|
|
public Q_SLOTS:
|
|
|
|
void load() override;
|
|
|
|
void save() override;
|
|
|
|
void defaults() override;
|
|
|
|
|
KCM/Compositing: Use KConfig XT in UI
Summary:
Use KConfig XT to manage most fields of the KCM.
Simplify code.
Depends on D27955
Test Plan: No functional change
Reviewers: #kwin, ervin, crossi, bport, hchain, zzag
Reviewed By: #kwin, ervin, bport, zzag
Subscribers: anthonyfieroni, zzag, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D27988
2020-04-20 08:10:45 +00:00
|
|
|
private Q_SLOTS:
|
|
|
|
void onBackendChanged();
|
|
|
|
void reenableGl();
|
|
|
|
|
2014-05-23 08:11:02 +00:00
|
|
|
private:
|
|
|
|
void init();
|
KCM/Compositing: Use KConfig XT in UI
Summary:
Use KConfig XT to manage most fields of the KCM.
Simplify code.
Depends on D27955
Test Plan: No functional change
Reviewers: #kwin, ervin, crossi, bport, hchain, zzag
Reviewed By: #kwin, ervin, bport, zzag
Subscribers: anthonyfieroni, zzag, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D27988
2020-04-20 08:10:45 +00:00
|
|
|
void updateUnmanagedItemStatus();
|
|
|
|
bool compositingRequired() const;
|
|
|
|
|
2014-05-23 08:11:02 +00:00
|
|
|
Ui_CompositingForm m_form;
|
KCM/Compositing: Use KConfig XT in UI
Summary:
Use KConfig XT to manage most fields of the KCM.
Simplify code.
Depends on D27955
Test Plan: No functional change
Reviewers: #kwin, ervin, crossi, bport, hchain, zzag
Reviewed By: #kwin, ervin, bport, zzag
Subscribers: anthonyfieroni, zzag, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D27988
2020-04-20 08:10:45 +00:00
|
|
|
|
|
|
|
OrgKdeKwinCompositingInterface *m_compositingInterface;
|
|
|
|
KWinCompositingSetting *m_settings;
|
|
|
|
|
|
|
|
// unmanaged states
|
|
|
|
int m_backend;
|
|
|
|
bool m_glCore;
|
|
|
|
double m_animationDurationFactor;
|
2014-03-07 09:09:47 +00:00
|
|
|
};
|
|
|
|
|
2019-09-25 13:49:52 +00:00
|
|
|
static const QVector<qreal> s_animationMultipliers = {8, 4, 2, 1, 0.5, 0.25, 0.125, 0};
|
|
|
|
|
KCM/Compositing: Use KConfig XT in UI
Summary:
Use KConfig XT to manage most fields of the KCM.
Simplify code.
Depends on D27955
Test Plan: No functional change
Reviewers: #kwin, ervin, crossi, bport, hchain, zzag
Reviewed By: #kwin, ervin, bport, zzag
Subscribers: anthonyfieroni, zzag, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D27988
2020-04-20 08:10:45 +00:00
|
|
|
bool KWinCompositingKCM::compositingRequired() const
|
|
|
|
{
|
|
|
|
return m_compositingInterface->platformRequiresCompositing();
|
|
|
|
}
|
|
|
|
|
2020-03-20 09:34:08 +00:00
|
|
|
KWinCompositingKCM::KWinCompositingKCM(QWidget *parent, const QVariantList &args)
|
2014-05-23 08:11:02 +00:00
|
|
|
: KCModule(parent, args)
|
KCM/Compositing: Use KConfig XT in UI
Summary:
Use KConfig XT to manage most fields of the KCM.
Simplify code.
Depends on D27955
Test Plan: No functional change
Reviewers: #kwin, ervin, crossi, bport, hchain, zzag
Reviewed By: #kwin, ervin, bport, zzag
Subscribers: anthonyfieroni, zzag, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D27988
2020-04-20 08:10:45 +00:00
|
|
|
, m_compositingInterface(new OrgKdeKwinCompositingInterface(QStringLiteral("org.kde.KWin"), QStringLiteral("/Compositor"), QDBusConnection::sessionBus(), this))
|
|
|
|
, m_settings(new KWinCompositingSetting(this))
|
2014-05-23 08:11:02 +00:00
|
|
|
{
|
|
|
|
m_form.setupUi(this);
|
KCM/Compositing: Use KConfig XT in UI
Summary:
Use KConfig XT to manage most fields of the KCM.
Simplify code.
Depends on D27955
Test Plan: No functional change
Reviewers: #kwin, ervin, crossi, bport, hchain, zzag
Reviewed By: #kwin, ervin, bport, zzag
Subscribers: anthonyfieroni, zzag, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D27988
2020-04-20 08:10:45 +00:00
|
|
|
addConfig(m_settings, this);
|
|
|
|
|
2014-06-03 09:39:10 +00:00
|
|
|
m_form.glCrashedWarning->setIcon(QIcon::fromTheme(QStringLiteral("dialog-warning")));
|
KCM/Compositing: Use KConfig XT in UI
Summary:
Use KConfig XT to manage most fields of the KCM.
Simplify code.
Depends on D27955
Test Plan: No functional change
Reviewers: #kwin, ervin, crossi, bport, hchain, zzag
Reviewed By: #kwin, ervin, bport, zzag
Subscribers: anthonyfieroni, zzag, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D27988
2020-04-20 08:10:45 +00:00
|
|
|
QAction *reenableGlAction = new QAction(i18n("Re-enable OpenGL detection"), this);
|
|
|
|
connect(reenableGlAction, &QAction::triggered, this, &KWinCompositingKCM::reenableGl);
|
|
|
|
connect(reenableGlAction, &QAction::triggered, m_form.glCrashedWarning, &KMessageWidget::animatedHide);
|
|
|
|
m_form.glCrashedWarning->addAction(reenableGlAction);
|
2014-06-03 09:39:10 +00:00
|
|
|
m_form.scaleWarning->setIcon(QIcon::fromTheme(QStringLiteral("dialog-warning")));
|
|
|
|
m_form.tearingWarning->setIcon(QIcon::fromTheme(QStringLiteral("dialog-warning")));
|
|
|
|
m_form.windowThumbnailWarning->setIcon(QIcon::fromTheme(QStringLiteral("dialog-warning")));
|
2014-05-23 08:11:02 +00:00
|
|
|
|
KCM/Compositing: Use KConfig XT in UI
Summary:
Use KConfig XT to manage most fields of the KCM.
Simplify code.
Depends on D27955
Test Plan: No functional change
Reviewers: #kwin, ervin, crossi, bport, hchain, zzag
Reviewed By: #kwin, ervin, bport, zzag
Subscribers: anthonyfieroni, zzag, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D27988
2020-04-20 08:10:45 +00:00
|
|
|
m_form.kcfg_Enabled->setVisible(!compositingRequired());
|
|
|
|
m_form.kcfg_WindowsBlockCompositing->setVisible(!compositingRequired());
|
2016-08-26 10:56:25 +00:00
|
|
|
|
2014-05-23 08:11:02 +00:00
|
|
|
init();
|
|
|
|
}
|
|
|
|
|
KCM/Compositing: Use KConfig XT in UI
Summary:
Use KConfig XT to manage most fields of the KCM.
Simplify code.
Depends on D27955
Test Plan: No functional change
Reviewers: #kwin, ervin, crossi, bport, hchain, zzag
Reviewed By: #kwin, ervin, bport, zzag
Subscribers: anthonyfieroni, zzag, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D27988
2020-04-20 08:10:45 +00:00
|
|
|
void KWinCompositingKCM::reenableGl()
|
|
|
|
{
|
|
|
|
m_settings->setOpenGLIsUnsafe(false);
|
|
|
|
m_settings->save();
|
|
|
|
}
|
|
|
|
|
2020-03-20 09:34:08 +00:00
|
|
|
void KWinCompositingKCM::init()
|
2014-05-23 08:11:02 +00:00
|
|
|
{
|
|
|
|
auto currentIndexChangedSignal = static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged);
|
|
|
|
|
|
|
|
// animation speed
|
KCM/Compositing: Use KConfig XT in UI
Summary:
Use KConfig XT to manage most fields of the KCM.
Simplify code.
Depends on D27955
Test Plan: No functional change
Reviewers: #kwin, ervin, crossi, bport, hchain, zzag
Reviewed By: #kwin, ervin, bport, zzag
Subscribers: anthonyfieroni, zzag, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D27988
2020-04-20 08:10:45 +00:00
|
|
|
m_form.animationDurationFactor->setMaximum(s_animationMultipliers.size() - 1);
|
|
|
|
connect(m_form.animationDurationFactor, &QSlider::valueChanged, this, [this]() {
|
|
|
|
m_settings->setAnimationDurationFactor(s_animationMultipliers[m_form.animationDurationFactor->value()]);
|
|
|
|
updateUnmanagedItemStatus();
|
2019-09-25 13:49:52 +00:00
|
|
|
});
|
|
|
|
|
KCM/Compositing: Use KConfig XT in UI
Summary:
Use KConfig XT to manage most fields of the KCM.
Simplify code.
Depends on D27955
Test Plan: No functional change
Reviewers: #kwin, ervin, crossi, bport, hchain, zzag
Reviewed By: #kwin, ervin, bport, zzag
Subscribers: anthonyfieroni, zzag, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D27988
2020-04-20 08:10:45 +00:00
|
|
|
if (isRunningPlasma()) {
|
2019-09-25 13:49:52 +00:00
|
|
|
m_form.animationSpeedLabel->hide();
|
|
|
|
m_form.animationSpeedControls->hide();
|
|
|
|
}
|
2014-05-23 08:11:02 +00:00
|
|
|
|
|
|
|
// gl scale filter
|
KCM/Compositing: Use KConfig XT in UI
Summary:
Use KConfig XT to manage most fields of the KCM.
Simplify code.
Depends on D27955
Test Plan: No functional change
Reviewers: #kwin, ervin, crossi, bport, hchain, zzag
Reviewed By: #kwin, ervin, bport, zzag
Subscribers: anthonyfieroni, zzag, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D27988
2020-04-20 08:10:45 +00:00
|
|
|
connect(m_form.kcfg_glTextureFilter, currentIndexChangedSignal, this,
|
2014-06-03 09:39:10 +00:00
|
|
|
[this](int index) {
|
|
|
|
if (index == 2) {
|
|
|
|
m_form.scaleWarning->animatedShow();
|
|
|
|
} else {
|
|
|
|
m_form.scaleWarning->animatedHide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
2014-05-23 08:11:02 +00:00
|
|
|
|
|
|
|
// tearing prevention
|
KCM/Compositing: Use KConfig XT in UI
Summary:
Use KConfig XT to manage most fields of the KCM.
Simplify code.
Depends on D27955
Test Plan: No functional change
Reviewers: #kwin, ervin, crossi, bport, hchain, zzag
Reviewed By: #kwin, ervin, bport, zzag
Subscribers: anthonyfieroni, zzag, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D27988
2020-04-20 08:10:45 +00:00
|
|
|
connect(m_form.kcfg_glPreferBufferSwap, currentIndexChangedSignal, this,
|
2014-06-03 09:39:10 +00:00
|
|
|
[this](int index) {
|
|
|
|
if (index == 2) {
|
|
|
|
// only when cheap - tearing
|
|
|
|
m_form.tearingWarning->setText(i18n("\"Only when cheap\" only prevents tearing for full screen changes like a video."));
|
|
|
|
m_form.tearingWarning->animatedShow();
|
|
|
|
} else if (index == 3) {
|
|
|
|
// full screen repaints
|
|
|
|
m_form.tearingWarning->setText(i18n("\"Full screen repaints\" can cause performance problems."));
|
|
|
|
m_form.tearingWarning->animatedShow();
|
|
|
|
} else if (index == 4) {
|
|
|
|
// re-use screen content
|
2016-02-15 08:39:03 +00:00
|
|
|
m_form.tearingWarning->setText(i18n("\"Re-use screen content\" causes severe performance problems on MESA drivers."));
|
2014-06-03 09:39:10 +00:00
|
|
|
m_form.tearingWarning->animatedShow();
|
|
|
|
} else {
|
|
|
|
m_form.tearingWarning->animatedHide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
2014-05-23 08:11:02 +00:00
|
|
|
|
|
|
|
// windowThumbnail
|
KCM/Compositing: Use KConfig XT in UI
Summary:
Use KConfig XT to manage most fields of the KCM.
Simplify code.
Depends on D27955
Test Plan: No functional change
Reviewers: #kwin, ervin, crossi, bport, hchain, zzag
Reviewed By: #kwin, ervin, bport, zzag
Subscribers: anthonyfieroni, zzag, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D27988
2020-04-20 08:10:45 +00:00
|
|
|
connect(m_form.kcfg_HiddenPreviews, currentIndexChangedSignal, this,
|
2014-06-03 09:39:10 +00:00
|
|
|
[this](int index) {
|
2015-02-04 13:03:50 +00:00
|
|
|
if (index == 2) {
|
2014-06-03 09:39:10 +00:00
|
|
|
m_form.windowThumbnailWarning->animatedShow();
|
|
|
|
} else {
|
|
|
|
m_form.windowThumbnailWarning->animatedHide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
2014-05-23 08:11:02 +00:00
|
|
|
|
|
|
|
// compositing type
|
KCM/Compositing: Use KConfig XT in UI
Summary:
Use KConfig XT to manage most fields of the KCM.
Simplify code.
Depends on D27955
Test Plan: No functional change
Reviewers: #kwin, ervin, crossi, bport, hchain, zzag
Reviewed By: #kwin, ervin, bport, zzag
Subscribers: anthonyfieroni, zzag, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D27988
2020-04-20 08:10:45 +00:00
|
|
|
m_form.backend->addItem(i18n("OpenGL 3.1"), CompositingTypeIndex::OPENGL31_INDEX);
|
|
|
|
m_form.backend->addItem(i18n("OpenGL 2.0"), CompositingTypeIndex::OPENGL20_INDEX);
|
|
|
|
m_form.backend->addItem(i18n("XRender"), CompositingTypeIndex::XRENDER_INDEX);
|
|
|
|
|
|
|
|
connect(m_form.backend, currentIndexChangedSignal, this, &KWinCompositingKCM::onBackendChanged);
|
2014-06-03 09:39:10 +00:00
|
|
|
|
KCM/Compositing: Use KConfig XT in UI
Summary:
Use KConfig XT to manage most fields of the KCM.
Simplify code.
Depends on D27955
Test Plan: No functional change
Reviewers: #kwin, ervin, crossi, bport, hchain, zzag
Reviewed By: #kwin, ervin, bport, zzag
Subscribers: anthonyfieroni, zzag, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D27988
2020-04-20 08:10:45 +00:00
|
|
|
if (m_settings->openGLIsUnsafe()) {
|
2014-06-03 09:39:10 +00:00
|
|
|
m_form.glCrashedWarning->animatedShow();
|
|
|
|
}
|
2014-05-23 08:11:02 +00:00
|
|
|
}
|
|
|
|
|
KCM/Compositing: Use KConfig XT in UI
Summary:
Use KConfig XT to manage most fields of the KCM.
Simplify code.
Depends on D27955
Test Plan: No functional change
Reviewers: #kwin, ervin, crossi, bport, hchain, zzag
Reviewed By: #kwin, ervin, bport, zzag
Subscribers: anthonyfieroni, zzag, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D27988
2020-04-20 08:10:45 +00:00
|
|
|
void KWinCompositingKCM::onBackendChanged()
|
|
|
|
{
|
|
|
|
const int currentType = m_form.backend->currentData().toInt();
|
|
|
|
|
|
|
|
m_form.kcfg_glTextureFilter->setVisible(currentType != CompositingTypeIndex::XRENDER_INDEX);
|
|
|
|
m_form.kcfg_XRenderSmoothScale->setVisible(currentType == CompositingTypeIndex::XRENDER_INDEX);
|
|
|
|
|
|
|
|
updateUnmanagedItemStatus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void KWinCompositingKCM::updateUnmanagedItemStatus()
|
|
|
|
{
|
|
|
|
int backend = KWinCompositingSetting::EnumBackend::OpenGL;
|
|
|
|
bool glCore = true;
|
|
|
|
const int currentType = m_form.backend->currentData().toInt();
|
|
|
|
switch (currentType) {
|
|
|
|
case CompositingTypeIndex::OPENGL31_INDEX:
|
|
|
|
// default already set
|
|
|
|
break;
|
|
|
|
case CompositingTypeIndex::OPENGL20_INDEX:
|
|
|
|
glCore = false;
|
|
|
|
break;
|
|
|
|
case CompositingTypeIndex::XRENDER_INDEX:
|
|
|
|
backend = KWinCompositingSetting::EnumBackend::XRender;
|
|
|
|
glCore = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
const auto animationDuration = s_animationMultipliers[m_form.animationDurationFactor->value()];
|
|
|
|
|
|
|
|
const bool inPlasma = isRunningPlasma();
|
|
|
|
|
|
|
|
bool changed = glCore != m_glCore;
|
|
|
|
changed |= backend != m_backend;
|
|
|
|
if (!inPlasma) {
|
|
|
|
changed |= (animationDuration != m_animationDurationFactor);
|
|
|
|
}
|
|
|
|
unmanagedWidgetChangeState(changed);
|
|
|
|
|
|
|
|
bool defaulted = glCore == m_settings->defaultGlCoreValue();
|
|
|
|
defaulted &= backend == m_settings->defaultBackendValue();
|
|
|
|
if (!inPlasma) {
|
|
|
|
defaulted &= animationDuration == m_settings->defaultAnimationDurationFactorValue();
|
|
|
|
}
|
|
|
|
unmanagedWidgetDefaultState(defaulted);
|
|
|
|
}
|
|
|
|
|
2020-03-20 09:34:08 +00:00
|
|
|
void KWinCompositingKCM::load()
|
2014-05-23 08:11:02 +00:00
|
|
|
{
|
|
|
|
KCModule::load();
|
KCM/Compositing: Use KConfig XT in UI
Summary:
Use KConfig XT to manage most fields of the KCM.
Simplify code.
Depends on D27955
Test Plan: No functional change
Reviewers: #kwin, ervin, crossi, bport, hchain, zzag
Reviewed By: #kwin, ervin, bport, zzag
Subscribers: anthonyfieroni, zzag, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D27988
2020-04-20 08:10:45 +00:00
|
|
|
|
|
|
|
// unmanaged items
|
|
|
|
m_settings->findItem("AnimationDurationFactor")->readConfig(m_settings->config());
|
|
|
|
const double multiplier = m_settings->animationDurationFactor();
|
|
|
|
auto const it = std::lower_bound(s_animationMultipliers.begin(), s_animationMultipliers.end(), multiplier, std::greater<qreal>());
|
|
|
|
const int index = static_cast<int>(std::distance(s_animationMultipliers.begin(), it));
|
|
|
|
m_form.animationDurationFactor->setValue(index);
|
|
|
|
m_form.animationDurationFactor->setDisabled(m_settings->isAnimationDurationFactorImmutable());
|
|
|
|
|
|
|
|
m_settings->findItem("Backend")->readConfig(m_settings->config());
|
|
|
|
m_settings->findItem("glCore")->readConfig(m_settings->config());
|
|
|
|
m_backend = m_settings->backend();
|
|
|
|
m_glCore = m_settings->glCore();
|
|
|
|
if (m_backend == KWinCompositingSetting::EnumBackend::OpenGL) {
|
|
|
|
if (m_glCore) {
|
|
|
|
m_form.backend->setCurrentIndex(CompositingTypeIndex::OPENGL31_INDEX);
|
|
|
|
} else {
|
|
|
|
m_form.backend->setCurrentIndex(CompositingTypeIndex::OPENGL20_INDEX);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
m_form.backend->setCurrentIndex(CompositingTypeIndex::XRENDER_INDEX);
|
|
|
|
}
|
|
|
|
m_form.backend->setDisabled(m_settings->isBackendImmutable());
|
|
|
|
|
|
|
|
onBackendChanged();
|
2014-05-23 08:11:02 +00:00
|
|
|
}
|
|
|
|
|
2020-03-20 09:34:08 +00:00
|
|
|
void KWinCompositingKCM::defaults()
|
2014-05-23 08:11:02 +00:00
|
|
|
{
|
|
|
|
KCModule::defaults();
|
KCM/Compositing: Use KConfig XT in UI
Summary:
Use KConfig XT to manage most fields of the KCM.
Simplify code.
Depends on D27955
Test Plan: No functional change
Reviewers: #kwin, ervin, crossi, bport, hchain, zzag
Reviewed By: #kwin, ervin, bport, zzag
Subscribers: anthonyfieroni, zzag, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D27988
2020-04-20 08:10:45 +00:00
|
|
|
|
|
|
|
// unmanaged widgets
|
|
|
|
m_form.backend->setCurrentIndex(CompositingTypeIndex::OPENGL20_INDEX);
|
|
|
|
// corresponds to 1.0 seconds in s_animationMultipliers
|
|
|
|
m_form.animationDurationFactor->setValue(3);
|
2014-05-23 08:11:02 +00:00
|
|
|
}
|
|
|
|
|
2020-03-20 09:34:08 +00:00
|
|
|
void KWinCompositingKCM::save()
|
2014-05-23 08:11:02 +00:00
|
|
|
{
|
KCM/Compositing: Use KConfig XT in UI
Summary:
Use KConfig XT to manage most fields of the KCM.
Simplify code.
Depends on D27955
Test Plan: No functional change
Reviewers: #kwin, ervin, crossi, bport, hchain, zzag
Reviewed By: #kwin, ervin, bport, zzag
Subscribers: anthonyfieroni, zzag, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D27988
2020-04-20 08:10:45 +00:00
|
|
|
int backend = KWinCompositingSetting::EnumBackend::OpenGL;
|
|
|
|
bool glCore = true;
|
|
|
|
const int currentType = m_form.backend->currentData().toInt();
|
|
|
|
switch (currentType) {
|
|
|
|
case CompositingTypeIndex::OPENGL31_INDEX:
|
|
|
|
// default already set
|
|
|
|
break;
|
|
|
|
case CompositingTypeIndex::OPENGL20_INDEX:
|
|
|
|
backend = KWinCompositingSetting::EnumBackend::OpenGL;
|
|
|
|
glCore = false;
|
|
|
|
break;
|
|
|
|
case CompositingTypeIndex::XRENDER_INDEX:
|
|
|
|
backend = KWinCompositingSetting::EnumBackend::XRender;
|
|
|
|
glCore = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
m_settings->setBackend(backend);
|
|
|
|
m_settings->setGlCore(glCore);
|
|
|
|
|
|
|
|
const auto animationDuration = s_animationMultipliers[m_form.animationDurationFactor->value()];
|
|
|
|
m_settings->setAnimationDurationFactor(animationDuration);
|
|
|
|
m_settings->save();
|
|
|
|
|
2014-05-23 08:11:02 +00:00
|
|
|
KCModule::save();
|
KCM/Compositing: Use KConfig XT in UI
Summary:
Use KConfig XT to manage most fields of the KCM.
Simplify code.
Depends on D27955
Test Plan: No functional change
Reviewers: #kwin, ervin, crossi, bport, hchain, zzag
Reviewed By: #kwin, ervin, bport, zzag
Subscribers: anthonyfieroni, zzag, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D27988
2020-04-20 08:10:45 +00:00
|
|
|
|
|
|
|
// Send signal to all kwin instances
|
|
|
|
QDBusMessage message = QDBusMessage::createSignal(QStringLiteral("/Compositor"),
|
|
|
|
QStringLiteral("org.kde.kwin.Compositing"),
|
|
|
|
QStringLiteral("reinit"));
|
|
|
|
QDBusConnection::sessionBus().send(message);
|
2014-05-23 08:11:02 +00:00
|
|
|
}
|
|
|
|
|
2013-12-02 08:55:21 +00:00
|
|
|
K_PLUGIN_FACTORY(KWinCompositingConfigFactory,
|
2020-03-20 09:34:08 +00:00
|
|
|
registerPlugin<KWinCompositingKCM>("compositing");
|
2013-12-02 08:55:21 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
#include "main.moc"
|