summaryrefslogtreecommitdiffstats
path: root/src/compositor
diff options
context:
space:
mode:
Diffstat (limited to 'src/compositor')
-rw-r--r--src/compositor/compositor_api/qwaylandquickcompositor.cpp6
-rw-r--r--src/compositor/compositor_api/qwaylandquickitem.cpp4
-rw-r--r--src/compositor/compositor_api/qwaylandsurface.cpp40
-rw-r--r--src/compositor/compositor_api/qwaylandsurface.h3
-rw-r--r--src/compositor/compositor_api/qwaylandsurface_p.h4
-rw-r--r--src/compositor/extensions/extensions.pri4
-rw-r--r--src/compositor/extensions/qwaylandviewporter.cpp243
-rw-r--r--src/compositor/extensions/qwaylandviewporter.h63
-rw-r--r--src/compositor/extensions/qwaylandviewporter_p.h93
9 files changed, 458 insertions, 2 deletions
diff --git a/src/compositor/compositor_api/qwaylandquickcompositor.cpp b/src/compositor/compositor_api/qwaylandquickcompositor.cpp
index 8e8a903e3..426008a60 100644
--- a/src/compositor/compositor_api/qwaylandquickcompositor.cpp
+++ b/src/compositor/compositor_api/qwaylandquickcompositor.cpp
@@ -53,6 +53,7 @@
#include "qwaylandquickitem.h"
#include "qwaylandoutput.h"
#include <QtWaylandCompositor/private/qwaylandcompositor_p.h>
+#include <QtWaylandCompositor/QWaylandViewporter>
#include "qwaylandsurfacegrabber.h"
QT_BEGIN_NAMESPACE
@@ -60,8 +61,9 @@ QT_BEGIN_NAMESPACE
class QWaylandQuickCompositorPrivate : public QWaylandCompositorPrivate
{
public:
- QWaylandQuickCompositorPrivate(QWaylandCompositor *compositor)
+ explicit QWaylandQuickCompositorPrivate(QWaylandCompositor *compositor)
: QWaylandCompositorPrivate(compositor)
+ , m_viewporter(new QWaylandViewporter(compositor))
{
}
protected:
@@ -69,6 +71,8 @@ protected:
{
return new QWaylandQuickSurface();
}
+private:
+ QScopedPointer<QWaylandViewporter> m_viewporter;
};
QWaylandQuickCompositor::QWaylandQuickCompositor(QObject *parent)
diff --git a/src/compositor/compositor_api/qwaylandquickitem.cpp b/src/compositor/compositor_api/qwaylandquickitem.cpp
index bc8365982..f848a0169 100644
--- a/src/compositor/compositor_api/qwaylandquickitem.cpp
+++ b/src/compositor/compositor_api/qwaylandquickitem.cpp
@@ -1317,6 +1317,10 @@ QSGNode *QWaylandQuickItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeDat
d->provider->setSmooth(smooth());
node->setRect(rect);
+ qreal scale = surface()->bufferScale();
+ QRectF source = surface()->sourceGeometry();
+ node->setSourceRect(QRectF(source.topLeft() * scale, source.size() * scale));
+
return node;
} else {
Q_ASSERT(!d->provider);
diff --git a/src/compositor/compositor_api/qwaylandsurface.cpp b/src/compositor/compositor_api/qwaylandsurface.cpp
index 8ad2389b6..eef51283c 100644
--- a/src/compositor/compositor_api/qwaylandsurface.cpp
+++ b/src/compositor/compositor_api/qwaylandsurface.cpp
@@ -235,6 +235,7 @@ void QWaylandSurfacePrivate::surface_commit(Resource *)
// Needed in order to know whether we want to emit signals later
QSize oldBufferSize = bufferSize;
+ QRectF oldSourceGeometry = sourceGeometry;
QSize oldDestinationSize = destinationSize;
bool oldHasContent = hasContent;
int oldBufferScale = bufferScale;
@@ -244,7 +245,9 @@ void QWaylandSurfacePrivate::surface_commit(Resource *)
bufferRef = pending.buffer;
bufferScale = pending.bufferScale;
bufferSize = bufferRef.size();
- destinationSize = pending.destinationSize.isEmpty() ? bufferSize / bufferScale : pending.destinationSize;
+ QSize surfaceSize = bufferSize / bufferScale;
+ sourceGeometry = !pending.sourceGeometry.isValid() ? QRect(QPoint(), surfaceSize) : pending.sourceGeometry;
+ destinationSize = pending.destinationSize.isEmpty() ? sourceGeometry.size().toSize() : pending.destinationSize;
damage = pending.damage.intersected(QRect(QPoint(), destinationSize));
hasContent = bufferRef.hasContent();
frameCallbacks << pendingFrameCallbacks;
@@ -252,6 +255,9 @@ void QWaylandSurfacePrivate::surface_commit(Resource *)
opaqueRegion = pending.opaqueRegion.intersected(QRect(QPoint(), destinationSize));
QPoint offsetForNextFrame = pending.offset;
+ if (viewport)
+ viewport->checkCommittedState();
+
// Clear per-commit state
pending.buffer = QWaylandBufferRef();
pending.offset = QPoint();
@@ -284,6 +290,9 @@ void QWaylandSurfacePrivate::surface_commit(Resource *)
if (oldDestinationSize != destinationSize)
emit q->destinationSizeChanged();
+ if (oldSourceGeometry != sourceGeometry)
+ emit q->sourceGeometryChanged();
+
if (oldHasContent != hasContent)
emit q->hasContentChanged();
@@ -471,6 +480,35 @@ bool QWaylandSurface::hasContent() const
}
/*!
+ * \qmlproperty rect QtWaylandCompositor::WaylandSurface::sourceGeometry
+ *
+ * This property describes the portion of the attached Wayland buffer that should
+ * be drawn on the screen. The coordinates are from the corner of the buffer and are
+ * scaled by \l bufferScale.
+ *
+ * \sa bufferScale
+ * \sa bufferSize
+ * \sa destinationSize
+ */
+
+/*!
+ * \property QWaylandSurface::sourceGeometry
+ *
+ * This property describes the portion of the attached QWaylandBuffer that should
+ * be drawn on the screen. The coordinates are from the corner of the buffer and are
+ * scaled by \l bufferScale.
+ *
+ * \sa bufferScale
+ * \sa bufferSize
+ * \sa destinationSize
+ */
+QRectF QWaylandSurface::sourceGeometry() const
+{
+ Q_D(const QWaylandSurface);
+ return d->sourceGeometry;
+}
+
+/*!
* \qmlproperty size QtWaylandCompositor::WaylandSurface::destinationSize
*
* This property holds the size of this WaylandSurface in surface coordinates.
diff --git a/src/compositor/compositor_api/qwaylandsurface.h b/src/compositor/compositor_api/qwaylandsurface.h
index 13f09f33c..9bf842900 100644
--- a/src/compositor/compositor_api/qwaylandsurface.h
+++ b/src/compositor/compositor_api/qwaylandsurface.h
@@ -81,6 +81,7 @@ class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandSurface : public QWaylandObject
Q_OBJECT
Q_DECLARE_PRIVATE(QWaylandSurface)
Q_PROPERTY(QWaylandClient *client READ client CONSTANT)
+ Q_PROPERTY(QRectF sourceGeometry READ sourceGeometry NOTIFY sourceGeometryChanged)
Q_PROPERTY(QSize destinationSize READ destinationSize NOTIFY destinationSizeChanged)
#if QT_DEPRECATED_SINCE(5, 13)
Q_PROPERTY(QSize size READ size NOTIFY sizeChanged) // Qt 6: Remove
@@ -113,6 +114,7 @@ public:
bool hasContent() const;
+ QRectF sourceGeometry() const;
QSize destinationSize() const;
#if QT_DEPRECATED_SINCE(5, 13)
QT_DEPRECATED QSize size() const;
@@ -162,6 +164,7 @@ Q_SIGNALS:
void damaged(const QRegion &rect);
void parentChanged(QWaylandSurface *newParent, QWaylandSurface *oldParent);
void childAdded(QWaylandSurface *child);
+ void sourceGeometryChanged();
void destinationSizeChanged();
#if QT_DEPRECATED_SINCE(5, 13)
QT_DEPRECATED void sizeChanged();
diff --git a/src/compositor/compositor_api/qwaylandsurface_p.h b/src/compositor/compositor_api/qwaylandsurface_p.h
index b34367801..85643623d 100644
--- a/src/compositor/compositor_api/qwaylandsurface_p.h
+++ b/src/compositor/compositor_api/qwaylandsurface_p.h
@@ -73,6 +73,7 @@
#include <wayland-util.h>
#include <QtWaylandCompositor/private/qwayland-server-wayland.h>
+#include <QtWaylandCompositor/private/qwaylandviewporter_p.h>
QT_BEGIN_NAMESPACE
@@ -144,6 +145,7 @@ public: //member variables
QRegion damage;
QWaylandBufferRef bufferRef;
QWaylandSurfaceRole *role = nullptr;
+ QWaylandViewporterPrivate::Viewport *viewport = nullptr;
struct {
QWaylandBufferRef buffer;
@@ -152,6 +154,7 @@ public: //member variables
bool newlyAttached;
QRegion inputRegion;
int bufferScale;
+ QRectF sourceGeometry;
QSize destinationSize;
QRegion opaqueRegion;
} pending;
@@ -167,6 +170,7 @@ public: //member variables
QRegion inputRegion;
QRegion opaqueRegion;
+ QRectF sourceGeometry;
QSize destinationSize;
QSize bufferSize;
int bufferScale = 1;
diff --git a/src/compositor/extensions/extensions.pri b/src/compositor/extensions/extensions.pri
index 5c708f891..38fe79a2f 100644
--- a/src/compositor/extensions/extensions.pri
+++ b/src/compositor/extensions/extensions.pri
@@ -9,6 +9,7 @@ WAYLANDSERVERSOURCES += \
../extensions/qt-key-unstable-v1.xml \
../extensions/qt-windowmanager.xml \
../3rdparty/protocol/text-input-unstable-v2.xml \
+ ../3rdparty/protocol/viewporter.xml \
../3rdparty/protocol/xdg-shell-unstable-v6.xml \
../3rdparty/protocol/xdg-shell.xml \
../3rdparty/protocol/xdg-decoration-unstable-v1.xml \
@@ -27,6 +28,8 @@ HEADERS += \
extensions/qwaylandtextinputmanager_p.h \
extensions/qwaylandqtwindowmanager.h \
extensions/qwaylandqtwindowmanager_p.h \
+ extensions/qwaylandviewporter.h \
+ extensions/qwaylandviewporter_p.h \
extensions/qwaylandxdgshellv5.h \
extensions/qwaylandxdgshellv5_p.h \
extensions/qwaylandxdgshellv6.h \
@@ -49,6 +52,7 @@ SOURCES += \
extensions/qwaylandtextinput.cpp \
extensions/qwaylandtextinputmanager.cpp \
extensions/qwaylandqtwindowmanager.cpp \
+ extensions/qwaylandviewporter.cpp \
extensions/qwaylandxdgshellv5.cpp \
extensions/qwaylandxdgshellv6.cpp \
extensions/qwaylandxdgshell.cpp \
diff --git a/src/compositor/extensions/qwaylandviewporter.cpp b/src/compositor/extensions/qwaylandviewporter.cpp
new file mode 100644
index 000000000..3856c135d
--- /dev/null
+++ b/src/compositor/extensions/qwaylandviewporter.cpp
@@ -0,0 +1,243 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaylandviewporter_p.h"
+
+#include <QtWaylandCompositor/QWaylandSurface>
+#include <QtWaylandCompositor/QWaylandCompositor>
+
+#include <QtWaylandCompositor/private/qwaylandsurface_p.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QWaylandViewporter
+ \inmodule QtWaylandCompositor
+ \since 5.13
+ \brief Provides an extension for surface resizing and cropping.
+
+ The QWaylandViewporter extension provides a way for clients to resize and crop surface
+ contents.
+
+ QWaylandViewporter corresponds to the Wayland interface, \c wp_viewporter.
+*/
+
+/*!
+ Constructs a QWaylandViewporter object.
+*/
+QWaylandViewporter::QWaylandViewporter()
+ : QWaylandCompositorExtensionTemplate<QWaylandViewporter>(*new QWaylandViewporterPrivate)
+{
+}
+
+/*!
+ * Constructs a QWaylandViewporter object for the provided \a compositor.
+ */
+QWaylandViewporter::QWaylandViewporter(QWaylandCompositor *compositor)
+ : QWaylandCompositorExtensionTemplate<QWaylandViewporter>(compositor, *new QWaylandViewporterPrivate())
+{
+}
+
+/*!
+ Initializes the extension.
+*/
+void QWaylandViewporter::initialize()
+{
+ Q_D(QWaylandViewporter);
+
+ QWaylandCompositorExtensionTemplate::initialize();
+ auto *compositor = static_cast<QWaylandCompositor *>(extensionContainer());
+ if (!compositor) {
+ qWarning() << "Failed to find QWaylandCompositor when initializing QWaylandViewporter";
+ return;
+ }
+ d->init(compositor->display(), 1);
+}
+
+/*!
+ Returns the Wayland interface for the QWaylandViewporter.
+*/
+const wl_interface *QWaylandViewporter::interface()
+{
+ return QWaylandViewporterPrivate::interface();
+}
+
+void QWaylandViewporterPrivate::wp_viewporter_destroy(Resource *resource)
+{
+ // Viewport objects are allowed ot outlive the viewporter
+ wl_resource_destroy(resource->handle);
+}
+
+void QWaylandViewporterPrivate::wp_viewporter_get_viewport(Resource *resource, uint id, wl_resource *surfaceResource)
+{
+ auto *surface = QWaylandSurface::fromResource(surfaceResource);
+ if (!surface) {
+ qWarning() << "Couldn't find surface for viewporter";
+ return;
+ }
+
+ auto *surfacePrivate = QWaylandSurfacePrivate::get(surface);
+ if (surfacePrivate->viewport) {
+ wl_resource_post_error(resource->handle, WP_VIEWPORTER_ERROR_VIEWPORT_EXISTS,
+ "viewport already exists for surface");
+ return;
+ }
+
+ surfacePrivate->viewport = new Viewport(surface, resource->client(), id);
+}
+
+QWaylandViewporterPrivate::Viewport::Viewport(QWaylandSurface *surface, wl_client *client, int id)
+ : QtWaylandServer::wp_viewport(client, id, /*version*/ 1)
+ , m_surface(surface)
+{
+ Q_ASSERT(surface);
+}
+
+QWaylandViewporterPrivate::Viewport::~Viewport()
+{
+ if (m_surface) {
+ auto *surfacePrivate = QWaylandSurfacePrivate::get(m_surface);
+ Q_ASSERT(surfacePrivate->viewport == this);
+ surfacePrivate->viewport = nullptr;
+ }
+}
+
+// This function has to be called immediately after a surface is committed, before no
+// other client events have been dispatched, or we may incorrectly error out on an
+// incomplete pending state. See comment below.
+void QWaylandViewporterPrivate::Viewport::checkCommittedState()
+{
+ auto *surfacePrivate = QWaylandSurfacePrivate::get(m_surface);
+
+ // We can't use the current state for destination/source when checking,
+ // as that has fallbacks to the buffer size so we can't distinguish
+ // between the set/unset case. We use the pending state because no other
+ // requests has modified it yet.
+ QSize destination = surfacePrivate->pending.destinationSize;
+ QRectF source = surfacePrivate->pending.sourceGeometry;
+
+ if (!destination.isValid() && source.size() != source.size().toSize()) {
+ wl_resource_post_error(resource()->handle, error_bad_size,
+ "non-integer size (%fx%f) with unset destination",
+ source.width(), source.height());
+ return;
+ }
+
+ QRectF max = QRectF(QPointF(), m_surface->bufferSize() / m_surface->bufferScale());
+ // We can't use QRectF.contains, because that would return false for values on the border
+ if (max.united(source) != max) {
+ wl_resource_post_error(resource()->handle, error_out_of_buffer,
+ "source %f,%f, %fx%f extends outside attached buffer %fx%f",
+ source.x(), source.y(), source.width(), source.height(),
+ max.width(), max.height());
+ return;
+ }
+}
+
+
+void QWaylandViewporterPrivate::Viewport::wp_viewport_destroy_resource(Resource *resource)
+{
+ Q_UNUSED(resource);
+ delete this;
+}
+
+void QWaylandViewporterPrivate::Viewport::wp_viewport_destroy(Resource *resource)
+{
+ if (m_surface) {
+ auto *surfacePrivate = QWaylandSurfacePrivate::get(m_surface);
+ surfacePrivate->pending.destinationSize = QSize();
+ surfacePrivate->pending.sourceGeometry = QRectF();
+ }
+ wl_resource_destroy(resource->handle);
+}
+
+void QWaylandViewporterPrivate::Viewport::wp_viewport_set_source(QtWaylandServer::wp_viewport::Resource *resource, wl_fixed_t x, wl_fixed_t y, wl_fixed_t width, wl_fixed_t height)
+{
+ Q_UNUSED(resource);
+
+ if (!m_surface) {
+ wl_resource_post_error(resource->handle, error_no_surface,
+ "set_source requested for destroyed surface");
+ return;
+ }
+
+ QPointF position(wl_fixed_to_double(x), wl_fixed_to_double(y));
+ QSizeF size(wl_fixed_to_double(width), wl_fixed_to_double(height));
+ QRectF sourceGeometry(position, size);
+
+ if (sourceGeometry == QRectF(-1, -1, -1, -1)) {
+ auto *surfacePrivate = QWaylandSurfacePrivate::get(m_surface);
+ surfacePrivate->pending.sourceGeometry = QRectF();
+ return;
+ }
+
+ if (position.x() < 0 || position.y() < 0) {
+ wl_resource_post_error(resource->handle, error_bad_value,
+ "negative position in set_source");
+ return;
+ }
+
+ if (!size.isValid()) {
+ wl_resource_post_error(resource->handle, error_bad_value,
+ "negative size in set_source");
+ return;
+ }
+
+ auto *surfacePrivate = QWaylandSurfacePrivate::get(m_surface);
+ surfacePrivate->pending.sourceGeometry = sourceGeometry;
+}
+
+void QWaylandViewporterPrivate::Viewport::wp_viewport_set_destination(QtWaylandServer::wp_viewport::Resource *resource, int32_t width, int32_t height)
+{
+ Q_UNUSED(resource);
+
+ if (!m_surface) {
+ wl_resource_post_error(resource->handle, error_no_surface,
+ "set_destination requested for destroyed surface");
+ return;
+ }
+
+ QSize destinationSize(width, height);
+ if (!destinationSize.isValid() && destinationSize != QSize(-1, -1)) {
+ wl_resource_post_error(resource->handle, error_bad_value,
+ "negative size in set_destination");
+ return;
+ }
+ auto *surfacePrivate = QWaylandSurfacePrivate::get(m_surface);
+ surfacePrivate->pending.destinationSize = destinationSize;
+}
+
+QT_END_NAMESPACE
diff --git a/src/compositor/extensions/qwaylandviewporter.h b/src/compositor/extensions/qwaylandviewporter.h
new file mode 100644
index 000000000..811c74145
--- /dev/null
+++ b/src/compositor/extensions/qwaylandviewporter.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDVIEWPORTER_H
+#define QWAYLANDVIEWPORTER_H
+
+#include <QtWaylandCompositor/QWaylandCompositorExtension>
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandViewporterPrivate;
+
+class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandViewporter
+ : public QWaylandCompositorExtensionTemplate<QWaylandViewporter>
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QWaylandViewporter)
+
+public:
+ explicit QWaylandViewporter();
+ explicit QWaylandViewporter(QWaylandCompositor *compositor);
+
+ void initialize() override;
+
+ static const struct wl_interface *interface();
+};
+
+QT_END_NAMESPACE
+
+#endif // QWAYLANDVIEWPORTER_H
diff --git a/src/compositor/extensions/qwaylandviewporter_p.h b/src/compositor/extensions/qwaylandviewporter_p.h
new file mode 100644
index 000000000..d22da6990
--- /dev/null
+++ b/src/compositor/extensions/qwaylandviewporter_p.h
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWaylandCompositor module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWAYLANDVIEWPORTER_P_H
+#define QWAYLANDVIEWPORTER_P_H
+
+#include "qwaylandviewporter.h"
+
+#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h>
+#include <QtWaylandCompositor/private/qwayland-server-viewporter.h>
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+QT_BEGIN_NAMESPACE
+
+class QWaylandSurface;
+
+class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandViewporterPrivate
+ : public QWaylandCompositorExtensionPrivate
+ , public QtWaylandServer::wp_viewporter
+{
+ Q_DECLARE_PUBLIC(QWaylandViewporter)
+public:
+ explicit QWaylandViewporterPrivate() = default;
+
+ class Q_WAYLAND_COMPOSITOR_EXPORT Viewport
+ : public QtWaylandServer::wp_viewport
+ {
+ public:
+ explicit Viewport(QWaylandSurface *surface, wl_client *client, int id);
+ ~Viewport() override;
+ void checkCommittedState();
+
+ protected:
+ void wp_viewport_destroy_resource(Resource *resource) override;
+ void wp_viewport_destroy(Resource *resource) override;
+ void wp_viewport_set_source(Resource *resource, wl_fixed_t x, wl_fixed_t y, wl_fixed_t width, wl_fixed_t height) override;
+ void wp_viewport_set_destination(Resource *resource, int32_t width, int32_t height) override;
+
+ private:
+ QPointer<QWaylandSurface> m_surface = nullptr;
+ };
+
+protected:
+ void wp_viewporter_destroy(Resource *resource) override;
+ void wp_viewporter_get_viewport(Resource *resource, uint32_t id, wl_resource *surface) override;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWAYLANDVIEWPORTER_P_H