kwin/plugins/platforms/x11/standalone/x11_platform.h

85 lines
2.8 KiB
C
Raw Normal View History

/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2016 Martin Gräßlin <mgraesslin@kde.org>
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_X11STANDALONE_PLATFORM_H
#define KWIN_X11STANDALONE_PLATFORM_H
#include "platform.h"
#include <kwin_export.h>
#include <QObject>
namespace KWin
{
class XInputIntegration;
class WindowSelector;
class KWIN_EXPORT X11StandalonePlatform : public Platform
{
Q_OBJECT
Q_INTERFACES(KWin::Platform)
Q_PLUGIN_METADATA(IID "org.kde.kwin.Platform" FILE "x11.json")
public:
X11StandalonePlatform(QObject *parent = nullptr);
virtual ~X11StandalonePlatform();
void init() override;
Screens *createScreens(QObject *parent = nullptr) override;
OpenGLBackend *createOpenGLBackend() override;
Edge *createScreenEdge(ScreenEdges *parent) override;
void createPlatformCursor(QObject *parent = nullptr) override;
bool requiresCompositing() const override;
bool compositingPossible() const override;
QString compositingNotPossibleReason() const override;
bool openGLCompositingIsBroken() const override;
void createOpenGLSafePoint(OpenGLSafePoint safePoint) override;
void startInteractiveWindowSelection(std::function<void (KWin::Toplevel *)> callback, const QByteArray &cursorName = QByteArray()) override;
PlatformCursorImage cursorImage() const override;
void setupActionForGlobalAccel(QAction *action) override;
protected:
void doHideCursor() override;
void doShowCursor() 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();
XInputIntegration *m_xinputIntegration = nullptr;
[platformx/x11] Add a freeze protection against OpenGL Summary: With nouveau driver it can happen that KWin gets frozen when first trying to render with OpenGL. This results in a freeze of the complete desktop as the compositor is non functional. Our OpenGL breakage detection is only able to detect crashes, but not freezes. This change improves it by also added a freeze protection. In the PreInit stage a thread is started with a QTimer of 15 sec. If the timer fires, qFatal is triggered to terminate KWin. This can only happen if the creation of the OpenGL compositor takes longer than said 15 sec. In the PostInit stage the timer gets deleted and the thread stopeed again. Thus if a freeze is detected the OpenGL unsafe protection is written into the config. KWin aborts and gets restarted by DrKonqui. The new KWin instance will no longer try to activate the freezing OpenGL as the protection is set. If KWin doesn't freeze the protection is removed from the config as we are used to. Check for freezes for the first n frames, not just the first This patch changes the freeze detection code to detect freezes in the first 30 frames (by default, users can change that with the KWIN_MAX_FRAMES_TESTED environment variable). This detects successfully the freezes associated to nouveau drivers in https://bugzilla.suse.com/show_bug.cgi?id=1005323 Reviewers: davidedmundson, #plasma, #kwin, graesslin Reviewed By: #plasma, #kwin, graesslin Subscribers: luebking, graesslin, kwin, plasma-devel, davidedmundson Tags: #plasma Differential Revision: https://phabricator.kde.org/D3132
2016-10-24 15:14:32 +00:00
QThread *m_openGLFreezeProtectionThread = nullptr;
QTimer *m_openGLFreezeProtection = nullptr;
Display *m_x11Display;
QScopedPointer<WindowSelector> m_windowSelector;
};
}
#endif