2020-03-15 15:19:28 +00:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
|
2020-07-04 07:51:33 +00:00
|
|
|
SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
2014-10-14 12:04:35 +00:00
|
|
|
|
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
|
|
|
|
*/
|
2014-10-14 12:04:35 +00:00
|
|
|
#ifndef WAYLAND_SERVER_SURFACE_INTERFACE_P_H
|
|
|
|
#define WAYLAND_SERVER_SURFACE_INTERFACE_P_H
|
|
|
|
|
|
|
|
#include "surface_interface.h"
|
2020-10-17 10:16:28 +00:00
|
|
|
#include "utils.h"
|
2016-09-13 06:46:39 +00:00
|
|
|
// Qt
|
2019-09-17 11:36:40 +00:00
|
|
|
#include <QHash>
|
2016-09-13 06:46:39 +00:00
|
|
|
#include <QVector>
|
2014-10-14 12:04:35 +00:00
|
|
|
// Wayland
|
2020-07-04 07:51:33 +00:00
|
|
|
#include "qwayland-server-wayland.h"
|
2014-10-14 12:04:35 +00:00
|
|
|
|
2020-04-29 14:56:38 +00:00
|
|
|
namespace KWaylandServer
|
2014-10-14 12:04:35 +00:00
|
|
|
{
|
|
|
|
|
2020-07-23 20:09:20 +00:00
|
|
|
class IdleInhibitorV1Interface;
|
2019-09-05 10:57:35 +00:00
|
|
|
class SurfaceRole;
|
2020-05-24 10:46:27 +00:00
|
|
|
class ViewportInterface;
|
2017-10-20 16:28:25 +00:00
|
|
|
|
2020-07-04 07:51:33 +00:00
|
|
|
class KWaylandFrameCallback : public QtWaylandServer::wl_callback
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
KWaylandFrameCallback(wl_resource *resource, SurfaceInterface *surface);
|
|
|
|
|
|
|
|
void destroy();
|
|
|
|
|
|
|
|
QPointer<SurfaceInterface> surface;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void callback_destroy_resource(Resource *resource) override;
|
|
|
|
};
|
|
|
|
|
|
|
|
class SurfaceInterfacePrivate : public QtWaylandServer::wl_surface
|
2014-10-14 12:04:35 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
struct State {
|
|
|
|
QRegion damage = QRegion();
|
2019-05-08 07:38:37 +00:00
|
|
|
QRegion bufferDamage = QRegion();
|
2014-10-14 12:04:35 +00:00
|
|
|
QRegion opaque = QRegion();
|
2020-10-17 10:16:28 +00:00
|
|
|
QRegion input = infiniteRegion();
|
2020-05-24 10:46:27 +00:00
|
|
|
QRectF sourceGeometry = QRectF();
|
|
|
|
QSize destinationSize = QSize();
|
|
|
|
QSize size = QSize();
|
|
|
|
bool sourceGeometryIsSet = false;
|
|
|
|
bool destinationSizeIsSet = false;
|
2014-10-16 12:59:01 +00:00
|
|
|
bool inputIsSet = false;
|
|
|
|
bool opaqueIsSet = false;
|
2014-11-28 07:33:32 +00:00
|
|
|
bool bufferIsSet = false;
|
2015-07-15 09:07:50 +00:00
|
|
|
bool shadowIsSet = false;
|
2015-08-26 12:42:58 +00:00
|
|
|
bool blurIsSet = false;
|
2015-09-02 16:13:25 +00:00
|
|
|
bool contrastIsSet = false;
|
2015-09-09 11:04:11 +00:00
|
|
|
bool slideIsSet = false;
|
2016-03-18 08:57:46 +00:00
|
|
|
bool childrenChanged = false;
|
2020-06-19 06:58:40 +00:00
|
|
|
bool bufferScaleIsSet = false;
|
|
|
|
bool bufferTransformIsSet = false;
|
|
|
|
qint32 bufferScale = 1;
|
|
|
|
OutputInterface::Transform bufferTransform = OutputInterface::Transform::Normal;
|
2020-07-04 07:51:33 +00:00
|
|
|
QList<KWaylandFrameCallback *> frameCallbacks;
|
2014-10-14 12:04:35 +00:00
|
|
|
QPoint offset = QPoint();
|
|
|
|
BufferInterface *buffer = nullptr;
|
|
|
|
// stacking order: bottom (first) -> top (last)
|
|
|
|
QList<QPointer<SubSurfaceInterface>> children;
|
2015-07-15 09:07:50 +00:00
|
|
|
QPointer<ShadowInterface> shadow;
|
2015-08-26 12:42:58 +00:00
|
|
|
QPointer<BlurInterface> blur;
|
2015-09-02 16:13:25 +00:00
|
|
|
QPointer<ContrastInterface> contrast;
|
2015-09-09 11:04:11 +00:00
|
|
|
QPointer<SlideInterface> slide;
|
2014-10-14 12:04:35 +00:00
|
|
|
};
|
|
|
|
|
2020-07-04 07:51:33 +00:00
|
|
|
static SurfaceInterfacePrivate *get(SurfaceInterface *surface) { return surface->d.data(); }
|
|
|
|
|
|
|
|
explicit SurfaceInterfacePrivate(SurfaceInterface *q);
|
|
|
|
~SurfaceInterfacePrivate() override;
|
2014-10-14 12:04:35 +00:00
|
|
|
|
|
|
|
void addChild(QPointer<SubSurfaceInterface> subsurface);
|
|
|
|
void removeChild(QPointer<SubSurfaceInterface> subsurface);
|
|
|
|
bool raiseChild(QPointer<SubSurfaceInterface> subsurface, SurfaceInterface *sibling);
|
|
|
|
bool lowerChild(QPointer<SubSurfaceInterface> subsurface, SurfaceInterface *sibling);
|
2015-07-15 09:07:50 +00:00
|
|
|
void setShadow(const QPointer<ShadowInterface> &shadow);
|
2015-08-26 12:42:58 +00:00
|
|
|
void setBlur(const QPointer<BlurInterface> &blur);
|
2015-09-02 16:13:25 +00:00
|
|
|
void setContrast(const QPointer<ContrastInterface> &contrast);
|
2015-09-09 11:04:11 +00:00
|
|
|
void setSlide(const QPointer<SlideInterface> &slide);
|
2016-11-08 13:17:15 +00:00
|
|
|
void installPointerConstraint(LockedPointerInterface *lock);
|
|
|
|
void installPointerConstraint(ConfinedPointerInterface *confinement);
|
2020-07-23 20:09:20 +00:00
|
|
|
void installIdleInhibitor(IdleInhibitorV1Interface *inhibitor);
|
2014-10-14 12:04:35 +00:00
|
|
|
|
2016-03-18 08:57:46 +00:00
|
|
|
void commitSubSurface();
|
|
|
|
void commit();
|
2020-06-10 07:42:16 +00:00
|
|
|
QMatrix4x4 buildSurfaceToBufferMatrix(const State *state);
|
2020-05-23 18:12:36 +00:00
|
|
|
|
2020-07-04 07:51:33 +00:00
|
|
|
CompositorInterface *compositor;
|
|
|
|
SurfaceInterface *q;
|
2019-09-05 10:57:35 +00:00
|
|
|
SurfaceRole *role = nullptr;
|
|
|
|
|
2014-10-14 12:04:35 +00:00
|
|
|
State current;
|
|
|
|
State pending;
|
2020-07-04 12:13:47 +00:00
|
|
|
State cached;
|
2014-10-14 12:04:35 +00:00
|
|
|
QPointer<SubSurfaceInterface> subSurface;
|
2016-04-01 06:36:34 +00:00
|
|
|
QRegion trackedDamage;
|
2020-06-10 07:42:16 +00:00
|
|
|
QMatrix4x4 surfaceToBufferMatrix;
|
|
|
|
QMatrix4x4 bufferToSurfaceMatrix;
|
2020-06-30 06:06:53 +00:00
|
|
|
QSize bufferSize;
|
2020-10-17 10:16:28 +00:00
|
|
|
QRegion inputRegion;
|
2014-10-14 12:04:35 +00:00
|
|
|
|
2016-03-29 13:54:18 +00:00
|
|
|
// workaround for https://bugreports.qt.io/browse/QTBUG-52192
|
|
|
|
// A subsurface needs to be considered mapped even if it doesn't have a buffer attached
|
|
|
|
// Otherwise Qt's sub-surfaces will never be visible and the client will freeze due to
|
|
|
|
// waiting on the frame callback of the never visible surface
|
|
|
|
bool subSurfaceIsMapped = true;
|
|
|
|
|
2016-08-22 12:18:23 +00:00
|
|
|
QVector<OutputInterface *> outputs;
|
|
|
|
|
2016-11-08 13:17:15 +00:00
|
|
|
QPointer<LockedPointerInterface> lockedPointer;
|
|
|
|
QPointer<ConfinedPointerInterface> confinedPointer;
|
2017-08-26 10:53:09 +00:00
|
|
|
QHash<OutputInterface*, QMetaObject::Connection> outputDestroyedConnections;
|
2020-07-23 20:09:20 +00:00
|
|
|
QVector<IdleInhibitorV1Interface*> idleInhibitors;
|
2020-05-24 10:46:27 +00:00
|
|
|
ViewportInterface *viewportExtension = nullptr;
|
2019-02-06 08:26:43 +00:00
|
|
|
SurfaceInterface *dataProxy = nullptr;
|
|
|
|
|
2020-07-04 07:51:33 +00:00
|
|
|
static QList<SurfaceInterface *> surfaces;
|
|
|
|
|
2020-07-15 21:51:42 +00:00
|
|
|
ClientConnection *client = nullptr;
|
|
|
|
|
2020-07-04 07:51:33 +00:00
|
|
|
protected:
|
|
|
|
void surface_destroy_resource(Resource *resource) override;
|
|
|
|
void surface_destroy(Resource *resource) override;
|
|
|
|
void surface_attach(Resource *resource, struct ::wl_resource *buffer, int32_t x, int32_t y) override;
|
|
|
|
void surface_damage(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override;
|
|
|
|
void surface_frame(Resource *resource, uint32_t callback) override;
|
|
|
|
void surface_set_opaque_region(Resource *resource, struct ::wl_resource *region) override;
|
|
|
|
void surface_set_input_region(Resource *resource, struct ::wl_resource *region) override;
|
|
|
|
void surface_commit(Resource *resource) override;
|
|
|
|
void surface_set_buffer_transform(Resource *resource, int32_t transform) override;
|
|
|
|
void surface_set_buffer_scale(Resource *resource, int32_t scale) override;
|
|
|
|
void surface_damage_buffer(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override;
|
|
|
|
|
2014-10-14 12:04:35 +00:00
|
|
|
private:
|
2020-07-04 07:51:33 +00:00
|
|
|
void swapStates(State *source, State *target, bool emitChanged);
|
|
|
|
|
2016-11-08 13:17:15 +00:00
|
|
|
QMetaObject::Connection constrainsOneShotConnection;
|
|
|
|
QMetaObject::Connection constrainsUnboundConnection;
|
2014-10-14 12:04:35 +00:00
|
|
|
};
|
|
|
|
|
2020-07-04 07:51:33 +00:00
|
|
|
} // namespace KWaylandServer
|
2014-10-14 12:04:35 +00:00
|
|
|
|
|
|
|
#endif
|