2007-11-27 19:40:25 +00:00
|
|
|
/********************************************************************
|
2007-09-18 13:59:06 +00:00
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2007 Rivo Laks <rivolaks@hot.ee>
|
|
|
|
|
2007-11-27 19:40:25 +00:00
|
|
|
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/>.
|
|
|
|
*********************************************************************/
|
2007-09-18 13:59:06 +00:00
|
|
|
|
|
|
|
#include "compositingprefs.h"
|
|
|
|
|
2013-06-25 07:53:45 +00:00
|
|
|
#include "main.h"
|
2012-12-21 14:11:31 +00:00
|
|
|
#include "xcbutils.h"
|
2010-12-03 21:13:43 +00:00
|
|
|
#include "kwinglplatform.h"
|
2007-09-18 13:59:06 +00:00
|
|
|
|
2011-04-03 19:59:57 +00:00
|
|
|
#include <kconfiggroup.h>
|
2014-03-17 15:24:10 +00:00
|
|
|
#include <KLocalizedString>
|
2011-04-03 19:59:57 +00:00
|
|
|
#include <ksharedconfig.h>
|
2010-02-26 20:47:00 +00:00
|
|
|
|
2013-09-02 11:14:39 +00:00
|
|
|
#include <QDebug>
|
2013-08-03 20:30:42 +00:00
|
|
|
#include <QStandardPaths>
|
2010-02-26 20:47:00 +00:00
|
|
|
#include <qprocess.h>
|
2007-09-18 13:59:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2013-05-24 12:50:17 +00:00
|
|
|
extern int screen_number; // main.cpp
|
|
|
|
extern bool is_multihead;
|
|
|
|
|
2007-09-18 13:59:06 +00:00
|
|
|
CompositingPrefs::CompositingPrefs()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
}
|
2007-10-17 15:37:14 +00:00
|
|
|
|
2007-09-18 13:59:06 +00:00
|
|
|
CompositingPrefs::~CompositingPrefs()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
}
|
2007-09-18 13:59:06 +00:00
|
|
|
|
2011-04-03 19:59:57 +00:00
|
|
|
bool CompositingPrefs::openGlIsBroken()
|
|
|
|
{
|
2013-07-23 05:02:52 +00:00
|
|
|
const QString unsafeKey(QStringLiteral("OpenGLIsUnsafe") + (is_multihead ? QString::number(screen_number) : QString()));
|
2013-09-04 14:10:36 +00:00
|
|
|
return KConfigGroup(KSharedConfig::openConfig(), "Compositing").readEntry(unsafeKey, false);
|
2011-04-03 19:59:57 +00:00
|
|
|
}
|
|
|
|
|
2007-09-26 16:34:08 +00:00
|
|
|
bool CompositingPrefs::compositingPossible()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2011-04-03 19:59:57 +00:00
|
|
|
// first off, check whether we figured that we'll crash on detection because of a buggy driver
|
2013-09-04 14:10:36 +00:00
|
|
|
KConfigGroup gl_workaround_group(KSharedConfig::openConfig(), "Compositing");
|
2013-07-23 05:02:52 +00:00
|
|
|
const QString unsafeKey(QStringLiteral("OpenGLIsUnsafe") + (is_multihead ? QString::number(screen_number) : QString()));
|
|
|
|
if (gl_workaround_group.readEntry("Backend", "OpenGL") == QStringLiteral("OpenGL") &&
|
2013-05-24 12:50:17 +00:00
|
|
|
gl_workaround_group.readEntry(unsafeKey, false))
|
2011-04-03 19:59:57 +00:00
|
|
|
return false;
|
|
|
|
|
2013-06-25 07:53:45 +00:00
|
|
|
if (kwinApp()->shouldUseWaylandForCompositing()) {
|
|
|
|
// don't do X specific checks if we are not going to use X for compositing
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-12-21 14:11:31 +00:00
|
|
|
if (!Xcb::Extensions::self()->isCompositeAvailable()) {
|
2013-09-02 11:14:39 +00:00
|
|
|
qDebug() << "No composite extension available";
|
2007-09-26 16:34:08 +00:00
|
|
|
return false;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2012-12-21 14:11:31 +00:00
|
|
|
if (!Xcb::Extensions::self()->isDamageAvailable()) {
|
2013-09-02 11:14:39 +00:00
|
|
|
qDebug() << "No damage extension available";
|
2007-09-26 16:34:08 +00:00
|
|
|
return false;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2011-07-20 20:10:03 +00:00
|
|
|
if (hasGlx())
|
2007-12-17 14:14:53 +00:00
|
|
|
return true;
|
|
|
|
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
2012-12-21 14:11:31 +00:00
|
|
|
if (Xcb::Extensions::self()->isRenderAvailable() && Xcb::Extensions::self()->isFixesAvailable())
|
2007-12-17 14:14:53 +00:00
|
|
|
return true;
|
2010-12-12 11:08:23 +00:00
|
|
|
#endif
|
|
|
|
#ifdef KWIN_HAVE_OPENGLES
|
|
|
|
return true;
|
2007-12-17 14:14:53 +00:00
|
|
|
#endif
|
2013-09-02 11:14:39 +00:00
|
|
|
qDebug() << "No OpenGL or XRender/XFixes support";
|
2007-12-17 14:14:53 +00:00
|
|
|
return false;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-09-26 16:34:08 +00:00
|
|
|
|
2007-11-12 16:32:25 +00:00
|
|
|
QString CompositingPrefs::compositingNotPossibleReason()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2011-04-03 19:59:57 +00:00
|
|
|
// first off, check whether we figured that we'll crash on detection because of a buggy driver
|
2013-09-04 14:10:36 +00:00
|
|
|
KConfigGroup gl_workaround_group(KSharedConfig::openConfig(), "Compositing");
|
2013-07-23 05:02:52 +00:00
|
|
|
const QString unsafeKey(QStringLiteral("OpenGLIsUnsafe") + (is_multihead ? QString::number(screen_number) : QString()));
|
|
|
|
if (gl_workaround_group.readEntry("Backend", "OpenGL") == QStringLiteral("OpenGL") &&
|
2013-05-24 12:50:17 +00:00
|
|
|
gl_workaround_group.readEntry(unsafeKey, false))
|
2011-04-03 19:59:57 +00:00
|
|
|
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>");
|
|
|
|
|
2012-12-21 14:11:31 +00:00
|
|
|
if (!Xcb::Extensions::self()->isCompositeAvailable() || !Xcb::Extensions::self()->isDamageAvailable()) {
|
2007-11-12 16:32:25 +00:00
|
|
|
return i18n("Required X extensions (XComposite and XDamage) are not available.");
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2011-08-13 13:21:51 +00:00
|
|
|
#if !defined( KWIN_HAVE_XRENDER_COMPOSITING )
|
2011-07-20 20:10:03 +00:00
|
|
|
if (!hasGlx())
|
2011-01-30 14:34:42 +00:00
|
|
|
return i18n("GLX/OpenGL are not available and only OpenGL support is compiled.");
|
2008-01-08 11:26:52 +00:00
|
|
|
#else
|
2011-07-20 20:10:03 +00:00
|
|
|
if (!(hasGlx()
|
2012-12-21 14:11:31 +00:00
|
|
|
|| (Xcb::Extensions::self()->isRenderAvailable() && Xcb::Extensions::self()->isFixesAvailable()))) {
|
2011-01-30 14:34:42 +00:00
|
|
|
return i18n("GLX/OpenGL and XRender/XFixes are not available.");
|
|
|
|
}
|
2007-12-17 14:14:53 +00:00
|
|
|
#endif
|
2007-11-12 16:32:25 +00:00
|
|
|
return QString();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-11-12 16:32:25 +00:00
|
|
|
|
2011-07-20 20:10:03 +00:00
|
|
|
bool CompositingPrefs::hasGlx()
|
|
|
|
{
|
2014-09-18 15:09:16 +00:00
|
|
|
return Xcb::Extensions::self()->hasGlx();
|
2011-07-20 20:10:03 +00:00
|
|
|
}
|
|
|
|
|
2007-09-18 13:59:06 +00:00
|
|
|
} // namespace
|
|
|
|
|