Commit e8e6e31a authored by Martin Flöser's avatar Martin Flöser

[kcmkwin/compositing] Hide config options which don't make sense if Compositing is required

Summary:
On Wayland compositing is required. It doesn't make any sense to offer
the user to disable the compositor or to allow windows to block
compositing.

The Compositor DBus interface gains a new property whether the platform
requires compositing. This is queried by the compositing kcm and based
on that the two mentioned options get hidden and not stored to config
file.

Test Plan: Opened the KCM on Wayland

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D2586
parent 85302033
......@@ -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);
......
......@@ -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:
/**
......
......@@ -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) {
......
......@@ -25,6 +25,8 @@
#include <QAbstractItemModel>
#include <QObject>
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;
};
......
......@@ -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();
}
......
......@@ -7,6 +7,7 @@
<property name="openGLIsBroken" type="b" access="read"/>
<property name="compositingType" type="s" access="read"/>
<property name="supportedOpenGLPlatformInterfaces" type="as" access="read"/>
<property name="platformRequiresCompositing" type="b" access="read"/>
<signal name="compositingToggled">
<arg name="active" type="b" direction="out"/>
</signal>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment