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 | | |||
35 | class KWinCompositingSettings : public KCModule | 36 | #include "kwincompositing_setting.h" | ||
37 | | ||||
38 | class KWinCompositingKCM : public KCModule | ||||
zzag: Put the opening brace on newline. | |||||
36 | { | 39 | { | ||
37 | Q_OBJECT | 40 | Q_OBJECT | ||
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… | |||||
38 | public: | 41 | public: | ||
39 | explicit KWinCompositingSettings(QWidget *parent = nullptr, const QVariantList &args = QVariantList()); | 42 | enum CompositingTypeIndex { | ||
43 | OPENGL31_INDEX = 0, | ||||
44 | OPENGL20_INDEX, | ||||
45 | XRENDER_INDEX | ||||
46 | }; | ||||
47 | | ||||
48 | explicit KWinCompositingKCM(QWidget *parent = nullptr, const QVariantList &args = QVariantList()); | ||||
40 | 49 | | |||
41 | public Q_SLOTS: | 50 | public Q_SLOTS: | ||
42 | void load() override; | 51 | void load() override; | ||
43 | void save() override; | 52 | void save() override; | ||
44 | void defaults() override; | 53 | void defaults() override; | ||
45 | 54 | | |||
55 | private Q_SLOTS: | ||||
56 | void onBackendChanged(); | ||||
57 | 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 ;-)) | |||||
58 | | ||||
46 | private: | 59 | private: | ||
47 | void init(); | 60 | void init(); | ||
48 | KWin::Compositing::Compositing *m_compositing; | 61 | void updateUnmanagedItemStatus(); | ||
62 | bool isRunningPlasma() const; | ||||
zzag: Make it static. | |||||
63 | bool compositingRequired() const; | ||||
64 | | ||||
zzag: typo: Unnamaged | |||||
49 | Ui_CompositingForm m_form; | 65 | Ui_CompositingForm m_form; | ||
66 | | ||||
67 | OrgKdeKwinCompositingInterface *m_compositingInterface; | ||||
68 | KWinCompositingSetting *m_settings; | ||||
69 | | ||||
70 | // unmanaged states | ||||
71 | int m_backend; | ||||
72 | bool m_glCore; | ||||
73 | double m_animationDurationFactor; | ||||
50 | }; | 74 | }; | ||
51 | 75 | | |||
52 | static const QVector<qreal> s_animationMultipliers = {8, 4, 2, 1, 0.5, 0.25, 0.125, 0}; | 76 | static const QVector<qreal> s_animationMultipliers = {8, 4, 2, 1, 0.5, 0.25, 0.125, 0}; | ||
53 | 77 | | |||
54 | KWinCompositingSettings::KWinCompositingSettings(QWidget *parent, const QVariantList &args) | 78 | bool KWinCompositingKCM::compositingRequired() const | ||
79 | { | ||||
80 | return m_compositingInterface->platformRequiresCompositing(); | ||||
81 | } | ||||
82 | | ||||
83 | KWinCompositingKCM::KWinCompositingKCM(QWidget *parent, const QVariantList &args) | ||||
55 | : KCModule(parent, args) | 84 | : KCModule(parent, args) | ||
56 | , m_compositing(new KWin::Compositing::Compositing(this)) | 85 | , m_compositingInterface(new OrgKdeKwinCompositingInterface(QStringLiteral("org.kde.KWin"), QStringLiteral("/Compositor"), QDBusConnection::sessionBus(), this)) | ||
86 | , 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 | { | 87 | { | ||
zzag: Is there a reason why the parent is not `this`? | |||||
58 | m_form.setupUi(this); | 88 | m_form.setupUi(this); | ||
89 | addConfig(m_settings, this); | ||||
90 | | ||||
59 | m_form.glCrashedWarning->setIcon(QIcon::fromTheme(QStringLiteral("dialog-warning"))); | 91 | m_form.glCrashedWarning->setIcon(QIcon::fromTheme(QStringLiteral("dialog-warning"))); | ||
60 | QAction *reenableGLAction = new QAction(i18n("Re-enable OpenGL detection"), this); | 92 | QAction *reenableGLAction = new QAction(i18n("Re-enable OpenGL detection"), this); | ||
61 | connect(reenableGLAction, &QAction::triggered, m_compositing, &KWin::Compositing::Compositing::reenableOpenGLDetection); | 93 | connect(reenableGLAction, &QAction::triggered, this, &KWinCompositingKCM::reenableGL); | ||
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… | |||||
62 | connect(reenableGLAction, &QAction::triggered, m_form.glCrashedWarning, &KMessageWidget::animatedHide); | 94 | connect(reenableGLAction, &QAction::triggered, m_form.glCrashedWarning, &KMessageWidget::animatedHide); | ||
63 | m_form.glCrashedWarning->addAction(reenableGLAction); | 95 | m_form.glCrashedWarning->addAction(reenableGLAction); | ||
64 | m_form.scaleWarning->setIcon(QIcon::fromTheme(QStringLiteral("dialog-warning"))); | 96 | m_form.scaleWarning->setIcon(QIcon::fromTheme(QStringLiteral("dialog-warning"))); | ||
65 | m_form.tearingWarning->setIcon(QIcon::fromTheme(QStringLiteral("dialog-warning"))); | 97 | m_form.tearingWarning->setIcon(QIcon::fromTheme(QStringLiteral("dialog-warning"))); | ||
66 | m_form.windowThumbnailWarning->setIcon(QIcon::fromTheme(QStringLiteral("dialog-warning"))); | 98 | m_form.windowThumbnailWarning->setIcon(QIcon::fromTheme(QStringLiteral("dialog-warning"))); | ||
67 | 99 | | |||
68 | m_form.compositingEnabled->setVisible(!m_compositing->compositingRequired()); | 100 | m_form.kcfg_Enabled->setVisible(!compositingRequired()); | ||
69 | m_form.windowsBlockCompositing->setVisible(!m_compositing->compositingRequired()); | 101 | 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 | 102 | | |||
71 | init(); | 103 | init(); | ||
72 | } | 104 | } | ||
73 | 105 | | |||
74 | void KWinCompositingSettings::init() | 106 | void KWinCompositingKCM::reenableGL() { | ||
ervin: { should be on its own line | |||||
75 | { | 107 | m_settings->setOpenGLIsUnsafe(false); | ||
76 | using namespace KWin::Compositing; | 108 | m_settings->save(); | ||
77 | auto currentIndexChangedSignal = static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged); | 109 | } | ||
78 | 110 | | |||
79 | connect(m_compositing, &Compositing::changed, this, &KWinCompositingSettings::markAsChanged); | 111 | bool KWinCompositingKCM::isRunningPlasma() const | ||
112 | { | ||||
113 | return qgetenv("XDG_CURRENT_DESKTOP") == "KDE"; | ||||
114 | } | ||||
80 | 115 | | |||
81 | // enabled check box | 116 | void KWinCompositingKCM::init() | ||
82 | m_form.compositingEnabled->setChecked(m_compositing->compositingEnabled()); | 117 | { | ||
83 | connect(m_compositing, &Compositing::compositingEnabledChanged, m_form.compositingEnabled, &QCheckBox::setChecked); | 118 | auto currentIndexChangedSignal = static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged); | ||
84 | connect(m_form.compositingEnabled, &QCheckBox::toggled, m_compositing, &Compositing::setCompositingEnabled); | | |||
85 | 119 | | |||
86 | // animation speed | 120 | // animation speed | ||
87 | m_form.animationSpeed->setMaximum(s_animationMultipliers.size() - 1); | 121 | m_form.animationDurationFactor->setMaximum(s_animationMultipliers.size() - 1); | ||
88 | auto setSpeed = [this](const qreal multiplier) { | 122 | connect(m_form.animationDurationFactor, &QSlider::valueChanged, this, [this]() { | ||
89 | auto const it = std::lower_bound(s_animationMultipliers.begin(), s_animationMultipliers.end(), multiplier, std::greater<qreal>()); | 123 | m_settings->setAnimationDurationFactor(s_animationMultipliers[m_form.animationDurationFactor->value()]); | ||
90 | const int index = std::distance(s_animationMultipliers.begin(), it); | 124 | updateUnmanagedItemStatus(); | ||
91 | m_form.animationSpeed->setValue(index); | | |||
92 | }; | | |||
93 | setSpeed(m_compositing->animationSpeed()); | | |||
94 | connect(m_compositing, &Compositing::animationSpeedChanged, m_form.animationSpeed, setSpeed); | | |||
95 | connect(m_form.animationSpeed, &QSlider::valueChanged, m_compositing, [this](int index) { | | |||
96 | m_compositing->setAnimationSpeed(s_animationMultipliers[index]); | | |||
97 | }); | 125 | }); | ||
98 | 126 | | |||
99 | if (Compositing::isRunningPlasma()) { | 127 | if (isRunningPlasma()) { | ||
100 | m_form.animationSpeedLabel->hide(); | 128 | m_form.animationSpeedLabel->hide(); | ||
101 | m_form.animationSpeedControls->hide(); | 129 | m_form.animationSpeedControls->hide(); | ||
102 | } | 130 | } | ||
103 | 131 | | |||
104 | // gl scale filter | 132 | // gl scale filter | ||
105 | m_form.glScaleFilter->setCurrentIndex(m_compositing->glScaleFilter()); | 133 | connect(m_form.kcfg_GLTextureFilter, currentIndexChangedSignal, this, | ||
106 | connect(m_compositing, &Compositing::glScaleFilterChanged, m_form.glScaleFilter, &QComboBox::setCurrentIndex); | | |||
107 | connect(m_form.glScaleFilter, currentIndexChangedSignal, m_compositing, &Compositing::setGlScaleFilter); | | |||
108 | connect(m_form.glScaleFilter, currentIndexChangedSignal, | | |||
109 | [this](int index) { | 134 | [this](int index) { | ||
110 | if (index == 2) { | 135 | if (index == 2) { | ||
111 | m_form.scaleWarning->animatedShow(); | 136 | m_form.scaleWarning->animatedShow(); | ||
112 | } else { | 137 | } else { | ||
113 | m_form.scaleWarning->animatedHide(); | 138 | m_form.scaleWarning->animatedHide(); | ||
114 | } | 139 | } | ||
115 | } | 140 | } | ||
116 | ); | 141 | ); | ||
117 | 142 | | |||
118 | // xrender scale filter | | |||
119 | m_form.xrScaleFilter->setCurrentIndex(m_compositing->xrScaleFilter()); | | |||
120 | connect(m_compositing, &Compositing::xrScaleFilterChanged, m_form.xrScaleFilter, &QComboBox::setCurrentIndex); | | |||
121 | connect(m_form.xrScaleFilter, currentIndexChangedSignal, | | |||
122 | [this](int index) { | | |||
123 | if (index == 0) { | | |||
124 | m_compositing->setXrScaleFilter(false); | | |||
125 | } else { | | |||
126 | m_compositing->setXrScaleFilter(true); | | |||
127 | } | | |||
128 | }); | | |||
129 | | ||||
130 | // tearing prevention | 143 | // tearing prevention | ||
131 | m_form.tearingPrevention->setCurrentIndex(m_compositing->glSwapStrategy()); | 144 | connect(m_form.kcfg_GLPreferBufferSwap, currentIndexChangedSignal, this, | ||
132 | connect(m_compositing, &Compositing::glSwapStrategyChanged, m_form.tearingPrevention, &QComboBox::setCurrentIndex); | | |||
133 | connect(m_form.tearingPrevention, currentIndexChangedSignal, m_compositing, &Compositing::setGlSwapStrategy); | | |||
134 | connect(m_form.tearingPrevention, currentIndexChangedSignal, | | |||
135 | [this](int index) { | 145 | [this](int index) { | ||
136 | if (index == 2) { | 146 | if (index == 2) { | ||
137 | // only when cheap - tearing | 147 | // only when cheap - tearing | ||
138 | m_form.tearingWarning->setText(i18n("\"Only when cheap\" only prevents tearing for full screen changes like a video.")); | 148 | m_form.tearingWarning->setText(i18n("\"Only when cheap\" only prevents tearing for full screen changes like a video.")); | ||
139 | m_form.tearingWarning->animatedShow(); | 149 | m_form.tearingWarning->animatedShow(); | ||
140 | } else if (index == 3) { | 150 | } else if (index == 3) { | ||
141 | // full screen repaints | 151 | // full screen repaints | ||
142 | m_form.tearingWarning->setText(i18n("\"Full screen repaints\" can cause performance problems.")); | 152 | m_form.tearingWarning->setText(i18n("\"Full screen repaints\" can cause performance problems.")); | ||
143 | m_form.tearingWarning->animatedShow(); | 153 | m_form.tearingWarning->animatedShow(); | ||
144 | } else if (index == 4) { | 154 | } else if (index == 4) { | ||
145 | // re-use screen content | 155 | // re-use screen content | ||
146 | m_form.tearingWarning->setText(i18n("\"Re-use screen content\" causes severe performance problems on MESA drivers.")); | 156 | m_form.tearingWarning->setText(i18n("\"Re-use screen content\" causes severe performance problems on MESA drivers.")); | ||
147 | m_form.tearingWarning->animatedShow(); | 157 | m_form.tearingWarning->animatedShow(); | ||
148 | } else { | 158 | } else { | ||
149 | m_form.tearingWarning->animatedHide(); | 159 | m_form.tearingWarning->animatedHide(); | ||
150 | } | 160 | } | ||
151 | } | 161 | } | ||
152 | ); | 162 | ); | ||
153 | 163 | | |||
154 | // windowThumbnail | 164 | // windowThumbnail | ||
155 | m_form.windowThumbnail->setCurrentIndex(m_compositing->windowThumbnail()); | 165 | connect(m_form.kcfg_HiddenPreviews, currentIndexChangedSignal, this, | ||
ervin: Please add this as third connect parameter | |||||
156 | connect(m_compositing, &Compositing::windowThumbnailChanged, m_form.windowThumbnail, &QComboBox::setCurrentIndex); | | |||
157 | connect(m_form.windowThumbnail, currentIndexChangedSignal, m_compositing, &Compositing::setWindowThumbnail); | | |||
158 | connect(m_form.windowThumbnail, currentIndexChangedSignal, | | |||
159 | [this](int index) { | 166 | [this](int index) { | ||
160 | if (index == 2) { | 167 | if (index == 2) { | ||
161 | m_form.windowThumbnailWarning->animatedShow(); | 168 | m_form.windowThumbnailWarning->animatedShow(); | ||
162 | } else { | 169 | } else { | ||
163 | m_form.windowThumbnailWarning->animatedHide(); | 170 | m_form.windowThumbnailWarning->animatedHide(); | ||
164 | } | 171 | } | ||
165 | } | 172 | } | ||
166 | ); | 173 | ); | ||
167 | 174 | | |||
168 | // windows blocking compositing | | |||
169 | m_form.windowsBlockCompositing->setChecked(m_compositing->windowsBlockCompositing()); | | |||
170 | connect(m_compositing, &Compositing::windowsBlockCompositingChanged, m_form.windowsBlockCompositing, &QCheckBox::setChecked); | | |||
171 | connect(m_form.windowsBlockCompositing, &QCheckBox::toggled, m_compositing, &Compositing::setWindowsBlockCompositing); | | |||
172 | | ||||
173 | // compositing type | 175 | // compositing type | ||
174 | CompositingType *type = new CompositingType(this); | 176 | m_form.backend->addItem(i18n("OpenGL 3.1"), CompositingTypeIndex::OPENGL31_INDEX); | ||
175 | m_form.type->setModel(type); | 177 | m_form.backend->addItem(i18n("OpenGL 2.0"), CompositingTypeIndex::OPENGL20_INDEX); | ||
176 | auto updateCompositingType = [this, type]() { | 178 | m_form.backend->addItem(i18n("XRender"), CompositingTypeIndex::XRENDER_INDEX); | ||
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… | |||||
177 | m_form.type->setCurrentIndex(type->indexForCompositingType(m_compositing->compositingType())); | 179 | | ||
178 | }; | 180 | connect(m_form.backend, currentIndexChangedSignal, this, &KWinCompositingKCM::onBackendChanged); | ||
179 | updateCompositingType(); | 181 | | ||
180 | connect(m_compositing, &Compositing::compositingTypeChanged, | 182 | if (m_settings->openGLIsUnsafe()) { | ||
181 | [updateCompositingType]() { | 183 | m_form.glCrashedWarning->animatedShow(); | ||
182 | updateCompositingType(); | | |||
183 | } | 184 | } | ||
184 | ); | | |||
185 | auto showHideBasedOnType = [this, type]() { | | |||
186 | const int currentType = type->compositingTypeForIndex(m_form.type->currentIndex()); | | |||
187 | m_form.glScaleFilter->setVisible(currentType != CompositingType::XRENDER_INDEX); | | |||
188 | m_form.glScaleFilterLabel->setVisible(currentType != CompositingType::XRENDER_INDEX); | | |||
189 | m_form.xrScaleFilter->setVisible(currentType == CompositingType::XRENDER_INDEX); | | |||
190 | m_form.xrScaleFilterLabel->setVisible(currentType == CompositingType::XRENDER_INDEX); | | |||
191 | }; | | |||
192 | showHideBasedOnType(); | | |||
193 | connect(m_form.type, currentIndexChangedSignal, | | |||
194 | [this, type, showHideBasedOnType]() { | | |||
195 | m_compositing->setCompositingType(type->compositingTypeForIndex(m_form.type->currentIndex())); | | |||
196 | showHideBasedOnType(); | | |||
197 | } | 185 | } | ||
198 | ); | | |||
199 | 186 | | |||
200 | if (m_compositing->OpenGLIsUnsafe()) { | 187 | void KWinCompositingKCM::onBackendChanged() | ||
201 | m_form.glCrashedWarning->animatedShow(); | 188 | { | ||
189 | const int currentType = m_form.backend->currentData().toInt(); | ||||
190 | m_form.kcfg_GLTextureFilter->setVisible(currentType != CompositingTypeIndex::XRENDER_INDEX); | ||||
191 | m_form.glScaleFilterLabel->setVisible(currentType != CompositingTypeIndex::XRENDER_INDEX); | ||||
192 | | ||||
193 | m_form.kcfg_XRenderSmoothScale->setVisible(currentType == CompositingTypeIndex::XRENDER_INDEX); | ||||
194 | m_form.xrScaleFilterLabel->setVisible(currentType == CompositingTypeIndex::XRENDER_INDEX); | ||||
195 | | ||||
196 | updateUnmanagedItemStatus(); | ||||
202 | } | 197 | } | ||
198 | | ||||
199 | void KWinCompositingKCM::updateUnmanagedItemStatus() | ||||
200 | { | ||||
201 | int backend = KWinCompositingSetting::EnumBackend::OpenGL; | ||||
202 | bool glCore = true; | ||||
203 | const int currentType = m_form.backend->currentData().toInt(); | ||||
204 | switch (currentType) { | ||||
205 | case CompositingTypeIndex::OPENGL31_INDEX: | ||||
206 | // default already set | ||||
207 | break; | ||||
208 | case CompositingTypeIndex::OPENGL20_INDEX: | ||||
209 | backend = KWinCompositingSetting::EnumBackend::OpenGL; | ||||
210 | glCore = false; | ||||
211 | break; | ||||
212 | case CompositingTypeIndex::XRENDER_INDEX: | ||||
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. | |||||
213 | backend = KWinCompositingSetting::EnumBackend::XRender; | ||||
214 | glCore = false; | ||||
215 | break; | ||||
216 | } | ||||
217 | const auto animationDuration = s_animationMultipliers[m_form.animationDurationFactor->value()]; | ||||
218 | | ||||
219 | const bool changed = m_glCore != glCore || backend != m_backend || m_animationDurationFactor != animationDuration; | ||||
ervin: I'd split the clauses on several lines for readability | |||||
220 | emit unmanagedWidgetChangeState(changed); | ||||
221 | | ||||
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 | |||||
222 | const bool defaulted = glCore != m_settings->defaultGLCoreValue() && backend != m_settings->defaultBackendValue() && animationDuration != m_settings->defaultAnimationDurationFactorValue(); | ||||
ervin: ditto (especially for that one the line is getting quite long) | |||||
223 | emit unmanagedWidgetDefaultState(defaulted); | ||||
203 | } | 224 | } | ||
204 | 225 | | |||
205 | void KWinCompositingSettings::load() | 226 | void KWinCompositingKCM::load() | ||
206 | { | 227 | { | ||
207 | KCModule::load(); | 228 | KCModule::load(); | ||
208 | m_compositing->reset(); | 229 | | ||
230 | // unmanaged items | ||||
231 | m_settings->findItem("AnimationDurationFactor")->readConfig(m_settings->config()); | ||||
232 | const double multiplier = m_settings->animationDurationFactor(); | ||||
233 | auto const it = std::lower_bound(s_animationMultipliers.begin(), s_animationMultipliers.end(), multiplier, std::greater<qreal>()); | ||||
234 | const int index = static_cast<int>(std::distance(s_animationMultipliers.begin(), it)); | ||||
235 | m_form.animationDurationFactor->setValue(index); | ||||
236 | | ||||
237 | m_settings->findItem("Backend")->readConfig(m_settings->config()); | ||||
238 | 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. | |||||
239 | m_backend = m_settings->backend(); | ||||
240 | if (m_backend == KWinCompositingSetting::EnumBackend::OpenGL) { | ||||
241 | m_glCore = m_settings->gLCore(); | ||||
242 | if (m_glCore) { | ||||
243 | m_form.backend->setCurrentIndex(CompositingTypeIndex::OPENGL31_INDEX); | ||||
244 | } else { | ||||
245 | m_form.backend->setCurrentIndex(CompositingTypeIndex::OPENGL20_INDEX); | ||||
246 | } | ||||
247 | } 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… | |||||
248 | m_form.backend->setCurrentIndex(CompositingTypeIndex::XRENDER_INDEX); | ||||
249 | } | ||||
209 | } | 250 | } | ||
210 | 251 | | |||
211 | void KWinCompositingSettings::defaults() | 252 | void KWinCompositingKCM::defaults() | ||
212 | { | 253 | { | ||
213 | KCModule::defaults(); | 254 | KCModule::defaults(); | ||
214 | m_compositing->defaults(); | 255 | | ||
256 | // unmanaged widgets | ||||
257 | m_form.backend->setCurrentIndex(CompositingTypeIndex::OPENGL20_INDEX); | ||||
258 | // corresponds to 1.0 seconds in s_animationMultipliers | ||||
259 | m_form.animationDurationFactor->setValue(3); | ||||
215 | } | 260 | } | ||
216 | 261 | | |||
217 | void KWinCompositingSettings::save() | 262 | void KWinCompositingKCM::save() | ||
218 | { | 263 | { | ||
264 | int backend = KWinCompositingSetting::EnumBackend::OpenGL; | ||||
265 | bool glCore = true; | ||||
266 | const int currentType = m_form.backend->currentData().toInt(); | ||||
267 | switch (currentType) { | ||||
268 | case CompositingTypeIndex::OPENGL31_INDEX: | ||||
269 | // default already set | ||||
270 | break; | ||||
271 | case CompositingTypeIndex::OPENGL20_INDEX: | ||||
272 | backend = KWinCompositingSetting::EnumBackend::OpenGL; | ||||
273 | glCore = false; | ||||
274 | break; | ||||
275 | case CompositingTypeIndex::XRENDER_INDEX: | ||||
276 | backend = KWinCompositingSetting::EnumBackend::XRender; | ||||
277 | glCore = false; | ||||
278 | break; | ||||
279 | } | ||||
280 | m_settings->setBackend(backend); | ||||
281 | m_settings->setGLCore(glCore); | ||||
282 | | ||||
283 | const auto animationDuration = s_animationMultipliers[m_form.animationDurationFactor->value()]; | ||||
284 | m_settings->setAnimationDurationFactor(animationDuration); | ||||
285 | | ||||
219 | KCModule::save(); | 286 | KCModule::save(); | ||
220 | m_compositing->save(); | 287 | | ||
288 | // Send signal to all kwin instances | ||||
289 | QDBusMessage message = QDBusMessage::createSignal(QStringLiteral("/Compositor"), | ||||
290 | QStringLiteral("org.kde.kwin.Compositing"), | ||||
291 | QStringLiteral("reinit")); | ||||
292 | QDBusConnection::sessionBus().send(message); | ||||
221 | } | 293 | } | ||
222 | 294 | | |||
223 | K_PLUGIN_FACTORY(KWinCompositingConfigFactory, | 295 | K_PLUGIN_FACTORY(KWinCompositingConfigFactory, | ||
224 | registerPlugin<KWinCompositingSettings>("compositing"); | 296 | registerPlugin<KWinCompositingKCM>("compositing"); | ||
225 | ) | 297 | ) | ||
226 | 298 | | |||
227 | #include "main.moc" | 299 | #include "main.moc" |
Put the opening brace on newline.