Changeset View
Standalone View
kcmkwin/kwincompositing/main.cpp
Show All 14 Lines | |||||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||
16 | * GNU General Public License for more details. * | 16 | * GNU General Public License for more details. * | ||
17 | * * | 17 | * * | ||
18 | * You should have received a copy of the GNU General Public License * | 18 | * You should have received a copy of the GNU General Public License * | ||
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. * | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. * | ||
20 | **************************************************************************/ | 20 | **************************************************************************/ | ||
21 | 21 | | |||
22 | 22 | | |||
23 | #include "compositing.h" | | |||
24 | #include "ui_compositing.h" | 23 | #include "ui_compositing.h" | ||
24 | #include <kwin_compositing_interface.h> | ||||
25 | | ||||
25 | #include <QAction> | 26 | #include <QAction> | ||
26 | #include <QApplication> | 27 | #include <QApplication> | ||
27 | #include <QLayout> | 28 | #include <QLayout> | ||
28 | 29 | | |||
29 | #include <kcmodule.h> | 30 | #include <kcmodule.h> | ||
30 | #include <kservice.h> | 31 | #include <kservice.h> | ||
31 | 32 | | |||
32 | #include <algorithm> | 33 | #include <algorithm> | ||
33 | #include <functional> | 34 | #include <functional> | ||
34 | 35 | | |||
36 | #include "kwincompositing_setting.h" | ||||
37 | | ||||
38 | static bool isRunningPlasma() { | ||||
zzag: Put the opening brace on newline. | |||||
39 | return qgetenv("XDG_CURRENT_DESKTOP") == "KDE"; | ||||
40 | } | ||||
Since isRunningPlasma is static, you don't need to put it in an anonymous namespace. Also, coding style nitpick: { must be on its own line. zzag: Since isRunningPlasma is static, you don't need to put it in an anonymous namespace. Also… | |||||
41 | | ||||
35 | class KWinCompositingKCM : public KCModule | 42 | class KWinCompositingKCM : public KCModule | ||
36 | { | 43 | { | ||
37 | Q_OBJECT | 44 | Q_OBJECT | ||
38 | public: | 45 | public: | ||
46 | enum CompositingTypeIndex { | ||||
47 | OPENGL31_INDEX = 0, | ||||
48 | OPENGL20_INDEX, | ||||
49 | XRENDER_INDEX | ||||
50 | }; | ||||
51 | | ||||
39 | explicit KWinCompositingKCM(QWidget *parent = nullptr, const QVariantList &args = QVariantList()); | 52 | explicit KWinCompositingKCM(QWidget *parent = nullptr, const QVariantList &args = QVariantList()); | ||
40 | 53 | | |||
41 | public Q_SLOTS: | 54 | public Q_SLOTS: | ||
42 | void load() override; | 55 | void load() override; | ||
43 | void save() override; | 56 | void save() override; | ||
44 | void defaults() override; | 57 | void defaults() override; | ||
45 | 58 | | |||
59 | private Q_SLOTS: | ||||
60 | void onBackendChanged(); | ||||
61 | void reenableGl(); | ||||
That one was oddly fine (yes, Qt is inconsistent with dealing with GL and we are as well ;-)) ervin: That one was oddly fine (yes, Qt is inconsistent with dealing with GL and we are as well ;-)) | |||||
62 | | ||||
46 | private: | 63 | private: | ||
47 | void init(); | 64 | void init(); | ||
48 | KWin::Compositing::Compositing *m_compositing; | 65 | void updateUnmanagedItemStatus(); | ||
66 | bool compositingRequired() const; | ||||
zzag: Make it static. | |||||
67 | | ||||
zzag: typo: Unnamaged | |||||
49 | Ui_CompositingForm m_form; | 68 | Ui_CompositingForm m_form; | ||
69 | | ||||
70 | OrgKdeKwinCompositingInterface *m_compositingInterface; | ||||
71 | KWinCompositingSetting *m_settings; | ||||
72 | | ||||
73 | // unmanaged states | ||||
74 | int m_backend; | ||||
75 | bool m_glCore; | ||||
76 | double m_animationDurationFactor; | ||||
50 | }; | 77 | }; | ||
51 | 78 | | |||
52 | static const QVector<qreal> s_animationMultipliers = {8, 4, 2, 1, 0.5, 0.25, 0.125, 0}; | 79 | static const QVector<qreal> s_animationMultipliers = {8, 4, 2, 1, 0.5, 0.25, 0.125, 0}; | ||
53 | 80 | | |||
81 | bool KWinCompositingKCM::compositingRequired() const | ||||
82 | { | ||||
83 | return m_compositingInterface->platformRequiresCompositing(); | ||||
84 | } | ||||
85 | | ||||
54 | KWinCompositingKCM::KWinCompositingKCM(QWidget *parent, const QVariantList &args) | 86 | KWinCompositingKCM::KWinCompositingKCM(QWidget *parent, const QVariantList &args) | ||
55 | : KCModule(parent, args) | 87 | : KCModule(parent, args) | ||
56 | , m_compositing(new KWin::Compositing::Compositing(this)) | 88 | , m_compositingInterface(new OrgKdeKwinCompositingInterface(QStringLiteral("org.kde.KWin"), QStringLiteral("/Compositor"), QDBusConnection::sessionBus(), this)) | ||
89 | , m_settings(new KWinCompositingSetting(this)) | ||||
Please don't submit commented code unless there is a reason, which must be stated in a comment. zzag: Please don't submit commented code unless there is a reason, which must be stated in a comment. | |||||
57 | { | 90 | { | ||
zzag: Is there a reason why the parent is not `this`? | |||||
58 | m_form.setupUi(this); | 91 | m_form.setupUi(this); | ||
92 | addConfig(m_settings, this); | ||||
93 | | ||||
59 | m_form.glCrashedWarning->setIcon(QIcon::fromTheme(QStringLiteral("dialog-warning"))); | 94 | m_form.glCrashedWarning->setIcon(QIcon::fromTheme(QStringLiteral("dialog-warning"))); | ||
60 | QAction *reenableGLAction = new QAction(i18n("Re-enable OpenGL detection"), this); | 95 | QAction *reenableGlAction = new QAction(i18n("Re-enable OpenGL detection"), this); | ||
zzag: We don't capture any variable so there is no point for using a lambda. | |||||
Well, this is captured because of m_settings, isn't it? It would be nice to have this as third connect parameter though. ervin: Well, this is captured because of m_settings, isn't it?
It would be nice to have this as third… | |||||
Yes, this is captured but I would say it's not an excuse for using a lambda. A method would be more appropriate in this case. zzag: Yes, this is captured but I would say it's not an excuse for using a lambda. A method would be… | |||||
61 | connect(reenableGLAction, &QAction::triggered, m_compositing, &KWin::Compositing::Compositing::reenableOpenGLDetection); | 96 | connect(reenableGlAction, &QAction::triggered, this, &KWinCompositingKCM::reenableGl); | ||
62 | connect(reenableGLAction, &QAction::triggered, m_form.glCrashedWarning, &KMessageWidget::animatedHide); | 97 | connect(reenableGlAction, &QAction::triggered, m_form.glCrashedWarning, &KMessageWidget::animatedHide); | ||
63 | m_form.glCrashedWarning->addAction(reenableGLAction); | 98 | m_form.glCrashedWarning->addAction(reenableGlAction); | ||
64 | m_form.scaleWarning->setIcon(QIcon::fromTheme(QStringLiteral("dialog-warning"))); | 99 | m_form.scaleWarning->setIcon(QIcon::fromTheme(QStringLiteral("dialog-warning"))); | ||
65 | m_form.tearingWarning->setIcon(QIcon::fromTheme(QStringLiteral("dialog-warning"))); | 100 | m_form.tearingWarning->setIcon(QIcon::fromTheme(QStringLiteral("dialog-warning"))); | ||
66 | m_form.windowThumbnailWarning->setIcon(QIcon::fromTheme(QStringLiteral("dialog-warning"))); | 101 | m_form.windowThumbnailWarning->setIcon(QIcon::fromTheme(QStringLiteral("dialog-warning"))); | ||
67 | 102 | | |||
68 | m_form.compositingEnabled->setVisible(!m_compositing->compositingRequired()); | 103 | m_form.kcfg_Enabled->setVisible(!compositingRequired()); | ||
69 | m_form.windowsBlockCompositing->setVisible(!m_compositing->compositingRequired()); | 104 | m_form.kcfg_WindowsBlockCompositing->setVisible(!compositingRequired()); | ||
stray whitespace between "kcfg_WindowsBlockCompositing" and "->". Please remove it. zzag: stray whitespace between "kcfg_WindowsBlockCompositing" and "->". Please remove it. | |||||
70 | 105 | | |||
71 | init(); | 106 | init(); | ||
72 | } | 107 | } | ||
73 | 108 | | |||
109 | void KWinCompositingKCM::reenableGl() | ||||
110 | { | ||||
111 | m_settings->setOpenGLIsUnsafe(false); | ||||
112 | m_settings->save(); | ||||
113 | } | ||||
114 | | ||||
74 | void KWinCompositingKCM::init() | 115 | void KWinCompositingKCM::init() | ||
75 | { | 116 | { | ||
76 | using namespace KWin::Compositing; | | |||
77 | auto currentIndexChangedSignal = static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged); | 117 | auto currentIndexChangedSignal = static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged); | ||
ervin: { should be on its own line | |||||
78 | 118 | | |||
79 | connect(m_compositing, &Compositing::changed, this, qOverload<bool>(&KCModule::changed)); | | |||
80 | connect(m_compositing, &Compositing::defaulted, this, qOverload<bool>(&KCModule::defaulted)); | | |||
81 | | ||||
82 | // enabled check box | | |||
83 | m_form.compositingEnabled->setChecked(m_compositing->compositingEnabled()); | | |||
84 | connect(m_compositing, &Compositing::compositingEnabledChanged, m_form.compositingEnabled, &QCheckBox::setChecked); | | |||
85 | connect(m_form.compositingEnabled, &QCheckBox::toggled, m_compositing, &Compositing::setCompositingEnabled); | | |||
86 | | ||||
87 | // animation speed | 119 | // animation speed | ||
88 | m_form.animationSpeed->setMaximum(s_animationMultipliers.size() - 1); | 120 | m_form.animationDurationFactor->setMaximum(s_animationMultipliers.size() - 1); | ||
89 | auto setSpeed = [this](const qreal multiplier) { | 121 | connect(m_form.animationDurationFactor, &QSlider::valueChanged, this, [this]() { | ||
90 | auto const it = std::lower_bound(s_animationMultipliers.begin(), s_animationMultipliers.end(), multiplier, std::greater<qreal>()); | 122 | m_settings->setAnimationDurationFactor(s_animationMultipliers[m_form.animationDurationFactor->value()]); | ||
91 | const int index = std::distance(s_animationMultipliers.begin(), it); | 123 | updateUnmanagedItemStatus(); | ||
92 | m_form.animationSpeed->setValue(index); | | |||
93 | }; | | |||
94 | setSpeed(m_compositing->animationSpeed()); | | |||
95 | connect(m_compositing, &Compositing::animationSpeedChanged, m_form.animationSpeed, setSpeed); | | |||
96 | connect(m_form.animationSpeed, &QSlider::valueChanged, m_compositing, [this](int index) { | | |||
97 | m_compositing->setAnimationSpeed(s_animationMultipliers[index]); | | |||
98 | }); | 124 | }); | ||
99 | 125 | | |||
100 | if (Compositing::isRunningPlasma()) { | 126 | if (isRunningPlasma()) { | ||
101 | m_form.animationSpeedLabel->hide(); | 127 | m_form.animationSpeedLabel->hide(); | ||
102 | m_form.animationSpeedControls->hide(); | 128 | m_form.animationSpeedControls->hide(); | ||
103 | } | 129 | } | ||
104 | 130 | | |||
105 | // gl scale filter | 131 | // gl scale filter | ||
106 | m_form.glScaleFilter->setCurrentIndex(m_compositing->glScaleFilter()); | 132 | connect(m_form.kcfg_glTextureFilter, currentIndexChangedSignal, this, | ||
107 | connect(m_compositing, &Compositing::glScaleFilterChanged, m_form.glScaleFilter, &QComboBox::setCurrentIndex); | | |||
108 | connect(m_form.glScaleFilter, currentIndexChangedSignal, m_compositing, &Compositing::setGlScaleFilter); | | |||
109 | connect(m_form.glScaleFilter, currentIndexChangedSignal, | | |||
110 | [this](int index) { | 133 | [this](int index) { | ||
111 | if (index == 2) { | 134 | if (index == 2) { | ||
112 | m_form.scaleWarning->animatedShow(); | 135 | m_form.scaleWarning->animatedShow(); | ||
113 | } else { | 136 | } else { | ||
114 | m_form.scaleWarning->animatedHide(); | 137 | m_form.scaleWarning->animatedHide(); | ||
115 | } | 138 | } | ||
116 | } | 139 | } | ||
117 | ); | 140 | ); | ||
118 | 141 | | |||
119 | // xrender scale filter | | |||
120 | m_form.xrScaleFilter->setCurrentIndex(m_compositing->xrScaleFilter()); | | |||
121 | connect(m_compositing, &Compositing::xrScaleFilterChanged, m_form.xrScaleFilter, &QComboBox::setCurrentIndex); | | |||
122 | connect(m_form.xrScaleFilter, currentIndexChangedSignal, | | |||
123 | [this](int index) { | | |||
124 | if (index == 0) { | | |||
125 | m_compositing->setXrScaleFilter(false); | | |||
126 | } else { | | |||
127 | m_compositing->setXrScaleFilter(true); | | |||
128 | } | | |||
129 | }); | | |||
130 | | ||||
131 | // tearing prevention | 142 | // tearing prevention | ||
132 | m_form.tearingPrevention->setCurrentIndex(m_compositing->glSwapStrategy()); | 143 | connect(m_form.kcfg_glPreferBufferSwap, currentIndexChangedSignal, this, | ||
133 | connect(m_compositing, &Compositing::glSwapStrategyChanged, m_form.tearingPrevention, &QComboBox::setCurrentIndex); | | |||
134 | connect(m_form.tearingPrevention, currentIndexChangedSignal, m_compositing, &Compositing::setGlSwapStrategy); | | |||
135 | connect(m_form.tearingPrevention, currentIndexChangedSignal, | | |||
136 | [this](int index) { | 144 | [this](int index) { | ||
137 | if (index == 2) { | 145 | if (index == 2) { | ||
138 | // only when cheap - tearing | 146 | // only when cheap - tearing | ||
139 | m_form.tearingWarning->setText(i18n("\"Only when cheap\" only prevents tearing for full screen changes like a video.")); | 147 | m_form.tearingWarning->setText(i18n("\"Only when cheap\" only prevents tearing for full screen changes like a video.")); | ||
140 | m_form.tearingWarning->animatedShow(); | 148 | m_form.tearingWarning->animatedShow(); | ||
141 | } else if (index == 3) { | 149 | } else if (index == 3) { | ||
142 | // full screen repaints | 150 | // full screen repaints | ||
143 | m_form.tearingWarning->setText(i18n("\"Full screen repaints\" can cause performance problems.")); | 151 | m_form.tearingWarning->setText(i18n("\"Full screen repaints\" can cause performance problems.")); | ||
144 | m_form.tearingWarning->animatedShow(); | 152 | m_form.tearingWarning->animatedShow(); | ||
145 | } else if (index == 4) { | 153 | } else if (index == 4) { | ||
146 | // re-use screen content | 154 | // re-use screen content | ||
147 | m_form.tearingWarning->setText(i18n("\"Re-use screen content\" causes severe performance problems on MESA drivers.")); | 155 | m_form.tearingWarning->setText(i18n("\"Re-use screen content\" causes severe performance problems on MESA drivers.")); | ||
148 | m_form.tearingWarning->animatedShow(); | 156 | m_form.tearingWarning->animatedShow(); | ||
149 | } else { | 157 | } else { | ||
150 | m_form.tearingWarning->animatedHide(); | 158 | m_form.tearingWarning->animatedHide(); | ||
151 | } | 159 | } | ||
152 | } | 160 | } | ||
153 | ); | 161 | ); | ||
154 | 162 | | |||
155 | // windowThumbnail | 163 | // windowThumbnail | ||
156 | m_form.windowThumbnail->setCurrentIndex(m_compositing->windowThumbnail()); | 164 | connect(m_form.kcfg_HiddenPreviews, currentIndexChangedSignal, this, | ||
ervin: Please add this as third connect parameter | |||||
157 | connect(m_compositing, &Compositing::windowThumbnailChanged, m_form.windowThumbnail, &QComboBox::setCurrentIndex); | | |||
158 | connect(m_form.windowThumbnail, currentIndexChangedSignal, m_compositing, &Compositing::setWindowThumbnail); | | |||
159 | connect(m_form.windowThumbnail, currentIndexChangedSignal, | | |||
160 | [this](int index) { | 165 | [this](int index) { | ||
161 | if (index == 2) { | 166 | if (index == 2) { | ||
162 | m_form.windowThumbnailWarning->animatedShow(); | 167 | m_form.windowThumbnailWarning->animatedShow(); | ||
163 | } else { | 168 | } else { | ||
164 | m_form.windowThumbnailWarning->animatedHide(); | 169 | m_form.windowThumbnailWarning->animatedHide(); | ||
165 | } | 170 | } | ||
166 | } | 171 | } | ||
167 | ); | 172 | ); | ||
168 | 173 | | |||
169 | // windows blocking compositing | | |||
170 | m_form.windowsBlockCompositing->setChecked(m_compositing->windowsBlockCompositing()); | | |||
171 | connect(m_compositing, &Compositing::windowsBlockCompositingChanged, m_form.windowsBlockCompositing, &QCheckBox::setChecked); | | |||
172 | connect(m_form.windowsBlockCompositing, &QCheckBox::toggled, m_compositing, &Compositing::setWindowsBlockCompositing); | | |||
173 | | ||||
174 | // compositing type | 174 | // compositing type | ||
175 | CompositingType *type = new CompositingType(this); | 175 | m_form.backend->addItem(i18n("OpenGL 3.1"), CompositingTypeIndex::OPENGL31_INDEX); | ||
176 | m_form.type->setModel(type); | 176 | m_form.backend->addItem(i18n("OpenGL 2.0"), CompositingTypeIndex::OPENGL20_INDEX); | ||
177 | auto updateCompositingType = [this, type]() { | 177 | m_form.backend->addItem(i18n("XRender"), CompositingTypeIndex::XRENDER_INDEX); | ||
178 | m_form.type->setCurrentIndex(type->indexForCompositingType(m_compositing->compositingType())); | 178 | | ||
179 | }; | 179 | connect(m_form.backend, currentIndexChangedSignal, this, &KWinCompositingKCM::onBackendChanged); | ||
anthonyfieroni: It's translatable ? | |||||
1/ That's not much related to this diff : this wasn't changed. 2/ That's up to translators to say I would guess. meven: 1/ That's not much related to this diff : this wasn't changed.
2/ That's up to translators to… | |||||
180 | updateCompositingType(); | 180 | | ||
181 | connect(m_compositing, &Compositing::compositingTypeChanged, | 181 | if (m_settings->openGLIsUnsafe()) { | ||
182 | [updateCompositingType]() { | 182 | m_form.glCrashedWarning->animatedShow(); | ||
183 | updateCompositingType(); | | |||
184 | } | 183 | } | ||
185 | ); | | |||
186 | auto showHideBasedOnType = [this, type]() { | | |||
187 | const int currentType = type->compositingTypeForIndex(m_form.type->currentIndex()); | | |||
188 | m_form.glScaleFilter->setVisible(currentType != CompositingType::XRENDER_INDEX); | | |||
189 | m_form.glScaleFilterLabel->setVisible(currentType != CompositingType::XRENDER_INDEX); | | |||
190 | m_form.xrScaleFilter->setVisible(currentType == CompositingType::XRENDER_INDEX); | | |||
191 | m_form.xrScaleFilterLabel->setVisible(currentType == CompositingType::XRENDER_INDEX); | | |||
192 | }; | | |||
193 | showHideBasedOnType(); | | |||
194 | connect(m_form.type, currentIndexChangedSignal, | | |||
195 | [this, type, showHideBasedOnType]() { | | |||
196 | m_compositing->setCompositingType(type->compositingTypeForIndex(m_form.type->currentIndex())); | | |||
197 | showHideBasedOnType(); | | |||
198 | } | 184 | } | ||
199 | ); | | |||
200 | 185 | | |||
201 | if (m_compositing->OpenGLIsUnsafe()) { | 186 | void KWinCompositingKCM::onBackendChanged() | ||
202 | m_form.glCrashedWarning->animatedShow(); | 187 | { | ||
188 | const int currentType = m_form.backend->currentData().toInt(); | ||||
189 | | ||||
190 | m_form.kcfg_glTextureFilter->setVisible(currentType != CompositingTypeIndex::XRENDER_INDEX); | ||||
191 | m_form.kcfg_XRenderSmoothScale->setVisible(currentType == CompositingTypeIndex::XRENDER_INDEX); | ||||
192 | | ||||
193 | updateUnmanagedItemStatus(); | ||||
203 | } | 194 | } | ||
195 | | ||||
196 | void KWinCompositingKCM::updateUnmanagedItemStatus() | ||||
197 | { | ||||
198 | int backend = KWinCompositingSetting::EnumBackend::OpenGL; | ||||
199 | bool glCore = true; | ||||
200 | const int currentType = m_form.backend->currentData().toInt(); | ||||
201 | switch (currentType) { | ||||
202 | case CompositingTypeIndex::OPENGL31_INDEX: | ||||
203 | // default already set | ||||
204 | break; | ||||
205 | case CompositingTypeIndex::OPENGL20_INDEX: | ||||
206 | glCore = false; | ||||
207 | break; | ||||
208 | case CompositingTypeIndex::XRENDER_INDEX: | ||||
209 | backend = KWinCompositingSetting::EnumBackend::XRender; | ||||
210 | glCore = false; | ||||
211 | break; | ||||
212 | } | ||||
213 | const auto animationDuration = s_animationMultipliers[m_form.animationDurationFactor->value()]; | ||||
214 | | ||||
215 | const bool inPlasma = isRunningPlasma(); | ||||
216 | | ||||
217 | bool changed = glCore != m_glCore; | ||||
218 | changed |= backend != m_backend; | ||||
219 | if (!inPlasma) { | ||||
220 | changed |= (animationDuration != m_animationDurationFactor); | ||||
221 | } | ||||
222 | unmanagedWidgetChangeState(changed); | ||||
223 | | ||||
224 | bool defaulted = glCore == m_settings->defaultGlCoreValue(); | ||||
225 | defaulted &= backend == m_settings->defaultBackendValue(); | ||||
226 | if (!inPlasma) { | ||||
227 | defaulted &= animationDuration == m_settings->defaultAnimationDurationFactorValue(); | ||||
228 | } | ||||
229 | unmanagedWidgetDefaultState(defaulted); | ||||
204 | } | 230 | } | ||
205 | 231 | | |||
206 | void KWinCompositingKCM::load() | 232 | void KWinCompositingKCM::load() | ||
207 | { | 233 | { | ||
208 | KCModule::load(); | 234 | KCModule::load(); | ||
209 | m_compositing->load(); | 235 | | ||
236 | // unmanaged items | ||||
237 | m_settings->findItem("AnimationDurationFactor")->readConfig(m_settings->config()); | ||||
238 | const double multiplier = m_settings->animationDurationFactor(); | ||||
239 | auto const it = std::lower_bound(s_animationMultipliers.begin(), s_animationMultipliers.end(), multiplier, std::greater<qreal>()); | ||||
240 | const int index = static_cast<int>(std::distance(s_animationMultipliers.begin(), it)); | ||||
241 | m_form.animationDurationFactor->setValue(index); | ||||
242 | | ||||
243 | m_settings->findItem("Backend")->readConfig(m_settings->config()); | ||||
244 | m_settings->findItem("glCore")->readConfig(m_settings->config()); | ||||
zzag: Maybe `glCore`? | |||||
meven: Indeed this caused the crash when I changed the name for this entry. | |||||
245 | m_backend = m_settings->backend(); | ||||
246 | m_glCore = m_settings->glCore(); | ||||
247 | if (m_backend == KWinCompositingSetting::EnumBackend::OpenGL) { | ||||
248 | if (m_glCore) { | ||||
249 | m_form.backend->setCurrentIndex(CompositingTypeIndex::OPENGL31_INDEX); | ||||
250 | } else { | ||||
251 | m_form.backend->setCurrentIndex(CompositingTypeIndex::OPENGL20_INDEX); | ||||
252 | } | ||||
253 | } else { | ||||
We need to initialize m_glCore to something; otherwise it will cause problems in updateUnmanagedItemStatus() later on. zzag: We need to initialize m_glCore to something; otherwise it will cause problems in… | |||||
254 | m_form.backend->setCurrentIndex(CompositingTypeIndex::XRENDER_INDEX); | ||||
255 | } | ||||
256 | onBackendChanged(); | ||||
210 | } | 257 | } | ||
Using m_settings to track unmanaged state lead to settings containing old data and new data. Managed widget update settings only on save. bport: Using m_settings to track unmanaged state lead to settings containing old data and new data. | |||||
211 | 258 | | |||
212 | void KWinCompositingKCM::defaults() | 259 | void KWinCompositingKCM::defaults() | ||
213 | { | 260 | { | ||
214 | KCModule::defaults(); | 261 | KCModule::defaults(); | ||
215 | m_compositing->defaults(); | 262 | | ||
263 | // unmanaged widgets | ||||
264 | m_form.backend->setCurrentIndex(CompositingTypeIndex::OPENGL20_INDEX); | ||||
ervin: I'd split the clauses on several lines for readability | |||||
265 | // corresponds to 1.0 seconds in s_animationMultipliers | ||||
266 | m_form.animationDurationFactor->setValue(3); | ||||
Ah, not what I had in mind since I would have liked to keep the const but no big deal ervin: Ah, not what I had in mind since I would have liked to keep the const but no big deal | |||||
216 | } | 267 | } | ||
ervin: ditto (especially for that one the line is getting quite long) | |||||
217 | 268 | | |||
218 | void KWinCompositingKCM::save() | 269 | void KWinCompositingKCM::save() | ||
219 | { | 270 | { | ||
271 | int backend = KWinCompositingSetting::EnumBackend::OpenGL; | ||||
272 | bool glCore = true; | ||||
273 | const int currentType = m_form.backend->currentData().toInt(); | ||||
274 | switch (currentType) { | ||||
275 | case CompositingTypeIndex::OPENGL31_INDEX: | ||||
276 | // default already set | ||||
277 | break; | ||||
278 | case CompositingTypeIndex::OPENGL20_INDEX: | ||||
279 | backend = KWinCompositingSetting::EnumBackend::OpenGL; | ||||
280 | glCore = false; | ||||
281 | break; | ||||
282 | case CompositingTypeIndex::XRENDER_INDEX: | ||||
283 | backend = KWinCompositingSetting::EnumBackend::XRender; | ||||
284 | glCore = false; | ||||
285 | break; | ||||
286 | } | ||||
287 | m_settings->setBackend(backend); | ||||
288 | m_settings->setGlCore(glCore); | ||||
289 | | ||||
290 | const auto animationDuration = s_animationMultipliers[m_form.animationDurationFactor->value()]; | ||||
291 | m_settings->setAnimationDurationFactor(animationDuration); | ||||
292 | m_settings->save(); | ||||
293 | | ||||
220 | KCModule::save(); | 294 | KCModule::save(); | ||
221 | m_compositing->save(); | 295 | | ||
296 | // Send signal to all kwin instances | ||||
297 | QDBusMessage message = QDBusMessage::createSignal(QStringLiteral("/Compositor"), | ||||
298 | QStringLiteral("org.kde.kwin.Compositing"), | ||||
299 | QStringLiteral("reinit")); | ||||
300 | QDBusConnection::sessionBus().send(message); | ||||
222 | } | 301 | } | ||
223 | 302 | | |||
224 | K_PLUGIN_FACTORY(KWinCompositingConfigFactory, | 303 | K_PLUGIN_FACTORY(KWinCompositingConfigFactory, | ||
225 | registerPlugin<KWinCompositingKCM>("compositing"); | 304 | registerPlugin<KWinCompositingKCM>("compositing"); | ||
226 | ) | 305 | ) | ||
227 | 306 | | |||
228 | #include "main.moc" | 307 | #include "main.moc" |
Put the opening brace on newline.