From 58668e52a060b879ba502fc3fa2683d150ca3eec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 3 Jun 2014 11:39:10 +0200 Subject: [PATCH] [kcmkwin/compositing] Show warning message when selecting "dangerous" options The idea is to warn the user that changing the settings might break the setup when we know it could be dangerous. The following cases are considered: * Scale filter Accurate * Tearing prevention * keep window thumbnail always * EGL if EGL and GLX are available * unredirect fullscreen not working on all hardware In addition the OpenGL is Unsafe warning is turned int a KMessageWidget which is also used for all the other warnings. REVIEW: 118494 --- kcmkwin/kwincompositing/compositing.cpp | 7 ++ kcmkwin/kwincompositing/compositing.h | 1 + kcmkwin/kwincompositing/compositing.ui | 155 ++++++++++++++++++++---- kcmkwin/kwincompositing/main.cpp | 70 +++++++++++ 4 files changed, 210 insertions(+), 23 deletions(-) diff --git a/kcmkwin/kwincompositing/compositing.cpp b/kcmkwin/kwincompositing/compositing.cpp index 46fc3335ed..1e02f778fe 100644 --- a/kcmkwin/kwincompositing/compositing.cpp +++ b/kcmkwin/kwincompositing/compositing.cpp @@ -161,6 +161,13 @@ bool Compositing::OpenGLIsBroken() return false; } +void Compositing::reenableOpenGLDetection() +{ + KConfigGroup kwinConfig(KSharedConfig::openConfig("kwinrc"), "Compositing"); + kwinConfig.writeEntry("OpenGLIsUnsafe", false); + kwinConfig.sync(); +} + int Compositing::animationSpeed() const { return m_animationSpeed; diff --git a/kcmkwin/kwincompositing/compositing.h b/kcmkwin/kwincompositing/compositing.h index 2f1df35f12..05ee523e21 100644 --- a/kcmkwin/kwincompositing/compositing.h +++ b/kcmkwin/kwincompositing/compositing.h @@ -50,6 +50,7 @@ public: Q_INVOKABLE bool OpenGLIsUnsafe() const; Q_INVOKABLE bool OpenGLIsBroken(); + Q_INVOKABLE void reenableOpenGLDetection(); int animationSpeed() const; int windowThumbnail() const; int glScaleFilter() const; diff --git a/kcmkwin/kwincompositing/compositing.ui b/kcmkwin/kwincompositing/compositing.ui index 571f0a51d2..0f30f12402 100644 --- a/kcmkwin/kwincompositing/compositing.ui +++ b/kcmkwin/kwincompositing/compositing.ui @@ -7,7 +7,7 @@ 0 0 402 - 300 + 335 @@ -17,21 +17,21 @@ QFormLayout::AllNonFixedFieldsGrow - + Enable compositor on startup - + Animation speed: - + @@ -82,14 +82,14 @@ - + Scale method: - + @@ -108,14 +108,14 @@ - + Scale method: - + @@ -129,41 +129,41 @@ - + Qt::Horizontal - + Rendering backend: - + - + OpenGL interface: - + - + Tearing prevention ("vsync"): - + @@ -192,18 +192,18 @@ - + Keep window thumbnails: - + - Always (Breaks Animations) + Always @@ -218,43 +218,152 @@ - + Expert: - + Suspend compositor for full screen windows - + Experimental: - + Enable color correction - + Qt::Horizontal + + + + + + OpenGL compositing (the default) has crashed KWin in the past. +This was most likely due to a driver bug. +If you think that you have meanwhile upgraded to a stable driver, +you can reset this protection but be aware that this might result in an immediate crash! +Alternatively, you might want to use the XRender backend instead. + + + true + + + false + + + KMessageWidget::Warning + + + + + + + EGL is not supported by all OpenGL drivers. If not supported the Compositor will be disabled. + + + true + + + false + + + KMessageWidget::Warning + + + + + + + Scale method "Accurate" is not supported by all hardware and can cause performance regressions and rendering artifacts. + + + true + + + false + + + KMessageWidget::Warning + + + + + + + true + + + false + + + KMessageWidget::Warning + + + + + + + Keeping the window thumbnail always interferes with the minimized state of windows. This can result in windows not suspending their work when minimized. + + + true + + + false + + + KMessageWidget::Warning + + + + + + + Having full screen windows bypass the compositor is not supported on every hardware. + + + true + + + false + + + KMessageWidget::Information + + + + + + + + KMessageWidget + QFrame +
kmessagewidget.h
+ 1 +
+
diff --git a/kcmkwin/kwincompositing/main.cpp b/kcmkwin/kwincompositing/main.cpp index 4712adecd8..b45c4176b4 100644 --- a/kcmkwin/kwincompositing/main.cpp +++ b/kcmkwin/kwincompositing/main.cpp @@ -78,6 +78,16 @@ KWinCompositingSettings::KWinCompositingSettings(QWidget *parent, const QVariant , m_compositing(new KWin::Compositing::Compositing(this)) { m_form.setupUi(this); + m_form.glCrashedWarning->setIcon(QIcon::fromTheme(QStringLiteral("dialog-warning"))); + QAction *reenableGLAction = new QAction(i18n("Re-enable OpenGL detection"), this); + connect(reenableGLAction, &QAction::triggered, m_compositing, &KWin::Compositing::Compositing::reenableOpenGLDetection); + connect(reenableGLAction, &QAction::triggered, m_form.glCrashedWarning, &KMessageWidget::animatedHide); + m_form.glCrashedWarning->addAction(reenableGLAction); + m_form.interfaceWarning->setIcon(QIcon::fromTheme(QStringLiteral("dialog-warning"))); + 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"))); + m_form.unredirectInformation->setIcon(QIcon::fromTheme(QStringLiteral("dialog-information"))); init(); } @@ -103,6 +113,15 @@ void KWinCompositingSettings::init() m_form.glScaleFilter->setCurrentIndex(m_compositing->glScaleFilter()); connect(m_compositing, &Compositing::glScaleFilterChanged, m_form.glScaleFilter, &QComboBox::setCurrentIndex); connect(m_form.glScaleFilter, currentIndexChangedSignal, m_compositing, &Compositing::setGlScaleFilter); + connect(m_form.glScaleFilter, currentIndexChangedSignal, + [this](int index) { + if (index == 2) { + m_form.scaleWarning->animatedShow(); + } else { + m_form.scaleWarning->animatedHide(); + } + } + ); // xrender scale filter m_form.xrScaleFilter->setCurrentIndex(m_compositing->xrScaleFilter()); @@ -113,22 +132,69 @@ void KWinCompositingSettings::init() m_form.tearingPrevention->setCurrentIndex(m_compositing->glSwapStrategy()); connect(m_compositing, &Compositing::glSwapStrategyChanged, m_form.tearingPrevention, &QComboBox::setCurrentIndex); connect(m_form.tearingPrevention, currentIndexChangedSignal, m_compositing, &Compositing::setGlSwapStrategy); + connect(m_form.tearingPrevention, currentIndexChangedSignal, + [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 + m_form.tearingWarning->setText(i18n("\"Re-use screen content\" causes performance severe problems on MESA drivers.")); + m_form.tearingWarning->animatedShow(); + } else { + m_form.tearingWarning->animatedHide(); + } + } + ); // windowThumbnail m_form.windowThumbnail->setCurrentIndex(m_compositing->windowThumbnail()); connect(m_compositing, &Compositing::windowThumbnailChanged, m_form.windowThumbnail, &QComboBox::setCurrentIndex); connect(m_form.windowThumbnail, currentIndexChangedSignal, m_compositing, &Compositing::setWindowThumbnail); + connect(m_form.windowThumbnail, currentIndexChangedSignal, + [this](int index) { + if (index == 0) { + m_form.windowThumbnailWarning->animatedShow(); + } else { + m_form.windowThumbnailWarning->animatedHide(); + } + } + ); // openglPlatformInterface m_form.openGLPlatformInterface->setModel(m_compositing->openGLPlatformInterfaceModel()); m_form.openGLPlatformInterface->setCurrentIndex(m_compositing->openGLPlatformInterface()); connect(m_compositing, &Compositing::openGLPlatformInterfaceChanged, m_form.openGLPlatformInterface, &QComboBox::setCurrentIndex); connect(m_form.openGLPlatformInterface, currentIndexChangedSignal, m_compositing, &Compositing::setOpenGLPlatformInterface); + connect(m_form.openGLPlatformInterface, currentIndexChangedSignal, + [this]() { + if (m_form.openGLPlatformInterface->count() > 1 // only if egl and glx are supported + && m_form.openGLPlatformInterface->currentData().toString() == QStringLiteral("egl")) { + m_form.interfaceWarning->animatedShow(); + } else { + m_form.interfaceWarning->animatedHide(); + } + } + ); // unredirect fullscreen m_form.unredirectFullscreen->setChecked(m_compositing->unredirectFullscreen()); connect(m_compositing, &Compositing::unredirectFullscreenChanged, m_form.unredirectFullscreen, &QCheckBox::setChecked); connect(m_form.unredirectFullscreen, &QCheckBox::toggled, m_compositing, &Compositing::setUnredirectFullscreen); + connect(m_form.unredirectFullscreen, &QCheckBox::toggled, + [this](bool enabled) { + if (enabled) { + m_form.unredirectInformation->animatedShow(); + } else { + m_form.unredirectInformation->animatedHide(); + } + } + ); // color correction m_form.colorCorrection->setChecked(m_compositing->glColorCorrection()); @@ -164,6 +230,10 @@ void KWinCompositingSettings::init() showHideBasedOnType(); } ); + + if (m_compositing->OpenGLIsUnsafe()) { + m_form.glCrashedWarning->animatedShow(); + } } void KWinCompositingSettings::load()