Toggling compositing is specific only to X11 so move the corresponding shortcut to the X11 compositor implementation.
204 lines
5.5 KiB
C++
204 lines
5.5 KiB
C++
/*
|
|
KWin - the KDE window manager
|
|
This file is part of the KDE project.
|
|
|
|
SPDX-FileCopyrightText: 2011 Arthur Arlt <a.arlt@stud.uni-heidelberg.de>
|
|
SPDX-FileCopyrightText: 2012 Martin Gräßlin <mgraesslin@kde.org>
|
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
*/
|
|
#pragma once
|
|
|
|
#include "libkwineffects/kwinglobals.h"
|
|
#include <xcb/xcb.h>
|
|
|
|
#include <QObject>
|
|
#include <QRegion>
|
|
#include <QTimer>
|
|
#include <memory>
|
|
|
|
namespace KWin
|
|
{
|
|
|
|
class Output;
|
|
class CompositorSelectionOwner;
|
|
class CursorScene;
|
|
class RenderBackend;
|
|
class RenderLayer;
|
|
class RenderLoop;
|
|
class RenderTarget;
|
|
class WorkspaceScene;
|
|
class Window;
|
|
|
|
class KWIN_EXPORT Compositor : public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
enum class State {
|
|
On = 0,
|
|
Off,
|
|
Starting,
|
|
Stopping
|
|
};
|
|
|
|
~Compositor() override;
|
|
static Compositor *self();
|
|
|
|
/**
|
|
* Re-initializes the Compositor completely.
|
|
* Connected to the D-Bus signal org.kde.KWin /KWin reinitCompositing
|
|
*/
|
|
virtual void reinitialize();
|
|
|
|
/**
|
|
* Whether the Compositor is active. That is a Scene is present and the Compositor is
|
|
* not shutting down itself.
|
|
*/
|
|
bool isActive();
|
|
|
|
WorkspaceScene *scene() const
|
|
{
|
|
return m_scene.get();
|
|
}
|
|
CursorScene *cursorScene() const
|
|
{
|
|
return m_cursorScene.get();
|
|
}
|
|
RenderBackend *backend() const
|
|
{
|
|
return m_backend.get();
|
|
}
|
|
|
|
/**
|
|
* @brief Static check to test whether the Compositor is available and active.
|
|
*
|
|
* @return bool @c true if there is a Compositor and it is active, @c false otherwise
|
|
*/
|
|
static bool compositing()
|
|
{
|
|
return s_compositor != nullptr && s_compositor->isActive();
|
|
}
|
|
|
|
// for delayed supportproperty management of effects
|
|
void keepSupportProperty(xcb_atom_t atom);
|
|
void removeSupportProperty(xcb_atom_t atom);
|
|
|
|
/**
|
|
* Whether Compositing is possible in the Platform.
|
|
* Returning @c false in this method makes only sense if requiresCompositing returns @c false.
|
|
*
|
|
* The default implementation returns @c true.
|
|
* @see requiresCompositing
|
|
*/
|
|
virtual bool compositingPossible() const;
|
|
/**
|
|
* Returns a user facing text explaining why compositing is not possible in case
|
|
* compositingPossible returns @c false.
|
|
*
|
|
* The default implementation returns an empty string.
|
|
* @see compositingPossible
|
|
*/
|
|
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.
|
|
* @see createOpenGLSafePoint
|
|
*/
|
|
virtual bool openGLCompositingIsBroken() const;
|
|
enum class OpenGLSafePoint {
|
|
PreInit,
|
|
PostInit,
|
|
PreFrame,
|
|
PostFrame,
|
|
PostLastGuardedFrame
|
|
};
|
|
/**
|
|
* 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.
|
|
* This can be used for openGLCompositingIsBroken.
|
|
*
|
|
* The default implementation does nothing.
|
|
* @see openGLCompositingIsBroken.
|
|
*/
|
|
virtual void createOpenGLSafePoint(OpenGLSafePoint safePoint);
|
|
|
|
/**
|
|
* @returns the format of the contents in the @p output
|
|
*
|
|
* This format is provided using the drm fourcc encoding
|
|
*/
|
|
uint outputFormat(Output *output);
|
|
|
|
virtual void inhibit(Window *window);
|
|
virtual void uninhibit(Window *window);
|
|
|
|
Q_SIGNALS:
|
|
void compositingToggled(bool active);
|
|
void aboutToDestroy();
|
|
void aboutToToggleCompositing();
|
|
void sceneCreated();
|
|
|
|
protected:
|
|
explicit Compositor(QObject *parent = nullptr);
|
|
|
|
virtual void start() = 0;
|
|
virtual void stop();
|
|
|
|
/**
|
|
* @brief Prepares start.
|
|
* @return bool @c true if start should be continued and @c if not.
|
|
*/
|
|
bool setupStart();
|
|
/**
|
|
* Continues the startup after Scene And Workspace are created
|
|
*/
|
|
void startupWithWorkspace();
|
|
|
|
virtual void configChanged();
|
|
|
|
void destroyCompositorSelection();
|
|
|
|
static Compositor *s_compositor;
|
|
|
|
protected Q_SLOTS:
|
|
virtual void composite(RenderLoop *renderLoop);
|
|
|
|
private Q_SLOTS:
|
|
void handleFrameRequested(RenderLoop *renderLoop);
|
|
|
|
private:
|
|
void releaseCompositorSelection();
|
|
void deleteUnusedSupportProperties();
|
|
|
|
bool attemptOpenGLCompositing();
|
|
bool attemptQPainterCompositing();
|
|
|
|
Output *findOutput(RenderLoop *loop) const;
|
|
void addOutput(Output *output);
|
|
void removeOutput(Output *output);
|
|
|
|
void addSuperLayer(RenderLayer *layer);
|
|
void removeSuperLayer(RenderLayer *layer);
|
|
|
|
void prePaintPass(RenderLayer *layer);
|
|
void postPaintPass(RenderLayer *layer);
|
|
void preparePaintPass(RenderLayer *layer, QRegion *repaint);
|
|
void paintPass(RenderLayer *layer, const RenderTarget &renderTarget, const QRegion ®ion);
|
|
void framePass(RenderLayer *layer);
|
|
|
|
State m_state = State::Off;
|
|
std::unique_ptr<CompositorSelectionOwner> m_selectionOwner;
|
|
QTimer m_releaseSelectionTimer;
|
|
QList<xcb_atom_t> m_unusedSupportProperties;
|
|
QTimer m_unusedSupportPropertyTimer;
|
|
std::unique_ptr<WorkspaceScene> m_scene;
|
|
std::unique_ptr<CursorScene> m_cursorScene;
|
|
std::unique_ptr<RenderBackend> m_backend;
|
|
QHash<RenderLoop *, RenderLayer *> m_superlayers;
|
|
CompositingType m_selectedCompositor = NoCompositing;
|
|
};
|
|
|
|
} // namespace KWin
|