2016-04-08 07:51:06 +00:00
|
|
|
/********************************************************************
|
|
|
|
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
|
|
|
|
{
|
2016-08-16 13:31:14 +00:00
|
|
|
class XInputIntegration;
|
2016-11-15 09:22:56 +00:00
|
|
|
class WindowSelector;
|
2017-08-19 08:58:05 +00:00
|
|
|
class X11EventFilter;
|
2016-04-08 07:51:06 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2016-04-08 08:32:37 +00:00
|
|
|
Screens *createScreens(QObject *parent = nullptr) override;
|
2016-04-12 13:03:07 +00:00
|
|
|
OpenGLBackend *createOpenGLBackend() override;
|
2016-04-15 11:47:56 +00:00
|
|
|
Edge *createScreenEdge(ScreenEdges *parent) override;
|
2016-08-15 10:00:03 +00:00
|
|
|
void createPlatformCursor(QObject *parent = nullptr) override;
|
2016-05-09 14:41:37 +00:00
|
|
|
bool requiresCompositing() const override;
|
2016-05-09 15:32:43 +00:00
|
|
|
bool compositingPossible() const override;
|
|
|
|
QString compositingNotPossibleReason() const override;
|
|
|
|
bool openGLCompositingIsBroken() const override;
|
2016-05-10 08:34:09 +00:00
|
|
|
void createOpenGLSafePoint(OpenGLSafePoint safePoint) override;
|
2016-11-15 09:22:56 +00:00
|
|
|
void startInteractiveWindowSelection(std::function<void (KWin::Toplevel *)> callback, const QByteArray &cursorName = QByteArray()) override;
|
2016-05-09 15:32:43 +00:00
|
|
|
|
2016-10-17 14:12:21 +00:00
|
|
|
PlatformCursorImage cursorImage() const override;
|
|
|
|
|
2017-01-17 06:12:44 +00:00
|
|
|
void setupActionForGlobalAccel(QAction *action) override;
|
|
|
|
|
2017-08-07 15:54:56 +00:00
|
|
|
OverlayWindow *createOverlayWindow() override;
|
|
|
|
|
2017-08-24 14:53:40 +00:00
|
|
|
void updateXTime() override;
|
2017-08-21 09:59:52 +00:00
|
|
|
OutlineVisual *createOutline(Outline *outline) override;
|
2017-08-24 14:53:40 +00:00
|
|
|
|
2016-10-20 08:21:54 +00:00
|
|
|
protected:
|
|
|
|
void doHideCursor() override;
|
|
|
|
void doShowCursor() override;
|
|
|
|
|
2016-05-09 15:32:43 +00:00
|
|
|
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();
|
2016-04-08 08:32:37 +00:00
|
|
|
|
2016-08-16 13:31:14 +00:00
|
|
|
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;
|
2016-11-11 08:59:46 +00:00
|
|
|
Display *m_x11Display;
|
2016-11-15 09:22:56 +00:00
|
|
|
QScopedPointer<WindowSelector> m_windowSelector;
|
2017-08-19 08:58:05 +00:00
|
|
|
QScopedPointer<X11EventFilter> m_screenEdgesFilter;
|
2016-08-16 13:31:14 +00:00
|
|
|
|
2016-04-08 07:51:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|