2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2015-03-20 13:41:03 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2015 Martin Gräßlin <mgraesslin@kde.org>
|
2015-03-20 13:41:03 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2016-04-07 07:24:17 +00:00
|
|
|
#ifndef KWIN_PLATFORM_H
|
|
|
|
#define KWIN_PLATFORM_H
|
2015-03-23 13:29:07 +00:00
|
|
|
#include <kwin_export.h>
|
2016-10-17 14:12:21 +00:00
|
|
|
#include <kwinglobals.h>
|
2015-08-18 06:35:34 +00:00
|
|
|
#include <epoxy/egl.h>
|
Send axis_source, axis_discrete, and axis_stop
Summary:
So far KWin didn't send axis_source, axis_discrete, and axis_stop. Even
though most of those events are optional, clients need them to work as
expected. For example, one needs axis_source and axis_stop to implement
kinetic scrolling; Xwayland needs axis_discrete to prevent multiple
scroll events when the compositor sends axis deltas greater than 10, etc.
BUG: 404152
FIXED-IN: 5.17.0
Test Plan:
* Content of a webpage in Firefox is moved by one line per each mouse
wheel "click";
* Scrolled gedit using 2 fingers on GNOME Shell, sway, and KDE Plasma;
in all three cases wayland debug looked the same (except diagonal scroll
motions).
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D19000
2019-02-12 09:14:51 +00:00
|
|
|
#include "input.h"
|
2018-03-06 03:55:13 +00:00
|
|
|
|
2015-04-01 13:36:40 +00:00
|
|
|
#include <QImage>
|
2015-03-20 13:41:03 +00:00
|
|
|
#include <QObject>
|
|
|
|
|
2016-11-15 09:22:56 +00:00
|
|
|
#include <functional>
|
|
|
|
|
2017-01-17 06:12:44 +00:00
|
|
|
class QAction;
|
|
|
|
|
2020-04-29 15:18:41 +00:00
|
|
|
namespace KWaylandServer {
|
2021-07-21 10:11:21 +00:00
|
|
|
class OutputConfigurationV2Interface;
|
2016-03-10 18:57:07 +00:00
|
|
|
}
|
|
|
|
|
2015-03-20 13:41:03 +00:00
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2018-03-28 23:27:21 +00:00
|
|
|
class AbstractOutput;
|
2016-04-15 11:47:56 +00:00
|
|
|
class Edge;
|
2017-09-23 18:21:26 +00:00
|
|
|
class Compositor;
|
2020-07-22 17:29:23 +00:00
|
|
|
class DmaBufTexture;
|
2021-10-02 08:26:51 +00:00
|
|
|
class InputBackend;
|
2017-08-07 15:54:56 +00:00
|
|
|
class OverlayWindow;
|
2015-03-27 07:51:56 +00:00
|
|
|
class OpenGLBackend;
|
2017-08-21 09:59:52 +00:00
|
|
|
class Outline;
|
|
|
|
class OutlineVisual;
|
2015-03-27 08:05:03 +00:00
|
|
|
class QPainterBackend;
|
Introduce RenderLoop
At the moment, our frame scheduling infrastructure is still heavily
based on Xinerama-style rendering. Specifically, we assume that painting
is driven by a single timer, etc.
This change introduces a new type - RenderLoop. Its main purpose is to
drive compositing on a specific output, or in case of X11, on the
overlay window.
With RenderLoop, compositing is synchronized to vblank events. It
exposes the last and the next estimated presentation timestamp. The
expected presentation timestamp can be used by effects to ensure that
animations are synchronized with the upcoming vblank event.
On Wayland, every outputs has its own render loop. On X11, per screen
rendering is not possible, therefore the platform exposes the render
loop for the overlay window. Ideally, the Scene has to expose the
RenderLoop, but as the first step towards better compositing scheduling
it's good as is for the time being.
The RenderLoop tries to minimize the latency by delaying compositing as
close as possible to the next vblank event. One tricky thing about it is
that if compositing is too close to the next vblank event, animations
may become a little bit choppy. However, increasing the latency reduces
the choppiness.
Given that, there is no any "silver bullet" solution for the choppiness
issue, a new option has been added in the Compositing KCM to specify the
amount of latency. By default, it's "Medium," but if a user is not
satisfied with the upstream default, they can tweak it.
2020-11-19 08:52:29 +00:00
|
|
|
class RenderLoop;
|
2017-09-23 18:21:26 +00:00
|
|
|
class Scene;
|
2016-04-15 11:47:56 +00:00
|
|
|
class ScreenEdges;
|
2021-01-30 13:22:07 +00:00
|
|
|
class Session;
|
2016-11-15 09:22:56 +00:00
|
|
|
class Toplevel;
|
2015-04-02 12:37:23 +00:00
|
|
|
|
2018-03-28 23:27:21 +00:00
|
|
|
class KWIN_EXPORT Outputs : public QVector<AbstractOutput*>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Outputs(){};
|
|
|
|
template <typename T>
|
|
|
|
Outputs(const QVector<T> &other) {
|
|
|
|
resize(other.size());
|
|
|
|
std::copy(other.constBegin(), other.constEnd(), begin());
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-04-07 07:18:10 +00:00
|
|
|
class KWIN_EXPORT Platform : public QObject
|
2015-03-20 13:41:03 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
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
|
|
|
~Platform() override;
|
2015-03-20 13:41:03 +00:00
|
|
|
|
2021-01-30 13:22:07 +00:00
|
|
|
virtual Session *session() const = 0;
|
|
|
|
virtual bool initialize() = 0;
|
2021-10-02 08:26:51 +00:00
|
|
|
virtual InputBackend *createInputBackend();
|
2015-03-27 07:51:56 +00:00
|
|
|
virtual OpenGLBackend *createOpenGLBackend();
|
2015-03-27 08:05:03 +00:00
|
|
|
virtual QPainterBackend *createQPainterBackend();
|
2020-07-22 17:29:23 +00:00
|
|
|
virtual DmaBufTexture *createDmaBufTexture(const QSize &size) {
|
|
|
|
Q_UNUSED(size);
|
|
|
|
return nullptr;
|
|
|
|
}
|
2019-09-05 14:59:53 +00:00
|
|
|
|
2016-04-15 11:47:56 +00:00
|
|
|
/**
|
|
|
|
* Allows the platform to create a platform specific screen edge.
|
|
|
|
* The default implementation creates a Edge.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-04-15 11:47:56 +00:00
|
|
|
virtual Edge *createScreenEdge(ScreenEdges *parent);
|
2016-08-15 10:00:03 +00:00
|
|
|
/**
|
|
|
|
* Allows the platform to create a platform specific Cursor.
|
|
|
|
* The default implementation creates an InputRedirectionCursor.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-08-15 10:00:03 +00:00
|
|
|
virtual void createPlatformCursor(QObject *parent = nullptr);
|
2015-06-05 17:34:03 +00:00
|
|
|
virtual void warpPointer(const QPointF &globalPos);
|
2020-10-15 09:27:00 +00:00
|
|
|
/**
|
|
|
|
* Whether our Compositing EGL display supports creating native EGL fences.
|
|
|
|
*/
|
|
|
|
bool supportsNativeFence() const;
|
2015-08-18 06:35:34 +00:00
|
|
|
/**
|
|
|
|
* The EGLDisplay used by the compositing scene.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-07-18 08:27:56 +00:00
|
|
|
EGLDisplay sceneEglDisplay() const;
|
|
|
|
void setSceneEglDisplay(EGLDisplay display);
|
2020-10-16 14:57:35 +00:00
|
|
|
/**
|
|
|
|
* Returns the compositor-wide shared EGL context. This function may return EGL_NO_CONTEXT
|
|
|
|
* if the underlying rendering backend does not use EGL.
|
|
|
|
*
|
|
|
|
* Note that the returned context should never be made current. Instead, create a context
|
|
|
|
* that shares with this one and make the new context current.
|
|
|
|
*/
|
|
|
|
EGLContext sceneEglGlobalShareContext() const;
|
|
|
|
/**
|
|
|
|
* Sets the global share context to @a context. This function is intended to be called only
|
|
|
|
* by rendering backends.
|
|
|
|
*/
|
|
|
|
void setSceneEglGlobalShareContext(EGLContext context);
|
2016-07-18 09:17:54 +00:00
|
|
|
|
2015-11-17 09:32:06 +00:00
|
|
|
/**
|
|
|
|
* Implementing subclasses should provide a size in case the backend represents
|
|
|
|
* a basic screen and uses the BasicScreens.
|
|
|
|
*
|
|
|
|
* Base implementation returns an invalid size.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2015-11-17 09:32:06 +00:00
|
|
|
virtual QSize screenSize() const;
|
2016-03-10 18:57:07 +00:00
|
|
|
/**
|
|
|
|
* Implement this method to receive configuration change requests through KWayland's
|
|
|
|
* OutputManagement interface.
|
|
|
|
*
|
|
|
|
* Base implementation warns that the current backend does not implement this
|
|
|
|
* functionality.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2021-07-21 10:11:21 +00:00
|
|
|
void requestOutputsChange(KWaylandServer::OutputConfigurationV2Interface *config);
|
2015-11-17 09:32:06 +00:00
|
|
|
|
2016-05-09 14:41:37 +00:00
|
|
|
/**
|
|
|
|
* Whether the Platform requires compositing for rendering.
|
|
|
|
* Default implementation returns @c true. If the implementing Platform allows to be used
|
|
|
|
* without compositing (e.g. rendering is done by the windowing system), re-implement this method.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-05-09 14:41:37 +00:00
|
|
|
virtual bool requiresCompositing() const;
|
2016-05-09 15:32:43 +00:00
|
|
|
/**
|
|
|
|
* Whether Compositing is possible in the Platform.
|
2019-01-12 10:31:32 +00:00
|
|
|
* Returning @c false in this method makes only sense if requiresCompositing returns @c false.
|
2016-05-09 15:32:43 +00:00
|
|
|
*
|
|
|
|
* The default implementation returns @c true.
|
|
|
|
* @see requiresCompositing
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-05-09 15:32:43 +00:00
|
|
|
virtual bool compositingPossible() const;
|
|
|
|
/**
|
|
|
|
* Returns a user facing text explaining why compositing is not possible in case
|
2019-01-12 10:31:32 +00:00
|
|
|
* compositingPossible returns @c false.
|
2016-05-09 15:32:43 +00:00
|
|
|
*
|
|
|
|
* The default implementation returns an empty string.
|
|
|
|
* @see compositingPossible
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-05-09 15:32:43 +00:00
|
|
|
virtual QString compositingNotPossibleReason() const;
|
|
|
|
/**
|
|
|
|
* Whether OpenGL compositing is broken.
|
|
|
|
* The Platform can implement this method if it is able to detect whether OpenGL compositing
|
|
|
|
* broke (e.g. triggered a crash in a previous run).
|
|
|
|
*
|
|
|
|
* Default implementation returns @c false.
|
2016-05-10 08:34:09 +00:00
|
|
|
* @see createOpenGLSafePoint
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-05-09 15:32:43 +00:00
|
|
|
virtual bool openGLCompositingIsBroken() const;
|
2016-05-10 08:34:09 +00:00
|
|
|
enum class OpenGLSafePoint {
|
|
|
|
PreInit,
|
[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
|
|
|
PostInit,
|
|
|
|
PreFrame,
|
|
|
|
PostFrame,
|
|
|
|
PostLastGuardedFrame
|
2016-05-10 08:34:09 +00:00
|
|
|
};
|
|
|
|
/**
|
|
|
|
* This method is invoked before and after creating the OpenGL rendering Scene.
|
|
|
|
* An implementing Platform can use it to detect crashes triggered by the OpenGL implementation.
|
2019-01-12 10:31:32 +00:00
|
|
|
* This can be used for openGLCompositingIsBroken.
|
2016-05-10 08:34:09 +00:00
|
|
|
*
|
|
|
|
* The default implementation does nothing.
|
|
|
|
* @see openGLCompositingIsBroken.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-05-10 08:34:09 +00:00
|
|
|
virtual void createOpenGLSafePoint(OpenGLSafePoint safePoint);
|
2016-05-09 14:41:37 +00:00
|
|
|
|
2016-11-15 09:22:56 +00:00
|
|
|
/**
|
|
|
|
* Starts an interactive window selection process.
|
|
|
|
*
|
|
|
|
* Once the user selected a window the @p callback is invoked with the selected Toplevel as
|
|
|
|
* argument. In case the user cancels the interactive window selection or selecting a window is currently
|
|
|
|
* not possible (e.g. screen locked) the @p callback is invoked with a @c nullptr argument.
|
|
|
|
*
|
|
|
|
* During the interactive window selection the cursor is turned into a crosshair cursor unless
|
|
|
|
* @p cursorName is provided. The argument @p cursorName is a QByteArray instead of Qt::CursorShape
|
|
|
|
* to support the "pirate" cursor for kill window which is not wrapped by Qt::CursorShape.
|
|
|
|
*
|
2016-11-15 13:23:51 +00:00
|
|
|
* The default implementation forwards to InputRedirection.
|
2016-11-15 09:22:56 +00:00
|
|
|
*
|
|
|
|
* @param callback The function to invoke once the interactive window selection ends
|
|
|
|
* @param cursorName The optional name of the cursor shape to use, default is crosshair
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-11-15 09:22:56 +00:00
|
|
|
virtual void startInteractiveWindowSelection(std::function<void(KWin::Toplevel*)> callback, const QByteArray &cursorName = QByteArray());
|
|
|
|
|
2016-11-23 14:53:17 +00:00
|
|
|
/**
|
|
|
|
* Starts an interactive position selection process.
|
|
|
|
*
|
|
|
|
* Once the user selected a position on the screen the @p callback is invoked with
|
|
|
|
* the selected point as argument. In case the user cancels the interactive position selection
|
|
|
|
* or selecting a position is currently not possible (e.g. screen locked) the @p callback
|
|
|
|
* is invoked with a point at @c -1 as x and y argument.
|
|
|
|
*
|
|
|
|
* During the interactive window selection the cursor is turned into a crosshair cursor.
|
|
|
|
*
|
|
|
|
* The default implementation forwards to InputRedirection.
|
|
|
|
*
|
|
|
|
* @param callback The function to invoke once the interactive position selection ends
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-11-23 14:53:17 +00:00
|
|
|
virtual void startInteractivePositionSelection(std::function<void(const QPoint &)> callback);
|
|
|
|
|
2017-01-17 06:12:44 +00:00
|
|
|
/**
|
|
|
|
* Platform specific preparation for an @p action which is used for KGlobalAccel.
|
|
|
|
*
|
|
|
|
* A platform might need to do preparation for an @p action before
|
|
|
|
* it can be used with KGlobalAccel.
|
|
|
|
*
|
|
|
|
* Code using KGlobalAccel should invoke this method for the @p action
|
|
|
|
* prior to setting up any shortcuts and connections.
|
|
|
|
*
|
|
|
|
* The default implementation does nothing.
|
|
|
|
*
|
|
|
|
* @param action The action which will be used with KGlobalAccel.
|
|
|
|
* @since 5.10
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2017-01-17 06:12:44 +00:00
|
|
|
virtual void setupActionForGlobalAccel(QAction *action);
|
|
|
|
|
2020-10-28 06:40:06 +00:00
|
|
|
/**
|
|
|
|
* Returns @c true if the software cursor is being used; otherwise returns @c false.
|
|
|
|
*/
|
|
|
|
bool usesSoftwareCursor() const;
|
2015-04-01 13:36:40 +00:00
|
|
|
|
2020-10-28 07:03:09 +00:00
|
|
|
/**
|
|
|
|
* Returns @c true if the software cursor is being forced; otherwise returns @c false.
|
|
|
|
*
|
|
|
|
* Note that the value returned by this function not always matches usesSoftwareCursor().
|
|
|
|
* If this function returns @c true, then it is guaranteed that the compositor will
|
|
|
|
* use the software cursor. However, this doesn't apply vice versa.
|
|
|
|
*
|
|
|
|
* If the compositor uses a software cursor, this function may return @c false. This
|
|
|
|
* is typically the case if the current cursor image can't be displayed using hardware
|
|
|
|
* cursors, for example due to buffer size limitations, etc.
|
|
|
|
*
|
|
|
|
* @see usesSoftwareCursor()
|
|
|
|
*/
|
|
|
|
bool isSoftwareCursorForced() const;
|
|
|
|
|
2016-10-17 14:12:21 +00:00
|
|
|
/**
|
|
|
|
* Returns a PlatformCursorImage. By default this is created by softwareCursor and
|
|
|
|
* softwareCursorHotspot. An implementing subclass can use this to provide a better
|
|
|
|
* suited PlatformCursorImage.
|
|
|
|
*
|
|
|
|
* @see softwareCursor
|
|
|
|
* @see softwareCursorHotspot
|
|
|
|
* @since 5.9
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-10-17 14:12:21 +00:00
|
|
|
virtual PlatformCursorImage cursorImage() const;
|
|
|
|
|
2016-10-20 08:21:54 +00:00
|
|
|
/**
|
|
|
|
* The Platform cursor image should be hidden.
|
|
|
|
* @see showCursor
|
|
|
|
* @see doHideCursor
|
|
|
|
* @see isCursorHidden
|
|
|
|
* @since 5.9
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-10-20 08:21:54 +00:00
|
|
|
void hideCursor();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The Platform cursor image should be shown again.
|
|
|
|
* @see hideCursor
|
|
|
|
* @see doShowCursor
|
|
|
|
* @see isCursorHidden
|
|
|
|
* @since 5.9
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-10-20 08:21:54 +00:00
|
|
|
void showCursor();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether the cursor is currently hidden.
|
|
|
|
* @see showCursor
|
|
|
|
* @see hideCursor
|
|
|
|
* @since 5.9
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-10-20 08:21:54 +00:00
|
|
|
bool isCursorHidden() const {
|
|
|
|
return m_hideCursorCounter > 0;
|
|
|
|
}
|
2015-05-05 17:02:52 +00:00
|
|
|
bool isReady() const {
|
|
|
|
return m_ready;
|
|
|
|
}
|
2015-05-06 07:26:08 +00:00
|
|
|
void setInitialWindowSize(const QSize &size) {
|
|
|
|
m_initialWindowSize = size;
|
|
|
|
}
|
2015-05-06 07:37:25 +00:00
|
|
|
void setDeviceIdentifier(const QByteArray &identifier) {
|
|
|
|
m_deviceIdentifier = identifier;
|
|
|
|
}
|
2015-06-05 17:34:03 +00:00
|
|
|
bool supportsPointerWarping() const {
|
|
|
|
return m_pointerWarping;
|
|
|
|
}
|
2015-11-24 12:11:29 +00:00
|
|
|
int initialOutputCount() const {
|
|
|
|
return m_initialOutputCount;
|
|
|
|
}
|
|
|
|
void setInitialOutputCount(int count) {
|
|
|
|
m_initialOutputCount = count;
|
|
|
|
}
|
2016-10-25 23:36:02 +00:00
|
|
|
qreal initialOutputScale() const {
|
|
|
|
return m_initialOutputScale;
|
|
|
|
}
|
|
|
|
void setInitialOutputScale(qreal scale) {
|
|
|
|
m_initialOutputScale = scale;
|
|
|
|
}
|
2015-04-24 10:00:19 +00:00
|
|
|
|
2017-08-07 15:54:56 +00:00
|
|
|
/**
|
|
|
|
* Creates the OverlayWindow required for X11 based compositors.
|
|
|
|
* Default implementation returns @c nullptr.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2017-08-07 15:54:56 +00:00
|
|
|
virtual OverlayWindow *createOverlayWindow();
|
|
|
|
|
2017-08-24 14:53:40 +00:00
|
|
|
/**
|
2020-04-27 10:49:36 +00:00
|
|
|
* Queries the current X11 time stamp of the X server.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2020-04-27 10:49:36 +00:00
|
|
|
void updateXTime();
|
2017-08-24 14:53:40 +00:00
|
|
|
|
2017-08-21 09:59:52 +00:00
|
|
|
/**
|
|
|
|
* Creates the OutlineVisual for the given @p outline.
|
|
|
|
* Default implementation creates an OutlineVisual suited for composited usage.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2017-08-21 09:59:52 +00:00
|
|
|
virtual OutlineVisual *createOutline(Outline *outline);
|
|
|
|
|
2017-08-21 06:53:56 +00:00
|
|
|
/**
|
|
|
|
* Platform specific way to invert the screen.
|
|
|
|
* Default implementation invokes the invert effect
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2017-08-21 06:53:56 +00:00
|
|
|
virtual void invertScreen();
|
|
|
|
|
2017-09-23 18:21:26 +00:00
|
|
|
/**
|
|
|
|
* Default implementation creates an EffectsHandlerImp;
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2017-09-23 18:21:26 +00:00
|
|
|
virtual void createEffectsHandler(Compositor *compositor, Scene *scene);
|
2019-09-05 14:59:53 +00:00
|
|
|
|
2017-10-15 20:24:49 +00:00
|
|
|
/**
|
|
|
|
* The CompositingTypes supported by the Platform.
|
|
|
|
* The first item should be the most preferred one.
|
|
|
|
* @since 5.11
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2017-10-15 20:24:49 +00:00
|
|
|
virtual QVector<CompositingType> supportedCompositors() const = 0;
|
2017-09-23 18:21:26 +00:00
|
|
|
|
[colorcorrection] Night Color - blue light filter at nighttime
With Wayland KWin needs to provide certain services, which were provided
before that by the Xserver. One of these is gamma correction, which includes
the - by many people beloved - functionality to reduce the blue light at
nighttime. This patch provides the KWin part of that. It is self contained,
but in the end will work in tandem with a lib in Plasma Workspace and a KCM
in Plasma Desktop, which can be used to configure Night Color.
* Three modi:
** Automatic: The location and sun timings are determined automatically
(location data updates will be provided by the workspace)
** Location: The sun timings are determined by fixed location data
** Timings: The sun timings are set manually by the user
* Color temperature value changes are smoothly applied:
** Configuration changes, which lead to other current values are changed
in a quick way over a few seconds
** Changes on sunrise and sunset are applied slowly over the course of few
minutes till several hours depending on the configuration
* The current color value is set immediately at startup or after suspend
phases and VT switches. There is no flickering.
* All configuration is done via a DBus interface, changed values are tested
on correctness and applied atomically
* Self contained mechanism, speaks directly to the hardware by setting the
gamma ramps on the CRTC
* Currently working on DRM backend, extensible to other platform backends in
the future
* The code is written in a way to make the classes later easily extendable to
also provide normal color correction, as it's currently done by KGamma on X
Test Plan:
Manually with the workspace parts and added integration tests in KWin using
the virtual backend.
BUG:371494
Reviewers: #kwin, graesslin
Subscribers: kwin, plasma-devel, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D5928
2017-12-11 09:43:12 +00:00
|
|
|
/**
|
|
|
|
* Whether gamma control is supported by the backend.
|
|
|
|
* @since 5.12
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
[colorcorrection] Night Color - blue light filter at nighttime
With Wayland KWin needs to provide certain services, which were provided
before that by the Xserver. One of these is gamma correction, which includes
the - by many people beloved - functionality to reduce the blue light at
nighttime. This patch provides the KWin part of that. It is self contained,
but in the end will work in tandem with a lib in Plasma Workspace and a KCM
in Plasma Desktop, which can be used to configure Night Color.
* Three modi:
** Automatic: The location and sun timings are determined automatically
(location data updates will be provided by the workspace)
** Location: The sun timings are determined by fixed location data
** Timings: The sun timings are set manually by the user
* Color temperature value changes are smoothly applied:
** Configuration changes, which lead to other current values are changed
in a quick way over a few seconds
** Changes on sunrise and sunset are applied slowly over the course of few
minutes till several hours depending on the configuration
* The current color value is set immediately at startup or after suspend
phases and VT switches. There is no flickering.
* All configuration is done via a DBus interface, changed values are tested
on correctness and applied atomically
* Self contained mechanism, speaks directly to the hardware by setting the
gamma ramps on the CRTC
* Currently working on DRM backend, extensible to other platform backends in
the future
* The code is written in a way to make the classes later easily extendable to
also provide normal color correction, as it's currently done by KGamma on X
Test Plan:
Manually with the workspace parts and added integration tests in KWin using
the virtual backend.
BUG:371494
Reviewers: #kwin, graesslin
Subscribers: kwin, plasma-devel, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D5928
2017-12-11 09:43:12 +00:00
|
|
|
bool supportsGammaControl() const {
|
|
|
|
return m_supportsGammaControl;
|
|
|
|
}
|
|
|
|
|
2018-03-28 23:27:21 +00:00
|
|
|
// outputs with connections (org_kde_kwin_outputdevice)
|
|
|
|
virtual Outputs outputs() const {
|
|
|
|
return Outputs();
|
|
|
|
}
|
|
|
|
// actively compositing outputs (wl_output)
|
|
|
|
virtual Outputs enabledOutputs() const {
|
|
|
|
return Outputs();
|
|
|
|
}
|
2021-04-09 06:21:59 +00:00
|
|
|
AbstractOutput *findOutput(int screenId) const;
|
|
|
|
AbstractOutput *findOutput(const QUuid &uuid) const;
|
2021-08-27 15:49:54 +00:00
|
|
|
AbstractOutput *outputAt(const QPoint &pos) const;
|
2019-08-28 18:54:37 +00:00
|
|
|
|
2019-02-02 18:17:44 +00:00
|
|
|
/**
|
2017-11-07 19:12:51 +00:00
|
|
|
* A string of information to include in kwin debug output
|
|
|
|
* It should not be translated.
|
|
|
|
*
|
|
|
|
* The base implementation prints the name.
|
|
|
|
* @since 5.12
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2017-11-07 19:12:51 +00:00
|
|
|
virtual QString supportInformation() const;
|
|
|
|
|
2019-02-16 19:50:46 +00:00
|
|
|
/**
|
2019-12-25 09:37:17 +00:00
|
|
|
* The compositor plugin which got selected from @ref supportedCompositors.
|
2019-02-16 19:50:46 +00:00
|
|
|
* Prior to selecting a compositor this returns @c NoCompositing.
|
|
|
|
*
|
2019-12-25 09:37:17 +00:00
|
|
|
* This method allows the platforms to limit the offerings in @ref supportedCompositors
|
2019-02-16 19:50:46 +00:00
|
|
|
* in case they do not support runtime compositor switching
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-02-16 19:50:46 +00:00
|
|
|
CompositingType selectedCompositor() const
|
|
|
|
{
|
|
|
|
return m_selectedCompositor;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Used by Compositor to set the used compositor.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-02-16 19:50:46 +00:00
|
|
|
void setSelectedCompositor(CompositingType type)
|
|
|
|
{
|
|
|
|
m_selectedCompositor = type;
|
|
|
|
}
|
|
|
|
|
2020-11-09 12:19:15 +00:00
|
|
|
/**
|
|
|
|
* Returns @c true if rendering is split per screen; otherwise returns @c false.
|
|
|
|
*/
|
|
|
|
bool isPerScreenRenderingEnabled() const;
|
|
|
|
|
Introduce RenderLoop
At the moment, our frame scheduling infrastructure is still heavily
based on Xinerama-style rendering. Specifically, we assume that painting
is driven by a single timer, etc.
This change introduces a new type - RenderLoop. Its main purpose is to
drive compositing on a specific output, or in case of X11, on the
overlay window.
With RenderLoop, compositing is synchronized to vblank events. It
exposes the last and the next estimated presentation timestamp. The
expected presentation timestamp can be used by effects to ensure that
animations are synchronized with the upcoming vblank event.
On Wayland, every outputs has its own render loop. On X11, per screen
rendering is not possible, therefore the platform exposes the render
loop for the overlay window. Ideally, the Scene has to expose the
RenderLoop, but as the first step towards better compositing scheduling
it's good as is for the time being.
The RenderLoop tries to minimize the latency by delaying compositing as
close as possible to the next vblank event. One tricky thing about it is
that if compositing is too close to the next vblank event, animations
may become a little bit choppy. However, increasing the latency reduces
the choppiness.
Given that, there is no any "silver bullet" solution for the choppiness
issue, a new option has been added in the Compositing KCM to specify the
amount of latency. By default, it's "Medium," but if a user is not
satisfied with the upstream default, they can tweak it.
2020-11-19 08:52:29 +00:00
|
|
|
/**
|
|
|
|
* If the Platform doesn't support per screen rendering, this function returns the
|
|
|
|
* RenderLoop that drives compositing.
|
|
|
|
*/
|
|
|
|
virtual RenderLoop *renderLoop() const;
|
|
|
|
|
2021-10-05 17:06:28 +00:00
|
|
|
virtual AbstractOutput *createVirtualOutput(const QString &name, const QSize &size, qreal scaling);
|
|
|
|
virtual void removeVirtualOutput(AbstractOutput *output);
|
|
|
|
|
2015-05-11 13:43:30 +00:00
|
|
|
public Q_SLOTS:
|
2015-05-05 08:44:46 +00:00
|
|
|
void pointerMotion(const QPointF &position, quint32 time);
|
|
|
|
void pointerButtonPressed(quint32 button, quint32 time);
|
|
|
|
void pointerButtonReleased(quint32 button, quint32 time);
|
Send axis_source, axis_discrete, and axis_stop
Summary:
So far KWin didn't send axis_source, axis_discrete, and axis_stop. Even
though most of those events are optional, clients need them to work as
expected. For example, one needs axis_source and axis_stop to implement
kinetic scrolling; Xwayland needs axis_discrete to prevent multiple
scroll events when the compositor sends axis deltas greater than 10, etc.
BUG: 404152
FIXED-IN: 5.17.0
Test Plan:
* Content of a webpage in Firefox is moved by one line per each mouse
wheel "click";
* Scrolled gedit using 2 fingers on GNOME Shell, sway, and KDE Plasma;
in all three cases wayland debug looked the same (except diagonal scroll
motions).
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D19000
2019-02-12 09:14:51 +00:00
|
|
|
void pointerAxisHorizontal(qreal delta, quint32 time, qint32 discreteDelta = 0,
|
|
|
|
InputRedirection::PointerAxisSource source = InputRedirection::PointerAxisSourceUnknown);
|
|
|
|
void pointerAxisVertical(qreal delta, quint32 time, qint32 discreteDelta = 0,
|
|
|
|
InputRedirection::PointerAxisSource source = InputRedirection::PointerAxisSourceUnknown);
|
2015-05-05 08:44:46 +00:00
|
|
|
void keyboardKeyPressed(quint32 key, quint32 time);
|
|
|
|
void keyboardKeyReleased(quint32 key, quint32 time);
|
|
|
|
void keyboardModifiers(uint32_t modsDepressed, uint32_t modsLatched, uint32_t modsLocked, uint32_t group);
|
|
|
|
void keymapChange(int fd, uint32_t size);
|
|
|
|
void touchDown(qint32 id, const QPointF &pos, quint32 time);
|
|
|
|
void touchUp(qint32 id, quint32 time);
|
|
|
|
void touchMotion(qint32 id, const QPointF &pos, quint32 time);
|
2021-01-17 22:18:08 +00:00
|
|
|
void cancelTouchSequence();
|
2015-05-05 08:44:46 +00:00
|
|
|
void touchCancel();
|
|
|
|
void touchFrame();
|
|
|
|
|
2017-03-15 16:56:08 +00:00
|
|
|
void processSwipeGestureBegin(int fingerCount, quint32 time);
|
|
|
|
void processSwipeGestureUpdate(const QSizeF &delta, quint32 time);
|
|
|
|
void processSwipeGestureEnd(quint32 time);
|
|
|
|
void processSwipeGestureCancelled(quint32 time);
|
|
|
|
void processPinchGestureBegin(int fingerCount, quint32 time);
|
|
|
|
void processPinchGestureUpdate(qreal scale, qreal angleDelta, const QSizeF &delta, quint32 time);
|
|
|
|
void processPinchGestureEnd(quint32 time);
|
|
|
|
void processPinchGestureCancelled(quint32 time);
|
|
|
|
|
2020-04-02 16:18:01 +00:00
|
|
|
void cursorRendered(const QRect &geometry);
|
2021-05-18 23:05:41 +00:00
|
|
|
virtual void sceneInitialized() {};
|
2020-04-02 16:18:01 +00:00
|
|
|
|
2015-04-13 14:25:34 +00:00
|
|
|
Q_SIGNALS:
|
2015-05-06 07:03:54 +00:00
|
|
|
void screensQueried();
|
2015-05-05 17:02:52 +00:00
|
|
|
void readyChanged(bool);
|
2020-12-09 14:33:58 +00:00
|
|
|
/**
|
|
|
|
* This signal is emitted when an output has been connected. The @a output is not ready
|
|
|
|
* for compositing yet.
|
|
|
|
*/
|
2020-11-07 18:27:38 +00:00
|
|
|
void outputAdded(AbstractOutput *output);
|
2020-12-09 14:33:58 +00:00
|
|
|
/**
|
|
|
|
* This signal is emitted when an output has been disconnected.
|
|
|
|
*/
|
2020-11-07 18:27:38 +00:00
|
|
|
void outputRemoved(AbstractOutput *output);
|
2020-12-09 14:01:29 +00:00
|
|
|
/**
|
|
|
|
* This signal is emitted when the @a output has become activated and it is ready for
|
|
|
|
* compositing.
|
|
|
|
*/
|
|
|
|
void outputEnabled(AbstractOutput *output);
|
|
|
|
/**
|
|
|
|
* This signal is emitted when the @a output has been deactivated and it is no longer
|
|
|
|
* being composited. The outputDisabled() signal is guaranteed to be emitted before the
|
|
|
|
* output is removed.
|
|
|
|
*
|
|
|
|
* @see outputEnabled, outputRemoved
|
|
|
|
*/
|
|
|
|
void outputDisabled(AbstractOutput *output);
|
2015-04-13 14:25:34 +00:00
|
|
|
|
2015-03-20 13:41:03 +00:00
|
|
|
protected:
|
2016-04-07 07:18:10 +00:00
|
|
|
explicit Platform(QObject *parent = nullptr);
|
2020-10-28 06:40:06 +00:00
|
|
|
void setSoftwareCursor(bool set);
|
2020-10-28 07:03:09 +00:00
|
|
|
void setSoftwareCursorForced(bool forced);
|
2015-05-05 08:54:13 +00:00
|
|
|
void repaint(const QRect &rect);
|
2015-05-05 17:02:52 +00:00
|
|
|
void setReady(bool ready);
|
2020-11-09 12:19:15 +00:00
|
|
|
void setPerScreenRenderingEnabled(bool enabled);
|
2015-05-06 07:26:08 +00:00
|
|
|
QSize initialWindowSize() const {
|
|
|
|
return m_initialWindowSize;
|
|
|
|
}
|
2015-05-06 07:37:25 +00:00
|
|
|
QByteArray deviceIdentifier() const {
|
|
|
|
return m_deviceIdentifier;
|
|
|
|
}
|
2015-06-05 17:34:03 +00:00
|
|
|
void setSupportsPointerWarping(bool set) {
|
|
|
|
m_pointerWarping = set;
|
|
|
|
}
|
[colorcorrection] Night Color - blue light filter at nighttime
With Wayland KWin needs to provide certain services, which were provided
before that by the Xserver. One of these is gamma correction, which includes
the - by many people beloved - functionality to reduce the blue light at
nighttime. This patch provides the KWin part of that. It is self contained,
but in the end will work in tandem with a lib in Plasma Workspace and a KCM
in Plasma Desktop, which can be used to configure Night Color.
* Three modi:
** Automatic: The location and sun timings are determined automatically
(location data updates will be provided by the workspace)
** Location: The sun timings are determined by fixed location data
** Timings: The sun timings are set manually by the user
* Color temperature value changes are smoothly applied:
** Configuration changes, which lead to other current values are changed
in a quick way over a few seconds
** Changes on sunrise and sunset are applied slowly over the course of few
minutes till several hours depending on the configuration
* The current color value is set immediately at startup or after suspend
phases and VT switches. There is no flickering.
* All configuration is done via a DBus interface, changed values are tested
on correctness and applied atomically
* Self contained mechanism, speaks directly to the hardware by setting the
gamma ramps on the CRTC
* Currently working on DRM backend, extensible to other platform backends in
the future
* The code is written in a way to make the classes later easily extendable to
also provide normal color correction, as it's currently done by KGamma on X
Test Plan:
Manually with the workspace parts and added integration tests in KWin using
the virtual backend.
BUG:371494
Reviewers: #kwin, graesslin
Subscribers: kwin, plasma-devel, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D5928
2017-12-11 09:43:12 +00:00
|
|
|
void setSupportsGammaControl(bool set) {
|
|
|
|
m_supportsGammaControl = set;
|
|
|
|
}
|
2015-04-01 13:36:40 +00:00
|
|
|
|
2019-08-28 18:54:37 +00:00
|
|
|
/**
|
|
|
|
* Whether the backend is supposed to change the configuration of outputs.
|
|
|
|
*/
|
|
|
|
void supportsOutputChanges() {
|
|
|
|
m_supportsOutputChanges = true;
|
|
|
|
}
|
|
|
|
|
2016-10-20 08:21:54 +00:00
|
|
|
/**
|
|
|
|
* Actual platform specific way to hide the cursor.
|
|
|
|
* Sub-classes need to implement if they support hiding the cursor.
|
|
|
|
*
|
|
|
|
* This method is invoked by hideCursor if the cursor needs to be hidden.
|
|
|
|
* The default implementation does nothing.
|
|
|
|
*
|
|
|
|
* @see doShowCursor
|
|
|
|
* @see hideCursor
|
|
|
|
* @see showCursor
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-10-20 08:21:54 +00:00
|
|
|
virtual void doHideCursor();
|
|
|
|
/**
|
|
|
|
* Actual platform specific way to show the cursor.
|
|
|
|
* Sub-classes need to implement if they support showing the cursor.
|
|
|
|
*
|
|
|
|
* This method is invoked by showCursor if the cursor needs to be shown again.
|
|
|
|
*
|
|
|
|
* @see doShowCursor
|
|
|
|
* @see hideCursor
|
|
|
|
* @see showCursor
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-10-20 08:21:54 +00:00
|
|
|
virtual void doShowCursor();
|
2020-10-28 07:03:09 +00:00
|
|
|
virtual void doSetSoftwareCursor();
|
2016-10-20 08:21:54 +00:00
|
|
|
|
2015-04-01 13:36:40 +00:00
|
|
|
private:
|
|
|
|
void triggerCursorRepaint();
|
2020-10-28 06:40:06 +00:00
|
|
|
bool m_softwareCursor = false;
|
2020-10-28 07:03:09 +00:00
|
|
|
bool m_softwareCursorForced = false;
|
2015-04-01 13:36:40 +00:00
|
|
|
struct {
|
2016-06-28 06:33:47 +00:00
|
|
|
QRect lastRenderedGeometry;
|
2015-04-01 13:36:40 +00:00
|
|
|
} m_cursor;
|
2015-05-05 17:02:52 +00:00
|
|
|
bool m_ready = false;
|
2015-05-06 07:26:08 +00:00
|
|
|
QSize m_initialWindowSize;
|
2015-05-06 07:37:25 +00:00
|
|
|
QByteArray m_deviceIdentifier;
|
2015-06-05 17:34:03 +00:00
|
|
|
bool m_pointerWarping = false;
|
2015-11-24 12:11:29 +00:00
|
|
|
int m_initialOutputCount = 1;
|
2016-10-25 23:36:02 +00:00
|
|
|
qreal m_initialOutputScale = 1;
|
2016-07-18 08:27:56 +00:00
|
|
|
EGLDisplay m_eglDisplay;
|
2020-10-16 14:57:35 +00:00
|
|
|
EGLContext m_globalShareContext = EGL_NO_CONTEXT;
|
2016-10-20 08:21:54 +00:00
|
|
|
int m_hideCursorCounter = 0;
|
[colorcorrection] Night Color - blue light filter at nighttime
With Wayland KWin needs to provide certain services, which were provided
before that by the Xserver. One of these is gamma correction, which includes
the - by many people beloved - functionality to reduce the blue light at
nighttime. This patch provides the KWin part of that. It is self contained,
but in the end will work in tandem with a lib in Plasma Workspace and a KCM
in Plasma Desktop, which can be used to configure Night Color.
* Three modi:
** Automatic: The location and sun timings are determined automatically
(location data updates will be provided by the workspace)
** Location: The sun timings are determined by fixed location data
** Timings: The sun timings are set manually by the user
* Color temperature value changes are smoothly applied:
** Configuration changes, which lead to other current values are changed
in a quick way over a few seconds
** Changes on sunrise and sunset are applied slowly over the course of few
minutes till several hours depending on the configuration
* The current color value is set immediately at startup or after suspend
phases and VT switches. There is no flickering.
* All configuration is done via a DBus interface, changed values are tested
on correctness and applied atomically
* Self contained mechanism, speaks directly to the hardware by setting the
gamma ramps on the CRTC
* Currently working on DRM backend, extensible to other platform backends in
the future
* The code is written in a way to make the classes later easily extendable to
also provide normal color correction, as it's currently done by KGamma on X
Test Plan:
Manually with the workspace parts and added integration tests in KWin using
the virtual backend.
BUG:371494
Reviewers: #kwin, graesslin
Subscribers: kwin, plasma-devel, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D5928
2017-12-11 09:43:12 +00:00
|
|
|
bool m_supportsGammaControl = false;
|
2019-08-28 18:54:37 +00:00
|
|
|
bool m_supportsOutputChanges = false;
|
2020-11-09 12:19:15 +00:00
|
|
|
bool m_isPerScreenRenderingEnabled = false;
|
2019-02-16 19:50:46 +00:00
|
|
|
CompositingType m_selectedCompositor = NoCompositing;
|
2015-03-20 13:41:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-04-07 07:18:10 +00:00
|
|
|
Q_DECLARE_INTERFACE(KWin::Platform, "org.kde.kwin.Platform")
|
2015-05-05 15:58:09 +00:00
|
|
|
|
2015-03-20 13:41:03 +00:00
|
|
|
#endif
|