2007-11-27 22:40:25 +03:00
|
|
|
/********************************************************************
|
2007-09-18 17:59:06 +04: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 22:40:25 +03: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 17:59:06 +04:00
|
|
|
|
|
|
|
#include "compositingprefs.h"
|
|
|
|
|
2013-06-25 11:53:45 +04:00
|
|
|
#include "main.h"
|
2012-12-21 18:11:31 +04:00
|
|
|
#include "xcbutils.h"
|
2010-12-04 00:13:43 +03:00
|
|
|
#include "kwinglplatform.h"
|
2014-12-05 13:42:15 +03:00
|
|
|
#include "utils.h"
|
2007-09-18 17:59:06 +04:00
|
|
|
|
2011-04-03 23:59:57 +04:00
|
|
|
#include <kconfiggroup.h>
|
2014-03-17 19:24:10 +04:00
|
|
|
#include <KLocalizedString>
|
2011-04-03 23:59:57 +04:00
|
|
|
#include <ksharedconfig.h>
|
2010-02-26 23:47:00 +03:00
|
|
|
|
2013-09-02 15:14:39 +04:00
|
|
|
#include <QDebug>
|
2015-10-30 15:18:30 +03:00
|
|
|
#include <QOpenGLContext>
|
2013-08-04 00:30:42 +04:00
|
|
|
#include <QStandardPaths>
|
2010-02-26 23:47:00 +03:00
|
|
|
#include <qprocess.h>
|
2007-09-18 17:59:06 +04:00
|
|
|
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2013-05-24 16:50:17 +04:00
|
|
|
extern int screen_number; // main.cpp
|
|
|
|
extern bool is_multihead;
|
|
|
|
|
2007-09-18 17:59:06 +04:00
|
|
|
CompositingPrefs::CompositingPrefs()
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
|
|
|
}
|
2007-10-17 19:37:14 +04:00
|
|
|
|
2007-09-18 17:59:06 +04:00
|
|
|
CompositingPrefs::~CompositingPrefs()
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
|
|
|
}
|
2007-09-18 17:59:06 +04:00
|
|
|
|
2011-04-03 23:59:57 +04:00
|
|
|
bool CompositingPrefs::openGlIsBroken()
|
|
|
|
{
|
2015-11-05 17:14:06 +03:00
|
|
|
const QString unsafeKey(QLatin1String("OpenGLIsUnsafe") + (is_multihead ? QString::number(screen_number) : QString()));
|
2013-09-04 18:10:36 +04:00
|
|
|
return KConfigGroup(KSharedConfig::openConfig(), "Compositing").readEntry(unsafeKey, false);
|
2011-04-03 23:59:57 +04:00
|
|
|
}
|
|
|
|
|
2007-09-26 20:34:08 +04:00
|
|
|
bool CompositingPrefs::compositingPossible()
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
2011-04-03 23:59:57 +04:00
|
|
|
// first off, check whether we figured that we'll crash on detection because of a buggy driver
|
2013-09-04 18:10:36 +04:00
|
|
|
KConfigGroup gl_workaround_group(KSharedConfig::openConfig(), "Compositing");
|
2015-11-05 17:14:06 +03:00
|
|
|
const QString unsafeKey(QLatin1String("OpenGLIsUnsafe") + (is_multihead ? QString::number(screen_number) : QString()));
|
|
|
|
if (gl_workaround_group.readEntry("Backend", "OpenGL") == QLatin1String("OpenGL") &&
|
2013-05-24 16:50:17 +04:00
|
|
|
gl_workaround_group.readEntry(unsafeKey, false))
|
2011-04-03 23:59:57 +04:00
|
|
|
return false;
|
|
|
|
|
2013-06-25 11:53:45 +04: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 18:11:31 +04:00
|
|
|
if (!Xcb::Extensions::self()->isCompositeAvailable()) {
|
2014-12-05 13:42:15 +03:00
|
|
|
qCDebug(KWIN_CORE) << "No composite extension available";
|
2007-09-26 20:34:08 +04:00
|
|
|
return false;
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2012-12-21 18:11:31 +04:00
|
|
|
if (!Xcb::Extensions::self()->isDamageAvailable()) {
|
2014-12-05 13:42:15 +03:00
|
|
|
qCDebug(KWIN_CORE) << "No damage extension available";
|
2007-09-26 20:34:08 +04:00
|
|
|
return false;
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2011-07-21 00:10:03 +04:00
|
|
|
if (hasGlx())
|
2007-12-17 17:14:53 +03:00
|
|
|
return true;
|
|
|
|
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
2012-12-21 18:11:31 +04:00
|
|
|
if (Xcb::Extensions::self()->isRenderAvailable() && Xcb::Extensions::self()->isFixesAvailable())
|
2007-12-17 17:14:53 +03:00
|
|
|
return true;
|
2010-12-12 14:08:23 +03:00
|
|
|
#endif
|
2015-10-30 15:18:30 +03:00
|
|
|
if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES) {
|
|
|
|
return true;
|
2015-11-02 15:54:53 +03:00
|
|
|
} else if (qstrcmp(qgetenv("KWIN_COMPOSE"), "O2ES") == 0) {
|
|
|
|
return true;
|
2015-10-30 15:18:30 +03:00
|
|
|
}
|
2014-12-05 13:42:15 +03:00
|
|
|
qCDebug(KWIN_CORE) << "No OpenGL or XRender/XFixes support";
|
2007-12-17 17:14:53 +03:00
|
|
|
return false;
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-09-26 20:34:08 +04:00
|
|
|
|
2007-11-12 19:32:25 +03:00
|
|
|
QString CompositingPrefs::compositingNotPossibleReason()
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
2011-04-03 23:59:57 +04:00
|
|
|
// first off, check whether we figured that we'll crash on detection because of a buggy driver
|
2013-09-04 18:10:36 +04:00
|
|
|
KConfigGroup gl_workaround_group(KSharedConfig::openConfig(), "Compositing");
|
2015-11-05 17:14:06 +03:00
|
|
|
const QString unsafeKey(QLatin1String("OpenGLIsUnsafe") + (is_multihead ? QString::number(screen_number) : QString()));
|
|
|
|
if (gl_workaround_group.readEntry("Backend", "OpenGL") == QLatin1String("OpenGL") &&
|
2013-05-24 16:50:17 +04:00
|
|
|
gl_workaround_group.readEntry(unsafeKey, false))
|
2011-04-03 23:59:57 +04: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 18:11:31 +04:00
|
|
|
if (!Xcb::Extensions::self()->isCompositeAvailable() || !Xcb::Extensions::self()->isDamageAvailable()) {
|
2007-11-12 19:32:25 +03:00
|
|
|
return i18n("Required X extensions (XComposite and XDamage) are not available.");
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2011-08-13 17:21:51 +04:00
|
|
|
#if !defined( KWIN_HAVE_XRENDER_COMPOSITING )
|
2011-07-21 00:10:03 +04:00
|
|
|
if (!hasGlx())
|
2011-01-30 17:34:42 +03:00
|
|
|
return i18n("GLX/OpenGL are not available and only OpenGL support is compiled.");
|
2008-01-08 14:26:52 +03:00
|
|
|
#else
|
2011-07-21 00:10:03 +04:00
|
|
|
if (!(hasGlx()
|
2012-12-21 18:11:31 +04:00
|
|
|
|| (Xcb::Extensions::self()->isRenderAvailable() && Xcb::Extensions::self()->isFixesAvailable()))) {
|
2011-01-30 17:34:42 +03:00
|
|
|
return i18n("GLX/OpenGL and XRender/XFixes are not available.");
|
|
|
|
}
|
2007-12-17 17:14:53 +03:00
|
|
|
#endif
|
2007-11-12 19:32:25 +03:00
|
|
|
return QString();
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-11-12 19:32:25 +03:00
|
|
|
|
2011-07-21 00:10:03 +04:00
|
|
|
bool CompositingPrefs::hasGlx()
|
|
|
|
{
|
2014-09-18 19:09:16 +04:00
|
|
|
return Xcb::Extensions::self()->hasGlx();
|
2011-07-21 00:10:03 +04:00
|
|
|
}
|
|
|
|
|
2007-09-18 17:59:06 +04:00
|
|
|
} // namespace
|
|
|
|
|