2020-03-15 15:19:28 +00:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
|
2020-10-31 14:03:30 +00:00
|
|
|
SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
2020-03-15 15:19:28 +00:00
|
|
|
|
|
|
|
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
|
|
|
*/
|
2020-10-31 14:03:30 +00:00
|
|
|
|
|
|
|
#pragma once
|
2014-10-14 12:04:35 +00:00
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
2020-04-29 14:56:38 +00:00
|
|
|
#include <KWaylandServer/kwaylandserver_export.h>
|
2014-10-14 12:04:35 +00:00
|
|
|
|
|
|
|
struct wl_resource;
|
|
|
|
|
2020-04-29 14:56:38 +00:00
|
|
|
namespace KWaylandServer
|
2014-10-14 12:04:35 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
class Display;
|
2020-10-31 14:03:30 +00:00
|
|
|
class SubCompositorInterfacePrivate;
|
2014-10-14 12:04:35 +00:00
|
|
|
class SurfaceInterface;
|
|
|
|
class SubSurfaceInterface;
|
2020-10-31 14:03:30 +00:00
|
|
|
class SubSurfaceInterfacePrivate;
|
2014-10-14 12:04:35 +00:00
|
|
|
|
2017-05-26 16:33:25 +00:00
|
|
|
/**
|
2020-10-31 14:03:30 +00:00
|
|
|
* The SubCompositorInterface compositor extension provides applications a way to offload
|
|
|
|
* compositing work within a window from clients to the compositor. This may reduce the power
|
|
|
|
* usage for applications such as video players, etc.
|
|
|
|
*
|
|
|
|
* The SubCompositorInterface corresponds to the Wayland interface @c wl_subcompositor.
|
2017-05-26 16:33:25 +00:00
|
|
|
*/
|
2020-10-31 14:03:30 +00:00
|
|
|
class KWAYLANDSERVER_EXPORT SubCompositorInterface : public QObject
|
2014-10-14 12:04:35 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2020-10-31 14:03:30 +00:00
|
|
|
|
2014-10-14 12:04:35 +00:00
|
|
|
public:
|
2020-10-31 14:03:30 +00:00
|
|
|
explicit SubCompositorInterface(Display *display, QObject *parent = nullptr);
|
|
|
|
~SubCompositorInterface() override;
|
2014-10-14 12:04:35 +00:00
|
|
|
|
|
|
|
Q_SIGNALS:
|
2020-10-31 14:03:30 +00:00
|
|
|
/**
|
|
|
|
* This signal is emitted when a new sub-surface @subsurface has been created.
|
|
|
|
*/
|
|
|
|
void subSurfaceCreated(KWaylandServer::SubSurfaceInterface *subsurface);
|
2014-10-14 12:04:35 +00:00
|
|
|
|
|
|
|
private:
|
2020-10-31 14:03:30 +00:00
|
|
|
QScopedPointer<SubCompositorInterfacePrivate> d;
|
2014-10-14 12:04:35 +00:00
|
|
|
};
|
|
|
|
|
2017-05-26 16:33:25 +00:00
|
|
|
/**
|
2020-10-31 14:03:30 +00:00
|
|
|
* The SubSurfaceInterface corresponds to the Wayland interface @c wl_subsurface.
|
2017-05-26 16:33:25 +00:00
|
|
|
*/
|
2020-10-31 14:03:30 +00:00
|
|
|
class KWAYLANDSERVER_EXPORT SubSurfaceInterface : public QObject
|
2014-10-14 12:04:35 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2020-10-31 14:03:30 +00:00
|
|
|
|
2014-10-14 12:04:35 +00:00
|
|
|
public:
|
2020-10-31 14:03:30 +00:00
|
|
|
~SubSurfaceInterface() override;
|
2014-10-14 12:04:35 +00:00
|
|
|
|
2020-10-31 14:03:30 +00:00
|
|
|
/**
|
|
|
|
* Returns the position of the sub-surface relative to the upper-left corner of its parent.
|
|
|
|
*/
|
2014-10-14 12:04:35 +00:00
|
|
|
QPoint position() const;
|
|
|
|
|
2020-10-31 14:03:30 +00:00
|
|
|
/**
|
|
|
|
* This enum type is used to specify the commit behavior for a subsurface.
|
|
|
|
*/
|
2014-10-14 12:04:35 +00:00
|
|
|
enum class Mode {
|
|
|
|
Synchronized,
|
|
|
|
Desynchronized
|
|
|
|
};
|
2020-10-31 14:03:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the current commit mode.
|
|
|
|
*
|
|
|
|
* @see isSynchronized
|
|
|
|
*/
|
2014-10-14 12:04:35 +00:00
|
|
|
Mode mode() const;
|
|
|
|
|
2016-03-18 09:41:56 +00:00
|
|
|
/**
|
2020-10-31 14:03:30 +00:00
|
|
|
* Returns @c true if the sub-surface is in synchronized mode; otherwise returns @c false.
|
|
|
|
*
|
|
|
|
* This method checks whether this sub-surface or any of its ancestors is in the synchronized
|
|
|
|
* mode. Note that this function is not equivalent to calling mode() and checking whether
|
|
|
|
* the return value is Mode::Synchronized.
|
|
|
|
*
|
2016-03-18 09:41:56 +00:00
|
|
|
* @see mode
|
2020-10-31 14:03:30 +00:00
|
|
|
*/
|
2016-03-18 09:41:56 +00:00
|
|
|
bool isSynchronized() const;
|
|
|
|
|
2016-03-24 14:30:48 +00:00
|
|
|
/**
|
2020-10-31 14:03:30 +00:00
|
|
|
* Returns the SurfaceInterface for this SubSurfaceInterface. This function never returns a
|
|
|
|
* @c null.
|
|
|
|
*/
|
|
|
|
SurfaceInterface *surface() const;
|
|
|
|
|
2016-03-24 14:30:48 +00:00
|
|
|
/**
|
2020-10-31 14:03:30 +00:00
|
|
|
* Returns the parent surface for this SubSurfaceInterface. This function may return @c null.
|
|
|
|
*/
|
|
|
|
SurfaceInterface *parentSurface() const;
|
2014-10-14 12:04:35 +00:00
|
|
|
|
2016-03-23 15:59:18 +00:00
|
|
|
/**
|
2020-10-31 14:03:30 +00:00
|
|
|
* Returns the main surface for the sub-surface tree, that is the first surface without a parent
|
|
|
|
*/
|
|
|
|
SurfaceInterface *mainSurface() const;
|
2016-03-23 15:59:18 +00:00
|
|
|
|
2014-10-14 12:04:35 +00:00
|
|
|
Q_SIGNALS:
|
2020-10-31 14:03:30 +00:00
|
|
|
/**
|
|
|
|
* This signal is emitted when the position of the sub-surface has changed.
|
|
|
|
*/
|
|
|
|
void positionChanged(const QPoint &position);
|
|
|
|
/**
|
|
|
|
* This signal is emitted when the commit mode of the sub-surface has changed.
|
|
|
|
*/
|
|
|
|
void modeChanged(KWaylandServer::SubSurfaceInterface::Mode mode);
|
2014-10-14 12:04:35 +00:00
|
|
|
|
|
|
|
private:
|
2020-10-31 14:03:30 +00:00
|
|
|
SubSurfaceInterface(SurfaceInterface *surface, SurfaceInterface *parent, wl_resource *resource);
|
|
|
|
QScopedPointer<SubSurfaceInterfacePrivate> d;
|
|
|
|
friend class SubSurfaceInterfacePrivate;
|
|
|
|
friend class SubCompositorInterfacePrivate;
|
2014-10-14 12:04:35 +00:00
|
|
|
};
|
|
|
|
|
2020-10-31 14:03:30 +00:00
|
|
|
} // namespace KWaylandServer
|
2014-10-14 12:04:35 +00:00
|
|
|
|
2020-04-29 14:56:38 +00:00
|
|
|
Q_DECLARE_METATYPE(KWaylandServer::SubSurfaceInterface::Mode)
|