From d14cf2da92af6a935d1c4704ea44a5caaaf3ca4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Fri, 4 May 2012 11:13:24 +0200 Subject: [PATCH] Show detailed information why an effect cannot be loaded Effects can specify their minimum requirements in their desktop file: * OpenGL * OpenGL 2 (GLSL required) * Shaders (either ARB or OpenGL 2) The configuration module uses this information in combination with which backend KWin is currently using. So if e.g. OpenGL is used and an effect requires OpenGL 2 a detailed error message can be showed that OpenGL 2 is required. BUG: 209213 FIXED-IN: 4.9.0 REVIEW: 104847 --- composite.cpp | 22 +++ effects/blur/blur.desktop | 3 +- effects/coverswitch/coverswitch.desktop | 1 + effects/cube/cube.desktop | 1 + effects/cube/cubeslide.desktop | 1 + effects/explosion/explosion.desktop | 1 + effects/flipswitch/flipswitch.desktop | 1 + effects/glide/glide.desktop | 1 + effects/invert/invert.desktop | 1 + effects/kwineffect.desktop | 9 ++ effects/lookingglass/lookingglass.desktop | 1 + effects/magiclamp/magiclamp.desktop | 1 + effects/sheet/sheet.desktop | 1 + .../startupfeedback/startupfeedback.desktop | 1 + effects/wobblywindows/wobblywindows.desktop | 1 + kcmkwin/kwincompositing/main.cpp | 128 +++++++++++++++--- kcmkwin/kwincompositing/main.h | 2 + kcmkwin/kwincompositing/main.ui | 24 +++- org.kde.KWin.xml | 10 ++ workspace.h | 9 ++ 20 files changed, 195 insertions(+), 24 deletions(-) diff --git a/composite.cpp b/composite.cpp index 7e48066a50..c2ad976ace 100644 --- a/composite.cpp +++ b/composite.cpp @@ -556,6 +556,28 @@ bool Workspace::openGLIsBroken() const return CompositingPrefs::openGlIsBroken(); } +QString Workspace::compositingType() +{ + // the returned strings are considered as identifiers and may not be translated + if (!effects) { + return "none"; + } + if (effects->compositingType() == XRenderCompositing) { + return "xrender"; + } else if (effects->compositingType() == OpenGLCompositing) { +#ifdef KWIN_HAVE_OPENGLES + return "gles"; +#else + if (ShaderManager::instance()->isValid()) { + return "gl2"; + } else { + return "gl1"; + } +#endif + } + return "none"; +} + //**************************************** // Toplevel //**************************************** diff --git a/effects/blur/blur.desktop b/effects/blur/blur.desktop index db8940b114..6332582763 100644 --- a/effects/blur/blur.desktop +++ b/effects/blur/blur.desktop @@ -165,4 +165,5 @@ X-KDE-PluginInfo-License=GPL X-KDE-PluginInfo-EnabledByDefault=true X-KDE-Library=kwin4_effect_builtins X-KDE-Ordering=75 - +X-KWin-Requires-OpenGL=true +X-KWin-Requires-Shaders=true diff --git a/effects/coverswitch/coverswitch.desktop b/effects/coverswitch/coverswitch.desktop index 3f49bbb722..ba906dfdcc 100644 --- a/effects/coverswitch/coverswitch.desktop +++ b/effects/coverswitch/coverswitch.desktop @@ -149,3 +149,4 @@ X-KDE-PluginInfo-License=GPL X-KDE-PluginInfo-EnabledByDefault=false X-KDE-Library=kwin4_effect_builtins X-KDE-Ordering=50 +X-KWin-Requires-OpenGL=true diff --git a/effects/cube/cube.desktop b/effects/cube/cube.desktop index c9304d72a6..d7f2998597 100644 --- a/effects/cube/cube.desktop +++ b/effects/cube/cube.desktop @@ -163,3 +163,4 @@ X-KDE-PluginInfo-License=GPL X-KDE-PluginInfo-EnabledByDefault=false X-KDE-Library=kwin4_effect_builtins X-KDE-Ordering=50 +X-KWin-Requires-OpenGL=true diff --git a/effects/cube/cubeslide.desktop b/effects/cube/cubeslide.desktop index 2967b7c9c7..133c1d83f2 100644 --- a/effects/cube/cubeslide.desktop +++ b/effects/cube/cubeslide.desktop @@ -143,3 +143,4 @@ X-KDE-PluginInfo-License=GPL X-KDE-PluginInfo-EnabledByDefault=false X-KDE-Library=kwin4_effect_builtins X-KDE-Ordering=50 +X-KWin-Requires-OpenGL=true diff --git a/effects/explosion/explosion.desktop b/effects/explosion/explosion.desktop index ed36e2454a..d4156228f3 100644 --- a/effects/explosion/explosion.desktop +++ b/effects/explosion/explosion.desktop @@ -162,3 +162,4 @@ X-KDE-PluginInfo-License=GPL X-KDE-PluginInfo-EnabledByDefault=false X-KDE-Library=kwin4_effect_builtins X-KDE-Ordering=70 +X-KWin-Requires-OpenGL2=true diff --git a/effects/flipswitch/flipswitch.desktop b/effects/flipswitch/flipswitch.desktop index 2aba28aec9..48a81da609 100644 --- a/effects/flipswitch/flipswitch.desktop +++ b/effects/flipswitch/flipswitch.desktop @@ -145,3 +145,4 @@ X-KDE-PluginInfo-License=GPL X-KDE-PluginInfo-EnabledByDefault=false X-KDE-Library=kwin4_effect_builtins X-KDE-Ordering=50 +X-KWin-Requires-OpenGL=true diff --git a/effects/glide/glide.desktop b/effects/glide/glide.desktop index 28e7ad15fd..0bc2ead207 100644 --- a/effects/glide/glide.desktop +++ b/effects/glide/glide.desktop @@ -130,3 +130,4 @@ X-KDE-PluginInfo-License=GPL X-KDE-PluginInfo-EnabledByDefault=false X-KDE-Library=kwin4_effect_builtins X-KDE-Ordering=50 +X-KWin-Requires-OpenGL=true diff --git a/effects/invert/invert.desktop b/effects/invert/invert.desktop index d4a2457d9f..40f7895d02 100644 --- a/effects/invert/invert.desktop +++ b/effects/invert/invert.desktop @@ -162,3 +162,4 @@ X-KDE-PluginInfo-Depends= X-KDE-PluginInfo-License=GPL X-KDE-PluginInfo-EnabledByDefault=false X-KDE-Library=kwin4_effect_builtins +X-KWin-Requires-OpenGL2=true diff --git a/effects/kwineffect.desktop b/effects/kwineffect.desktop index 760f6d6a4b..721801092a 100644 --- a/effects/kwineffect.desktop +++ b/effects/kwineffect.desktop @@ -88,3 +88,12 @@ Comment[zh_TW]=KWin 效果 [PropertyDef::X-KDE-Ordering] Type=int + +[PropertyDef::X-KWin-Requires-OpenGL] +Type=bool + +[PropertyDef::X-KWin-Requires-OpenGL2] +Type=bool + +[PropertyDef::X-KWin-Requires-Shaders] +Type=bool diff --git a/effects/lookingglass/lookingglass.desktop b/effects/lookingglass/lookingglass.desktop index e46e51e867..5d6d83b65f 100644 --- a/effects/lookingglass/lookingglass.desktop +++ b/effects/lookingglass/lookingglass.desktop @@ -155,3 +155,4 @@ X-KDE-PluginInfo-Depends= X-KDE-PluginInfo-License=GPL X-KDE-PluginInfo-EnabledByDefault=false X-KDE-Library=kwin4_effect_builtins +X-KWin-Requires-OpenGL2=true diff --git a/effects/magiclamp/magiclamp.desktop b/effects/magiclamp/magiclamp.desktop index 5c1705e985..9e37d67d0a 100644 --- a/effects/magiclamp/magiclamp.desktop +++ b/effects/magiclamp/magiclamp.desktop @@ -155,3 +155,4 @@ X-KDE-PluginInfo-License=GPL X-KDE-PluginInfo-EnabledByDefault=false X-KDE-Library=kwin4_effect_builtins X-KDE-Ordering=50 +X-KWin-Requires-OpenGL=true diff --git a/effects/sheet/sheet.desktop b/effects/sheet/sheet.desktop index 3400fdfb1b..3d55edb81b 100644 --- a/effects/sheet/sheet.desktop +++ b/effects/sheet/sheet.desktop @@ -144,3 +144,4 @@ X-KDE-PluginInfo-License=GPL X-KDE-PluginInfo-EnabledByDefault=false X-KDE-Library=kwin4_effect_builtins X-KDE-Ordering=60 +X-KWin-Requires-OpenGL=true diff --git a/effects/startupfeedback/startupfeedback.desktop b/effects/startupfeedback/startupfeedback.desktop index c5bf017055..bf6f46d0cf 100644 --- a/effects/startupfeedback/startupfeedback.desktop +++ b/effects/startupfeedback/startupfeedback.desktop @@ -118,3 +118,4 @@ X-KDE-PluginInfo-Depends= X-KDE-PluginInfo-EnabledByDefault=true X-KDE-Library=kwin4_effect_builtins X-KDE-Ordering=90 +X-KWin-Requires-OpenGL=true diff --git a/effects/wobblywindows/wobblywindows.desktop b/effects/wobblywindows/wobblywindows.desktop index 1d03ed71ac..b66afce7ff 100644 --- a/effects/wobblywindows/wobblywindows.desktop +++ b/effects/wobblywindows/wobblywindows.desktop @@ -156,3 +156,4 @@ X-KDE-PluginInfo-License=GPL X-KDE-PluginInfo-EnabledByDefault=false X-KDE-Library=kwin4_effect_builtins X-KDE-Ordering=45 +X-KWin-Requires-OpenGL=true diff --git a/kcmkwin/kwincompositing/main.cpp b/kcmkwin/kwincompositing/main.cpp index 90655ad259..caf9b0a248 100644 --- a/kcmkwin/kwincompositing/main.cpp +++ b/kcmkwin/kwincompositing/main.cpp @@ -79,6 +79,8 @@ KWinCompositingConfig::KWinCompositingConfig(QWidget *parent, const QVariantList : KCModule(KWinCompositingConfigFactory::componentData(), parent) , mKWinConfig(KSharedConfig::openConfig("kwinrc")) , m_showConfirmDialog(false) + , m_showDetailedErrors(new QAction(i18nc("Action to open a dialog showing detailed information why an effect could not be loaded", + "Details"), this)) { KGlobal::locale()->insertCatalog("kwin_effects"); ui.setupUi(this); @@ -86,6 +88,9 @@ KWinCompositingConfig::KWinCompositingConfig(QWidget *parent, const QVariantList ui.tabWidget->setCurrentIndex(0); ui.statusTitleWidget->hide(); ui.rearmGlSupport->hide(); + ui.messageBox->setVisible(false); + ui.messageBox->addAction(m_showDetailedErrors); + ui.messageBox->setMessageType(KMessageWidget::Warning); // For future use (void) I18N_NOOP("Use GLSL shaders"); @@ -124,6 +129,7 @@ KWinCompositingConfig::KWinCompositingConfig(QWidget *parent, const QVariantList connect(ui.glVSync, SIGNAL(toggled(bool)), this, SLOT(changed())); connect(ui.glShaders, SIGNAL(toggled(bool)), this, SLOT(changed())); + connect(m_showDetailedErrors, SIGNAL(triggered(bool)), SLOT(showDetailedEffectLoadingInformation())); // Open the temporary config file // Temporary conf file is used to synchronize effect checkboxes with effect @@ -584,14 +590,15 @@ void KWinCompositingConfig::checkLoadedEffects() { // check for effects not supported by Backend or hardware // such effects are enabled but not returned by DBus method loadedEffects - QDBusMessage message = QDBusMessage::createMethodCall("org.kde.kwin", "/KWin", "org.kde.KWin", "loadedEffects"); - QDBusMessage reply = QDBusConnection::sessionBus().call(message); + OrgKdeKWinInterface kwin("org.kde.kwin", "/KWin", QDBusConnection::sessionBus()); KConfigGroup effectConfig = KConfigGroup(mKWinConfig, "Compositing"); bool enabledAfter = effectConfig.readEntry("Enabled", true); - if (reply.type() == QDBusMessage::ReplyMessage && enabledAfter && !getenv("KDE_FAILSAFE")) { + QDBusPendingReply< QStringList > reply = kwin.loadedEffects(); + + if (!reply.isError() && enabledAfter && !getenv("KDE_FAILSAFE")) { effectConfig = KConfigGroup(mKWinConfig, "Plugins"); - QStringList loadedEffects = reply.arguments()[0].toStringList(); + QStringList loadedEffects = reply.value(); QStringList effects = effectConfig.keyList(); QStringList disabledEffects = QStringList(); foreach (QString effect, effects) { // krazy:exclude=foreach @@ -602,25 +609,108 @@ void KWinCompositingConfig::checkLoadedEffects() } } if (!disabledEffects.isEmpty()) { - KServiceTypeTrader* trader = KServiceTypeTrader::self(); - KService::List services; - QString message = i18n("The following desktop effects could not be activated:"); - message.append(""); - KNotification::event("effectsnotsupported", message, QPixmap(), NULL, KNotification::CloseOnTimeout, KComponentData("kwin")); + m_showDetailedErrors->setData(disabledEffects); + ui.messageBox->setText(i18ncp("Error Message shown when a desktop effect could not be loaded", + "A desktop effect could not be loaded.", + "%1 desktop effects could not be loaded", disabledEffects.count())); + ui.messageBox->animatedShow(); } } } +void KWinCompositingConfig::showDetailedEffectLoadingInformation() +{ + QStringList disabledEffects = m_showDetailedErrors->data().toStringList(); + OrgKdeKWinInterface kwin("org.kde.kwin", "/KWin", QDBusConnection::sessionBus()); + QDBusPendingReply< QString > pendingCompositingType = kwin.compositingType(); + QString compositingType = pendingCompositingType.isError() ? "none" : pendingCompositingType.value(); + KServiceTypeTrader* trader = KServiceTypeTrader::self(); + KService::List services; + const KLocalizedString unknownReason = ki18nc("Effect with given name could not be activated due to unknown reason", + "%1 Effect failed to load due to unknown reason."); + const KLocalizedString requiresShaders = ki18nc("Effect with given name could not be activated as it requires hardware shaders", + "%1 Effect requires hardware support."); + const KLocalizedString requiresOpenGL = ki18nc("Effect with given name could not be activated as it requires OpenGL", + "%1 Effect requires OpenGL."); + const KLocalizedString requiresOpenGL2 = ki18nc("Effect with given name could not be activated as it requires OpenGL 2", + "%1 effect requires OpenGL 2."); + KDialog *dialog = new KDialog(this); + dialog->setWindowTitle(i18nc("Window title", "List of Effects which could not be loaded")); + dialog->setButtons(KDialog::Ok); + QWidget *mainWidget = new QWidget(dialog); + dialog->setMainWidget(mainWidget); + QVBoxLayout *vboxLayout = new QVBoxLayout(mainWidget); + mainWidget->setLayout(vboxLayout); + KTitleWidget *titleWidget = new KTitleWidget(mainWidget); + titleWidget->setText(i18n("For technical reasons it is not possible to determine all possible error causes."), + KTitleWidget::InfoMessage); + QLabel *label = new QLabel(mainWidget); + label->setOpenExternalLinks(true); + vboxLayout->addWidget(titleWidget); + vboxLayout->addWidget(label); + if (compositingType != "none") { + QString text; + if (disabledEffects.count() > 1) { + text = ""); + } + label->setText(text); + } else { + // compositing is not active - no effect can be active + label->setText(i18nc("Error Message shown when Compositing is not active after tried activation", + "Desktop Effect system is not running.")); + } + dialog->show(); +} + void KWinCompositingConfig::configChanged(bool reinitCompositing) { // Send signal to kwin diff --git a/kcmkwin/kwincompositing/main.h b/kcmkwin/kwincompositing/main.h index bd2950961f..706e6e34d2 100644 --- a/kcmkwin/kwincompositing/main.h +++ b/kcmkwin/kwincompositing/main.h @@ -81,6 +81,7 @@ private slots: void toogleSmoothScaleUi(int compositingType); void toggleEffectShortcutChanged(const QKeySequence &seq); void updateStatusUI(bool compositingIsPossible); + void showDetailedEffectLoadingInformation(); private: bool effectEnabled(const QString& effect, const KConfigGroup& cfg) const; @@ -94,6 +95,7 @@ private: bool m_showConfirmDialog; KActionCollection* m_actionCollection; QString originalGraphicsSystem; + QAction *m_showDetailedErrors; }; } // namespace diff --git a/kcmkwin/kwincompositing/main.ui b/kcmkwin/kwincompositing/main.ui index 6b5cfd0a5b..cff0f63b16 100644 --- a/kcmkwin/kwincompositing/main.ui +++ b/kcmkwin/kwincompositing/main.ui @@ -6,15 +6,25 @@ 0 0 - 552 - 483 + 557 + 530 - + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + - 2 + 0 @@ -859,6 +869,12 @@ On legacy hardware disabling Shaders can improve the performance.
kpluginselector.h
1 + + KMessageWidget + QFrame +
kmessagewidget.h
+ 1 +
tabWidget diff --git a/org.kde.KWin.xml b/org.kde.KWin.xml index b893bec24b..2e8eee595e 100644 --- a/org.kde.KWin.xml +++ b/org.kde.KWin.xml @@ -95,5 +95,15 @@ + + + + diff --git a/workspace.h b/workspace.h index 34114cbfea..367477e5df 100644 --- a/workspace.h +++ b/workspace.h @@ -455,6 +455,15 @@ public: bool compositingPossible() const; QString compositingNotPossibleReason() const; bool openGLIsBroken() const; + /** + * Returns the currently used Compositor (Scene): + * @li @c none No Compositing + * @li @c xrender XRender + * @li @c gl1 OpenGL 1 + * @li @c gl2 OpenGL 2 + * @li @c gles OpenGL ES 2 + **/ + QString compositingType(); void setCurrentScreen(int new_screen);