Provide functionality of CompositingPrefs through Platform
Summary: CompositingPrefs is only relevant for X11 standalone. It had some "hacks" to make it not block Compositing on Wayland. Thus it was in its current form not really useful. Now all the functionality is provided through Platform with a default implementation which is sensible for Wayland platforms. The X11 standalone platform implements the new methods with the Wayland checks removed. In addition all calls to CompositingPrefs now go through the platform directly and CompositingPrefs is completely dropped. Reviewers: #plasma Subscribers: plasma-devel Projects: #plasma Differential Revision: https://phabricator.kde.org/D1576
This commit is contained in:
parent
c45942a70c
commit
d15d3a5ff1
10 changed files with 135 additions and 197 deletions
|
@ -388,7 +388,6 @@ set(kwin_KDEINIT_SRCS
|
|||
deleted.cpp
|
||||
effects.cpp
|
||||
effectloader.cpp
|
||||
compositingprefs.cpp
|
||||
virtualdesktops.cpp
|
||||
xcbutils.cpp
|
||||
x11eventfilter.cpp
|
||||
|
|
|
@ -35,7 +35,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "screens.h"
|
||||
#include "shadow.h"
|
||||
#include "useractions.h"
|
||||
#include "compositingprefs.h"
|
||||
#include "xcbutils.h"
|
||||
#include "platform.h"
|
||||
#include "shell_client.h"
|
||||
|
@ -170,7 +169,7 @@ void Compositor::setup()
|
|||
}
|
||||
qCDebug(KWIN_CORE) << "Compositing is suspended, reason:" << reasons;
|
||||
return;
|
||||
} else if (!CompositingPrefs::compositingPossible()) {
|
||||
} else if (!kwinApp()->platform()->compositingPossible()) {
|
||||
qCCritical(KWIN_CORE) << "Compositing is not possible";
|
||||
return;
|
||||
}
|
||||
|
@ -211,7 +210,7 @@ void Compositor::slotCompositingOptionsInitialized()
|
|||
else {
|
||||
unsafeConfig.writeEntry(openGLIsUnsafe, true);
|
||||
unsafeConfig.sync();
|
||||
if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL && !kwinApp()->shouldUseWaylandForCompositing() && !CompositingPrefs::hasGlx()) {
|
||||
if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL && !kwinApp()->shouldUseWaylandForCompositing() && !Xcb::Extensions::self()->hasGlx()) {
|
||||
unsafeConfig.writeEntry(openGLIsUnsafe, false);
|
||||
unsafeConfig.sync();
|
||||
qCDebug(KWIN_CORE) << "No glx extensions available";
|
||||
|
|
|
@ -1,129 +0,0 @@
|
|||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2007 Rivo Laks <rivolaks@hot.ee>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************/
|
||||
|
||||
#include "compositingprefs.h"
|
||||
|
||||
#include "main.h"
|
||||
#include "xcbutils.h"
|
||||
#include "kwinglplatform.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include <kconfiggroup.h>
|
||||
#include <KLocalizedString>
|
||||
#include <ksharedconfig.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QOpenGLContext>
|
||||
#include <QStandardPaths>
|
||||
#include <qprocess.h>
|
||||
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
extern int screen_number; // main.cpp
|
||||
extern bool is_multihead;
|
||||
|
||||
CompositingPrefs::CompositingPrefs()
|
||||
{
|
||||
}
|
||||
|
||||
CompositingPrefs::~CompositingPrefs()
|
||||
{
|
||||
}
|
||||
|
||||
bool CompositingPrefs::openGlIsBroken()
|
||||
{
|
||||
const QString unsafeKey(QLatin1String("OpenGLIsUnsafe") + (is_multihead ? QString::number(screen_number) : QString()));
|
||||
return KConfigGroup(kwinApp()->config(), "Compositing").readEntry(unsafeKey, false);
|
||||
}
|
||||
|
||||
bool CompositingPrefs::compositingPossible()
|
||||
{
|
||||
// first off, check whether we figured that we'll crash on detection because of a buggy driver
|
||||
KConfigGroup gl_workaround_group(kwinApp()->config(), "Compositing");
|
||||
const QString unsafeKey(QLatin1String("OpenGLIsUnsafe") + (is_multihead ? QString::number(screen_number) : QString()));
|
||||
if (gl_workaround_group.readEntry("Backend", "OpenGL") == QLatin1String("OpenGL") &&
|
||||
gl_workaround_group.readEntry(unsafeKey, false))
|
||||
return false;
|
||||
|
||||
if (kwinApp()->shouldUseWaylandForCompositing()) {
|
||||
// don't do X specific checks if we are not going to use X for compositing
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Xcb::Extensions::self()->isCompositeAvailable()) {
|
||||
qCDebug(KWIN_CORE) << "No composite extension available";
|
||||
return false;
|
||||
}
|
||||
if (!Xcb::Extensions::self()->isDamageAvailable()) {
|
||||
qCDebug(KWIN_CORE) << "No damage extension available";
|
||||
return false;
|
||||
}
|
||||
if (hasGlx())
|
||||
return true;
|
||||
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
||||
if (Xcb::Extensions::self()->isRenderAvailable() && Xcb::Extensions::self()->isFixesAvailable())
|
||||
return true;
|
||||
#endif
|
||||
if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES) {
|
||||
return true;
|
||||
} else if (qstrcmp(qgetenv("KWIN_COMPOSE"), "O2ES") == 0) {
|
||||
return true;
|
||||
}
|
||||
qCDebug(KWIN_CORE) << "No OpenGL or XRender/XFixes support";
|
||||
return false;
|
||||
}
|
||||
|
||||
QString CompositingPrefs::compositingNotPossibleReason()
|
||||
{
|
||||
// first off, check whether we figured that we'll crash on detection because of a buggy driver
|
||||
KConfigGroup gl_workaround_group(kwinApp()->config(), "Compositing");
|
||||
const QString unsafeKey(QLatin1String("OpenGLIsUnsafe") + (is_multihead ? QString::number(screen_number) : QString()));
|
||||
if (gl_workaround_group.readEntry("Backend", "OpenGL") == QLatin1String("OpenGL") &&
|
||||
gl_workaround_group.readEntry(unsafeKey, false))
|
||||
return i18n("<b>OpenGL compositing (the default) has crashed KWin in the past.</b><br>"
|
||||
"This was most likely due to a driver bug."
|
||||
"<p>If you think that you have meanwhile upgraded to a stable driver,<br>"
|
||||
"you can reset this protection but <b>be aware that this might result in an immediate crash!</b></p>"
|
||||
"<p>Alternatively, you might want to use the XRender backend instead.</p>");
|
||||
|
||||
if (!Xcb::Extensions::self()->isCompositeAvailable() || !Xcb::Extensions::self()->isDamageAvailable()) {
|
||||
return i18n("Required X extensions (XComposite and XDamage) are not available.");
|
||||
}
|
||||
#if !defined( KWIN_HAVE_XRENDER_COMPOSITING )
|
||||
if (!hasGlx())
|
||||
return i18n("GLX/OpenGL are not available and only OpenGL support is compiled.");
|
||||
#else
|
||||
if (!(hasGlx()
|
||||
|| (Xcb::Extensions::self()->isRenderAvailable() && Xcb::Extensions::self()->isFixesAvailable()))) {
|
||||
return i18n("GLX/OpenGL and XRender/XFixes are not available.");
|
||||
}
|
||||
#endif
|
||||
return QString();
|
||||
}
|
||||
|
||||
bool CompositingPrefs::hasGlx()
|
||||
{
|
||||
return Xcb::Extensions::self()->hasGlx();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2007 Rivo Laks <rivolaks@hot.ee>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************/
|
||||
|
||||
#ifndef KWIN_COMPOSITINGPREFS_H
|
||||
#define KWIN_COMPOSITINGPREFS_H
|
||||
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
#include "kwinglutils.h"
|
||||
#include "kwinglobals.h"
|
||||
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
class CompositingPrefs
|
||||
{
|
||||
public:
|
||||
CompositingPrefs();
|
||||
~CompositingPrefs();
|
||||
|
||||
static bool compositingPossible();
|
||||
static QString compositingNotPossibleReason();
|
||||
static bool openGlIsBroken();
|
||||
/**
|
||||
* Tests whether GLX is supported and returns @c true
|
||||
* in case KWin is compiled with OpenGL support and GLX
|
||||
* is available.
|
||||
*
|
||||
* If KWin is compiled with OpenGL ES or without OpenGL at
|
||||
* all, @c false is returned.
|
||||
* @returns @c true if GLX is available, @c false otherwise and if not build with OpenGL support.
|
||||
**/
|
||||
static bool hasGlx();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //KWIN_COMPOSITINGPREFS_H
|
||||
|
||||
|
|
@ -25,10 +25,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
// kwin
|
||||
#include "atoms.h"
|
||||
#include "composite.h"
|
||||
#include "compositingprefs.h"
|
||||
#include "debug_console.h"
|
||||
#include "main.h"
|
||||
#include "placement.h"
|
||||
#include "platform.h"
|
||||
#include "kwinadaptor.h"
|
||||
#include "scene.h"
|
||||
#include "workspace.h"
|
||||
|
@ -195,7 +195,7 @@ CompositorDBusInterface::CompositorDBusInterface(Compositor *parent)
|
|||
|
||||
QString CompositorDBusInterface::compositingNotPossibleReason() const
|
||||
{
|
||||
return CompositingPrefs::compositingNotPossibleReason();
|
||||
return kwinApp()->platform()->compositingNotPossibleReason();
|
||||
}
|
||||
|
||||
QString CompositorDBusInterface::compositingType() const
|
||||
|
@ -227,12 +227,12 @@ bool CompositorDBusInterface::isActive() const
|
|||
|
||||
bool CompositorDBusInterface::isCompositingPossible() const
|
||||
{
|
||||
return CompositingPrefs::compositingPossible();
|
||||
return kwinApp()->platform()->compositingPossible();
|
||||
}
|
||||
|
||||
bool CompositorDBusInterface::isOpenGLBroken() const
|
||||
{
|
||||
return CompositingPrefs::openGlIsBroken();
|
||||
return kwinApp()->platform()->openGLCompositingIsBroken();
|
||||
}
|
||||
|
||||
void CompositorDBusInterface::resume()
|
||||
|
|
|
@ -29,7 +29,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
#include <QProcess>
|
||||
|
||||
#include "compositingprefs.h"
|
||||
#include "screens.h"
|
||||
#include "settings.h"
|
||||
#include "xcbutils.h"
|
||||
|
|
15
platform.cpp
15
platform.cpp
|
@ -286,4 +286,19 @@ bool Platform::requiresCompositing() const
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Platform::compositingPossible() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
QString Platform::compositingNotPossibleReason() const
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
bool Platform::openGLCompositingIsBroken() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
24
platform.h
24
platform.h
|
@ -100,6 +100,30 @@ public:
|
|||
* without compositing (e.g. rendering is done by the windowing system), re-implement this method.
|
||||
**/
|
||||
virtual bool requiresCompositing() const;
|
||||
/**
|
||||
* Whether Compositing is possible in the Platform.
|
||||
* Returning @c false in this method makes only sense if @link{requiresCompositing} returns @c false.
|
||||
*
|
||||
* The default implementation returns @c true.
|
||||
* @see requiresCompositing
|
||||
**/
|
||||
virtual bool compositingPossible() const;
|
||||
/**
|
||||
* Returns a user facing text explaining why compositing is not possible in case
|
||||
* @link{compositingPossible} returns @c false.
|
||||
*
|
||||
* The default implementation returns an empty string.
|
||||
* @see compositingPossible
|
||||
**/
|
||||
virtual QString compositingNotPossibleReason() const;
|
||||
/**
|
||||
* Whether OpenGL compositing is broken.
|
||||
* The Platform can implement this method if it is able to detect whether OpenGL compositing
|
||||
* broke (e.g. triggered a crash in a previous run).
|
||||
*
|
||||
* Default implementation returns @c false.
|
||||
**/
|
||||
virtual bool openGLCompositingIsBroken() const;
|
||||
|
||||
bool usesSoftwareCursor() const {
|
||||
return m_softWareCursor;
|
||||
|
|
|
@ -27,6 +27,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "screens_xrandr.h"
|
||||
#include "options.h"
|
||||
|
||||
#include <KConfigGroup>
|
||||
#include <KLocalizedString>
|
||||
|
||||
#include <QOpenGLContext>
|
||||
#include <QX11Info>
|
||||
|
||||
namespace KWin
|
||||
|
@ -79,5 +83,76 @@ bool X11StandalonePlatform::requiresCompositing() const
|
|||
return false;
|
||||
}
|
||||
|
||||
bool X11StandalonePlatform::openGLCompositingIsBroken() const
|
||||
{
|
||||
const QString unsafeKey(QLatin1String("OpenGLIsUnsafe") + (kwinApp()->isX11MultiHead() ? QString::number(kwinApp()->x11ScreenNumber()) : QString()));
|
||||
return KConfigGroup(kwinApp()->config(), "Compositing").readEntry(unsafeKey, false);
|
||||
}
|
||||
|
||||
QString X11StandalonePlatform::compositingNotPossibleReason() const
|
||||
{
|
||||
// first off, check whether we figured that we'll crash on detection because of a buggy driver
|
||||
KConfigGroup gl_workaround_group(kwinApp()->config(), "Compositing");
|
||||
const QString unsafeKey(QLatin1String("OpenGLIsUnsafe") + (kwinApp()->isX11MultiHead() ? QString::number(kwinApp()->x11ScreenNumber()) : QString()));
|
||||
if (gl_workaround_group.readEntry("Backend", "OpenGL") == QLatin1String("OpenGL") &&
|
||||
gl_workaround_group.readEntry(unsafeKey, false))
|
||||
return i18n("<b>OpenGL compositing (the default) has crashed KWin in the past.</b><br>"
|
||||
"This was most likely due to a driver bug."
|
||||
"<p>If you think that you have meanwhile upgraded to a stable driver,<br>"
|
||||
"you can reset this protection but <b>be aware that this might result in an immediate crash!</b></p>"
|
||||
"<p>Alternatively, you might want to use the XRender backend instead.</p>");
|
||||
|
||||
if (!Xcb::Extensions::self()->isCompositeAvailable() || !Xcb::Extensions::self()->isDamageAvailable()) {
|
||||
return i18n("Required X extensions (XComposite and XDamage) are not available.");
|
||||
}
|
||||
#if !defined( KWIN_HAVE_XRENDER_COMPOSITING )
|
||||
if (!hasGlx())
|
||||
return i18n("GLX/OpenGL are not available and only OpenGL support is compiled.");
|
||||
#else
|
||||
if (!(hasGlx()
|
||||
|| (Xcb::Extensions::self()->isRenderAvailable() && Xcb::Extensions::self()->isFixesAvailable()))) {
|
||||
return i18n("GLX/OpenGL and XRender/XFixes are not available.");
|
||||
}
|
||||
#endif
|
||||
return QString();
|
||||
}
|
||||
|
||||
bool X11StandalonePlatform::compositingPossible() const
|
||||
{
|
||||
// first off, check whether we figured that we'll crash on detection because of a buggy driver
|
||||
KConfigGroup gl_workaround_group(kwinApp()->config(), "Compositing");
|
||||
const QString unsafeKey(QLatin1String("OpenGLIsUnsafe") + (kwinApp()->isX11MultiHead() ? QString::number(kwinApp()->x11ScreenNumber()) : QString()));
|
||||
if (gl_workaround_group.readEntry("Backend", "OpenGL") == QLatin1String("OpenGL") &&
|
||||
gl_workaround_group.readEntry(unsafeKey, false))
|
||||
return false;
|
||||
|
||||
|
||||
if (!Xcb::Extensions::self()->isCompositeAvailable()) {
|
||||
qCDebug(KWIN_CORE) << "No composite extension available";
|
||||
return false;
|
||||
}
|
||||
if (!Xcb::Extensions::self()->isDamageAvailable()) {
|
||||
qCDebug(KWIN_CORE) << "No damage extension available";
|
||||
return false;
|
||||
}
|
||||
if (hasGlx())
|
||||
return true;
|
||||
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
||||
if (Xcb::Extensions::self()->isRenderAvailable() && Xcb::Extensions::self()->isFixesAvailable())
|
||||
return true;
|
||||
#endif
|
||||
if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES) {
|
||||
return true;
|
||||
} else if (qstrcmp(qgetenv("KWIN_COMPOSE"), "O2ES") == 0) {
|
||||
return true;
|
||||
}
|
||||
qCDebug(KWIN_CORE) << "No OpenGL or XRender/XFixes support";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool X11StandalonePlatform::hasGlx()
|
||||
{
|
||||
return Xcb::Extensions::self()->hasGlx();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -42,6 +42,21 @@ public:
|
|||
OpenGLBackend *createOpenGLBackend() override;
|
||||
Edge *createScreenEdge(ScreenEdges *parent) override;
|
||||
bool requiresCompositing() const override;
|
||||
bool compositingPossible() const override;
|
||||
QString compositingNotPossibleReason() const override;
|
||||
bool openGLCompositingIsBroken() const override;
|
||||
|
||||
private:
|
||||
/**
|
||||
* Tests whether GLX is supported and returns @c true
|
||||
* in case KWin is compiled with OpenGL support and GLX
|
||||
* is available.
|
||||
*
|
||||
* If KWin is compiled with OpenGL ES or without OpenGL at
|
||||
* all, @c false is returned.
|
||||
* @returns @c true if GLX is available, @c false otherwise and if not build with OpenGL support.
|
||||
**/
|
||||
static bool hasGlx();
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue