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/>.
|
|
|
|
*********************************************************************/
|
2018-08-29 18:02:16 +00:00
|
|
|
#ifndef KWIN_X11_PLATFORM_H
|
|
|
|
#define KWIN_X11_PLATFORM_H
|
2016-04-08 07:51:06 +00:00
|
|
|
#include "platform.h"
|
|
|
|
|
|
|
|
#include <kwin_export.h>
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
2017-09-22 18:35:50 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2016-04-08 07:51:06 +00:00
|
|
|
namespace KWin
|
|
|
|
{
|
2017-09-22 18:35:50 +00:00
|
|
|
class SyncFilter;
|
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;
|
2019-06-13 09:36:07 +00:00
|
|
|
class X11Output;
|
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);
|
Run clang-tidy with modernize-use-override check
Summary:
Currently code base of kwin can be viewed as two pieces. One is very
ancient, and the other one is more modern, which uses new C++ features.
The main problem with the ancient code is that it was written before
C++11 era. So, no override or final keywords, lambdas, etc.
Quite recently, KDE compiler settings were changed to show a warning if
a virtual method has missing override keyword. As you might have already
guessed, this fired back at us because of that ancient code. We had
about 500 new compiler warnings.
A "solution" was proposed to that problem - disable -Wno-suggest-override
and the other similar warning for clang. It's hard to call a solution
because those warnings are disabled not only for the old code, but also
for new. This is not what we want!
The main argument for not actually fixing the problem was that git
history will be screwed as well because of human factor. While good git
history is a very important thing, we should not go crazy about it and
block every change that somehow alters git history. git blame allows to
specify starting revision for a reason.
The other argument (human factor) can be easily solved by using tools
such as clang-tidy. clang-tidy is a clang-based linter for C++. It can
be used for various things, e.g. fixing coding style(e.g. add missing
braces to if statements, readability-braces-around-statements check),
or in our case add missing override keywords.
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, apol, romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D22371
2019-07-22 16:52:26 +00:00
|
|
|
~X11StandalonePlatform() override;
|
2016-04-08 07:51:06 +00:00
|
|
|
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;
|
2018-02-04 17:01:30 +00:00
|
|
|
void startInteractivePositionSelection(std::function<void (const QPoint &)> callback) 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-20 20:15:21 +00:00
|
|
|
Decoration::Renderer *createDecorationRenderer(Decoration::DecoratedClientImpl *client) override;
|
2017-08-24 14:53:40 +00:00
|
|
|
|
2017-08-21 06:53:56 +00:00
|
|
|
void invertScreen() override;
|
|
|
|
|
2017-09-23 18:21:26 +00:00
|
|
|
void createEffectsHandler(Compositor *compositor, Scene *scene) override;
|
2017-10-15 20:24:49 +00:00
|
|
|
QVector<CompositingType> supportedCompositors() const override;
|
2017-09-23 18:21:26 +00:00
|
|
|
|
2019-06-13 09:36:07 +00:00
|
|
|
void initOutputs();
|
|
|
|
void updateOutputs();
|
|
|
|
|
|
|
|
Outputs outputs() const override;
|
|
|
|
Outputs enabledOutputs() const override;
|
|
|
|
|
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.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-05-09 15:32:43 +00:00
|
|
|
static bool hasGlx();
|
2016-04-08 08:32:37 +00:00
|
|
|
|
2019-06-13 09:36:07 +00:00
|
|
|
template <typename T>
|
|
|
|
void doUpdateOutputs();
|
|
|
|
|
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;
|
2017-09-22 18:35:50 +00:00
|
|
|
std::unique_ptr<SyncFilter> m_syncFilter;
|
2016-08-16 13:31:14 +00:00
|
|
|
|
2019-06-13 09:36:07 +00:00
|
|
|
QVector<X11Output*> m_outputs;
|
2016-04-08 07:51:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|