diff --git a/dbusinterface.cpp b/dbusinterface.cpp index 302355bd9a..17ab6bd26e 100644 --- a/dbusinterface.cpp +++ b/dbusinterface.cpp @@ -235,6 +235,11 @@ bool CompositorDBusInterface::isOpenGLBroken() const return kwinApp()->platform()->openGLCompositingIsBroken(); } +bool CompositorDBusInterface::platformRequiresCompositing() const +{ + return kwinApp()->platform()->requiresCompositing(); +} + void CompositorDBusInterface::resume() { m_compositor->resume(Compositor::ScriptSuspend); diff --git a/dbusinterface.h b/dbusinterface.h index edec3248d0..5781a28e89 100644 --- a/dbusinterface.h +++ b/dbusinterface.h @@ -115,6 +115,7 @@ class CompositorDBusInterface : public QObject * Values depend on operation mode and compile time options. **/ Q_PROPERTY(QStringList supportedOpenGLPlatformInterfaces READ supportedOpenGLPlatformInterfaces) + Q_PROPERTY(bool platformRequiresCompositing READ platformRequiresCompositing) public: explicit CompositorDBusInterface(Compositor *parent); virtual ~CompositorDBusInterface() = default; @@ -125,6 +126,7 @@ public: bool isOpenGLBroken() const; QString compositingType() const; QStringList supportedOpenGLPlatformInterfaces() const; + bool platformRequiresCompositing() const; public Q_SLOTS: /** diff --git a/kcmkwin/kwincompositing/compositing.cpp b/kcmkwin/kwincompositing/compositing.cpp index 5f0815b6e1..85cfe975bc 100644 --- a/kcmkwin/kwincompositing/compositing.cpp +++ b/kcmkwin/kwincompositing/compositing.cpp @@ -49,6 +49,7 @@ Compositing::Compositing(QObject *parent) , m_openGLPlatformInterfaceModel(new OpenGLPlatformInterfaceModel(this)) , m_openGLPlatformInterface(0) , m_windowsBlockCompositing(true) + , m_compositingInterface(new OrgKdeKwinCompositingInterface(QStringLiteral("org.kde.KWin"), QStringLiteral("/Compositor"), QDBusConnection::sessionBus(), this)) { reset(); connect(this, &Compositing::animationSpeedChanged, this, &Compositing::changed); @@ -142,16 +143,13 @@ bool Compositing::OpenGLIsUnsafe() const bool Compositing::OpenGLIsBroken() { - OrgKdeKwinCompositingInterface interface(QStringLiteral("org.kde.KWin"), - QStringLiteral("/Compositor"), - QDBusConnection::sessionBus()); KConfigGroup kwinConfig(KSharedConfig::openConfig("kwinrc"), "Compositing"); QString oldBackend = kwinConfig.readEntry("Backend", "OpenGL"); kwinConfig.writeEntry("Backend", "OpenGL"); kwinConfig.sync(); - if (interface.openGLIsBroken()) { + if (m_compositingInterface->openGLIsBroken()) { kwinConfig.writeEntry("Backend", oldBackend); kwinConfig.sync(); return true; @@ -274,6 +272,9 @@ void Compositing::setCompositingType(int index) void Compositing::setCompositingEnabled(bool enabled) { + if (compositingRequired()) { + return; + } if (enabled == m_compositingEnabled) { return; } @@ -289,7 +290,9 @@ void Compositing::save() kwinConfig.writeEntry("HiddenPreviews", windowThumbnail() + 4); kwinConfig.writeEntry("GLTextureFilter", glScaleFilter()); kwinConfig.writeEntry("XRenderSmoothScale", xrScaleFilter()); - kwinConfig.writeEntry("Enabled", compositingEnabled()); + if (!compositingRequired()) { + kwinConfig.writeEntry("Enabled", compositingEnabled()); + } auto swapStrategy = [this] { switch (glSwapStrategy()) { case 0: @@ -329,7 +332,9 @@ void Compositing::save() if (glIndex.isValid()) { kwinConfig.writeEntry("GLPlatformInterface", glIndex.data(Qt::UserRole).toString()); } - kwinConfig.writeEntry("WindowsBlockCompositing", windowsBlockCompositing()); + if (!compositingRequired()) { + kwinConfig.writeEntry("WindowsBlockCompositing", windowsBlockCompositing()); + } kwinConfig.sync(); if (m_changed) { @@ -368,6 +373,9 @@ bool Compositing::windowsBlockCompositing() const void Compositing::setWindowsBlockCompositing(bool set) { + if (compositingRequired()) { + return; + } if (m_windowsBlockCompositing == set) { return; } @@ -375,6 +383,11 @@ void Compositing::setWindowsBlockCompositing(bool set) emit windowsBlockCompositingChanged(set); } +bool Compositing::compositingRequired() const +{ + return m_compositingInterface->platformRequiresCompositing(); +} + CompositingType::CompositingType(QObject *parent) : QAbstractItemModel(parent) { diff --git a/kcmkwin/kwincompositing/compositing.h b/kcmkwin/kwincompositing/compositing.h index e739b25310..04a4478341 100644 --- a/kcmkwin/kwincompositing/compositing.h +++ b/kcmkwin/kwincompositing/compositing.h @@ -25,6 +25,8 @@ #include #include +class OrgKdeKwinCompositingInterface; + namespace KWin { namespace Compositing { @@ -45,6 +47,7 @@ class Compositing : public QObject Q_PROPERTY(KWin::Compositing::OpenGLPlatformInterfaceModel *openGLPlatformInterfaceModel READ openGLPlatformInterfaceModel CONSTANT) Q_PROPERTY(int openGLPlatformInterface READ openGLPlatformInterface WRITE setOpenGLPlatformInterface NOTIFY openGLPlatformInterfaceChanged) Q_PROPERTY(bool windowsBlockCompositing READ windowsBlockCompositing WRITE setWindowsBlockCompositing NOTIFY windowsBlockCompositingChanged) + Q_PROPERTY(bool compositingRequired READ compositingRequired CONSTANT) public: explicit Compositing(QObject *parent = 0); @@ -61,6 +64,7 @@ public: bool compositingEnabled() const; int openGLPlatformInterface() const; bool windowsBlockCompositing() const; + bool compositingRequired() const; OpenGLPlatformInterfaceModel *openGLPlatformInterfaceModel() const; @@ -107,6 +111,8 @@ private: OpenGLPlatformInterfaceModel *m_openGLPlatformInterfaceModel; int m_openGLPlatformInterface; bool m_windowsBlockCompositing; + bool m_windowsBlockingCompositing; + OrgKdeKwinCompositingInterface *m_compositingInterface; }; diff --git a/kcmkwin/kwincompositing/main.cpp b/kcmkwin/kwincompositing/main.cpp index cd4aac6822..a5d7cdeca3 100644 --- a/kcmkwin/kwincompositing/main.cpp +++ b/kcmkwin/kwincompositing/main.cpp @@ -87,6 +87,9 @@ KWinCompositingSettings::KWinCompositingSettings(QWidget *parent, const QVariant m_form.tearingWarning->setIcon(QIcon::fromTheme(QStringLiteral("dialog-warning"))); m_form.windowThumbnailWarning->setIcon(QIcon::fromTheme(QStringLiteral("dialog-warning"))); + m_form.compositingEnabled->setVisible(!m_compositing->compositingRequired()); + m_form.windowsBlockCompositing->setVisible(!m_compositing->compositingRequired()); + init(); } diff --git a/org.kde.kwin.Compositing.xml b/org.kde.kwin.Compositing.xml index d98732e121..88ff9e429d 100644 --- a/org.kde.kwin.Compositing.xml +++ b/org.kde.kwin.Compositing.xml @@ -7,6 +7,7 @@ +