Changeset View
Changeset View
Standalone View
Standalone View
kcmkwin/kwincompositing/compositing.cpp
Show All 35 Lines | |||||
36 | namespace Compositing { | 36 | namespace Compositing { | ||
37 | 37 | | |||
38 | Compositing::Compositing(QObject *parent) | 38 | Compositing::Compositing(QObject *parent) | ||
39 | : QObject(parent) | 39 | : QObject(parent) | ||
40 | , m_animationSpeed(0) | 40 | , m_animationSpeed(0) | ||
41 | , m_windowThumbnail(0) | 41 | , m_windowThumbnail(0) | ||
42 | , m_glScaleFilter(0) | 42 | , m_glScaleFilter(0) | ||
43 | , m_xrScaleFilter(false) | 43 | , m_xrScaleFilter(false) | ||
44 | , m_unredirectFullscreen(false) | | |||
45 | , m_glSwapStrategy(0) | 44 | , m_glSwapStrategy(0) | ||
46 | , m_glColorCorrection(false) | 45 | , m_glColorCorrection(false) | ||
47 | , m_compositingType(0) | 46 | , m_compositingType(0) | ||
48 | , m_compositingEnabled(true) | 47 | , m_compositingEnabled(true) | ||
49 | , m_changed(false) | 48 | , m_changed(false) | ||
50 | , m_openGLPlatformInterfaceModel(new OpenGLPlatformInterfaceModel(this)) | 49 | , m_openGLPlatformInterfaceModel(new OpenGLPlatformInterfaceModel(this)) | ||
51 | , m_openGLPlatformInterface(0) | 50 | , m_openGLPlatformInterface(0) | ||
52 | { | 51 | { | ||
53 | reset(); | 52 | reset(); | ||
54 | connect(this, &Compositing::animationSpeedChanged, this, &Compositing::changed); | 53 | connect(this, &Compositing::animationSpeedChanged, this, &Compositing::changed); | ||
55 | connect(this, &Compositing::windowThumbnailChanged, this, &Compositing::changed); | 54 | connect(this, &Compositing::windowThumbnailChanged, this, &Compositing::changed); | ||
56 | connect(this, &Compositing::glScaleFilterChanged, this, &Compositing::changed); | 55 | connect(this, &Compositing::glScaleFilterChanged, this, &Compositing::changed); | ||
57 | connect(this, &Compositing::xrScaleFilterChanged, this, &Compositing::changed); | 56 | connect(this, &Compositing::xrScaleFilterChanged, this, &Compositing::changed); | ||
58 | connect(this, &Compositing::unredirectFullscreenChanged, this, &Compositing::changed); | | |||
59 | connect(this, &Compositing::glSwapStrategyChanged, this, &Compositing::changed); | 57 | connect(this, &Compositing::glSwapStrategyChanged, this, &Compositing::changed); | ||
60 | connect(this, &Compositing::glColorCorrectionChanged, this, &Compositing::changed); | 58 | connect(this, &Compositing::glColorCorrectionChanged, this, &Compositing::changed); | ||
61 | connect(this, &Compositing::compositingTypeChanged, this, &Compositing::changed); | 59 | connect(this, &Compositing::compositingTypeChanged, this, &Compositing::changed); | ||
62 | connect(this, &Compositing::compositingEnabledChanged, this, &Compositing::changed); | 60 | connect(this, &Compositing::compositingEnabledChanged, this, &Compositing::changed); | ||
63 | connect(this, &Compositing::openGLPlatformInterfaceChanged, this, &Compositing::changed); | 61 | connect(this, &Compositing::openGLPlatformInterfaceChanged, this, &Compositing::changed); | ||
64 | 62 | | |||
65 | connect(this, &Compositing::changed, [this]{ | 63 | connect(this, &Compositing::changed, [this]{ | ||
66 | m_changed = true; | 64 | m_changed = true; | ||
67 | }); | 65 | }); | ||
68 | } | 66 | } | ||
69 | 67 | | |||
70 | void Compositing::reset() | 68 | void Compositing::reset() | ||
71 | { | 69 | { | ||
72 | KConfigGroup kwinConfig(KSharedConfig::openConfig(QStringLiteral("kwinrc")), QStringLiteral("Compositing")); | 70 | KConfigGroup kwinConfig(KSharedConfig::openConfig(QStringLiteral("kwinrc")), QStringLiteral("Compositing")); | ||
73 | setAnimationSpeed(kwinConfig.readEntry("AnimationSpeed", 3)); | 71 | setAnimationSpeed(kwinConfig.readEntry("AnimationSpeed", 3)); | ||
74 | setWindowThumbnail(kwinConfig.readEntry("HiddenPreviews", 5) - 4); | 72 | setWindowThumbnail(kwinConfig.readEntry("HiddenPreviews", 5) - 4); | ||
75 | setGlScaleFilter(kwinConfig.readEntry("GLTextureFilter", 2)); | 73 | setGlScaleFilter(kwinConfig.readEntry("GLTextureFilter", 2)); | ||
76 | setXrScaleFilter(kwinConfig.readEntry("XRenderSmoothScale", false)); | 74 | setXrScaleFilter(kwinConfig.readEntry("XRenderSmoothScale", false)); | ||
77 | setUnredirectFullscreen(kwinConfig.readEntry("UnredirectFullscreen", false)); | | |||
78 | setCompositingEnabled(kwinConfig.readEntry("Enabled", true)); | 75 | setCompositingEnabled(kwinConfig.readEntry("Enabled", true)); | ||
79 | 76 | | |||
80 | auto swapStrategy = [&kwinConfig]() { | 77 | auto swapStrategy = [&kwinConfig]() { | ||
81 | const QString glSwapStrategyValue = kwinConfig.readEntry("GLPreferBufferSwap", "a"); | 78 | const QString glSwapStrategyValue = kwinConfig.readEntry("GLPreferBufferSwap", "a"); | ||
82 | 79 | | |||
83 | if (glSwapStrategyValue == "n") { | 80 | if (glSwapStrategyValue == "n") { | ||
84 | return 0; | 81 | return 0; | ||
85 | } else if (glSwapStrategyValue == "a") { | 82 | } else if (glSwapStrategyValue == "a") { | ||
Show All 33 Lines | |||||
119 | } | 116 | } | ||
120 | 117 | | |||
121 | void Compositing::defaults() | 118 | void Compositing::defaults() | ||
122 | { | 119 | { | ||
123 | setAnimationSpeed(3); | 120 | setAnimationSpeed(3); | ||
124 | setWindowThumbnail(1); | 121 | setWindowThumbnail(1); | ||
125 | setGlScaleFilter(2); | 122 | setGlScaleFilter(2); | ||
126 | setXrScaleFilter(false); | 123 | setXrScaleFilter(false); | ||
127 | setUnredirectFullscreen(false); | | |||
128 | setGlSwapStrategy(1); | 124 | setGlSwapStrategy(1); | ||
129 | setGlColorCorrection(false); | 125 | setGlColorCorrection(false); | ||
130 | setCompositingType(CompositingType::OPENGL20_INDEX); | 126 | setCompositingType(CompositingType::OPENGL20_INDEX); | ||
131 | const QModelIndex index = m_openGLPlatformInterfaceModel->indexForKey(QStringLiteral("glx")); | 127 | const QModelIndex index = m_openGLPlatformInterfaceModel->indexForKey(QStringLiteral("glx")); | ||
132 | setOpenGLPlatformInterface(index.isValid() ? index.row() : 0); | 128 | setOpenGLPlatformInterface(index.isValid() ? index.row() : 0); | ||
133 | m_changed = true; | 129 | m_changed = true; | ||
134 | } | 130 | } | ||
135 | 131 | | |||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Line(s) | 178 | { | |||
183 | return m_glScaleFilter; | 179 | return m_glScaleFilter; | ||
184 | } | 180 | } | ||
185 | 181 | | |||
186 | bool Compositing::xrScaleFilter() const | 182 | bool Compositing::xrScaleFilter() const | ||
187 | { | 183 | { | ||
188 | return m_xrScaleFilter; | 184 | return m_xrScaleFilter; | ||
189 | } | 185 | } | ||
190 | 186 | | |||
191 | bool Compositing::unredirectFullscreen() const | | |||
192 | { | | |||
193 | return m_unredirectFullscreen; | | |||
194 | } | | |||
195 | | ||||
196 | int Compositing::glSwapStrategy() const | 187 | int Compositing::glSwapStrategy() const | ||
197 | { | 188 | { | ||
198 | return m_glSwapStrategy; | 189 | return m_glSwapStrategy; | ||
199 | } | 190 | } | ||
200 | 191 | | |||
201 | bool Compositing::glColorCorrection() const | 192 | bool Compositing::glColorCorrection() const | ||
202 | { | 193 | { | ||
203 | return m_glColorCorrection; | 194 | return m_glColorCorrection; | ||
Show All 40 Lines | |||||
244 | { | 235 | { | ||
245 | if (strategy == m_glSwapStrategy) { | 236 | if (strategy == m_glSwapStrategy) { | ||
246 | return; | 237 | return; | ||
247 | } | 238 | } | ||
248 | m_glSwapStrategy = strategy; | 239 | m_glSwapStrategy = strategy; | ||
249 | emit glSwapStrategyChanged(strategy); | 240 | emit glSwapStrategyChanged(strategy); | ||
250 | } | 241 | } | ||
251 | 242 | | |||
252 | void Compositing::setUnredirectFullscreen(bool unredirect) | | |||
253 | { | | |||
254 | if (unredirect == m_unredirectFullscreen) { | | |||
255 | return; | | |||
256 | } | | |||
257 | m_unredirectFullscreen = unredirect; | | |||
258 | emit unredirectFullscreenChanged(unredirect); | | |||
259 | } | | |||
260 | | ||||
261 | void Compositing::setWindowThumbnail(int index) | 243 | void Compositing::setWindowThumbnail(int index) | ||
262 | { | 244 | { | ||
263 | if (index == m_windowThumbnail) { | 245 | if (index == m_windowThumbnail) { | ||
264 | return; | 246 | return; | ||
265 | } | 247 | } | ||
266 | m_windowThumbnail = index; | 248 | m_windowThumbnail = index; | ||
267 | emit windowThumbnailChanged(index); | 249 | emit windowThumbnailChanged(index); | ||
268 | } | 250 | } | ||
Show All 28 Lines | |||||
297 | 279 | | |||
298 | void Compositing::save() | 280 | void Compositing::save() | ||
299 | { | 281 | { | ||
300 | KConfigGroup kwinConfig(KSharedConfig::openConfig(QStringLiteral("kwinrc")), "Compositing"); | 282 | KConfigGroup kwinConfig(KSharedConfig::openConfig(QStringLiteral("kwinrc")), "Compositing"); | ||
301 | kwinConfig.writeEntry("AnimationSpeed", animationSpeed()); | 283 | kwinConfig.writeEntry("AnimationSpeed", animationSpeed()); | ||
302 | kwinConfig.writeEntry("HiddenPreviews", windowThumbnail() + 4); | 284 | kwinConfig.writeEntry("HiddenPreviews", windowThumbnail() + 4); | ||
303 | kwinConfig.writeEntry("GLTextureFilter", glScaleFilter()); | 285 | kwinConfig.writeEntry("GLTextureFilter", glScaleFilter()); | ||
304 | kwinConfig.writeEntry("XRenderSmoothScale", xrScaleFilter()); | 286 | kwinConfig.writeEntry("XRenderSmoothScale", xrScaleFilter()); | ||
305 | kwinConfig.writeEntry("UnredirectFullscreen", unredirectFullscreen()); | | |||
306 | kwinConfig.writeEntry("Enabled", compositingEnabled()); | 287 | kwinConfig.writeEntry("Enabled", compositingEnabled()); | ||
307 | auto swapStrategy = [this] { | 288 | auto swapStrategy = [this] { | ||
308 | switch (glSwapStrategy()) { | 289 | switch (glSwapStrategy()) { | ||
309 | case 0: | 290 | case 0: | ||
310 | return QStringLiteral("n"); | 291 | return QStringLiteral("n"); | ||
311 | case 2: | 292 | case 2: | ||
312 | return QStringLiteral("e"); | 293 | return QStringLiteral("e"); | ||
313 | case 3: | 294 | case 3: | ||
▲ Show 20 Lines • Show All 228 Lines • Show Last 20 Lines |