summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2018-11-14 15:47:00 +0100
committerJohan Helsing <johan.helsing@qt.io>2019-01-24 06:31:16 +0000
commit344e884d93bc35a8011427963f39575e56a5418a (patch)
treeaeececb30cc4e3fa4e42251b17151874faf75009
parentf9ba56f24e7d1fcc9d0dc5eabb55335fc64b9a56 (diff)
Add deprecated support for wl_scaler
[ChangeLog][Compositor] Add deprecated support for the deprecated wl_scaler. Some clients are stuck on the unofficial Weston protocol wl_scaler instead of the standardized and stable wp_viewporter. This implements optional support for wl_scaler. This patch has been written to be easily removable in Qt 6, and touches a minimal amount of other code. The implementation can be tested using the new manual test compositor: tests/manual/wlscaler. Weston 1.11.1 has a demo client named weston-resizor, which can be used to test. Note that although newer versions of Weston also have weston-resizor, those versions use wp_viewporter instead of wl_scaler, so you really need 1.11.1 or earlier to test. Fixes: QTBUG-69635 Change-Id: Id572e28044cd764eaf63b1259a92bc589711c39d Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
-rw-r--r--src/3rdparty/protocol/qt_attribution.json17
-rw-r--r--src/3rdparty/protocol/scaler.xml208
-rw-r--r--src/compositor/extensions/extensions.pri4
-rw-r--r--src/compositor/extensions/qwaylandwlscaler.cpp274
-rw-r--r--src/compositor/extensions/qwaylandwlscaler.h67
-rw-r--r--src/compositor/extensions/qwaylandwlscaler_p.h93
-rw-r--r--src/imports/compositor/qwaylandquickcompositorplugin.cpp4
-rw-r--r--sync.profile2
-rw-r--r--tests/manual/wlscaler/main.cpp59
-rw-r--r--tests/manual/wlscaler/main.qml100
-rw-r--r--tests/manual/wlscaler/qml.qrc5
-rw-r--r--tests/manual/wlscaler/wlscaler.pro7
12 files changed, 840 insertions, 0 deletions
diff --git a/src/3rdparty/protocol/qt_attribution.json b/src/3rdparty/protocol/qt_attribution.json
index 657c0328..ad32d3af 100644
--- a/src/3rdparty/protocol/qt_attribution.json
+++ b/src/3rdparty/protocol/qt_attribution.json
@@ -56,6 +56,23 @@ Copyright (c) 2013 BMW Car IT GmbH"
},
{
+ "Id": "wayland-scaler-protocol",
+ "Name": "Wayland Scaler Protocol",
+ "QDocModule": "qtwaylandcompositor",
+ "QtUsage": "Used in the Qt Wayland Compositor API",
+ "Files": "scaler.xml",
+
+ "Description": "The Wayland scaler extension allows a client to scale or crop a surface without modifying the buffer",
+ "Homepage": "https://wayland.freedesktop.org",
+ "Version": "2",
+ "DownloadLocation": "https://cgit.freedesktop.org/wayland/weston/plain/protocol/scaler.xml?h=1.11.1",
+ "LicenseId": "MIT",
+ "License": "MIT License",
+ "LicenseFile": "MIT_LICENSE.txt",
+ "Copyright": "Copyright © 2013-2014 Collabora, Ltd."
+ },
+
+ {
"Id": "wayland-viewporter-protocol",
"Name": "Wayland Viewporter Protocol",
"QDocModule": "qtwaylandcompositor",
diff --git a/src/3rdparty/protocol/scaler.xml b/src/3rdparty/protocol/scaler.xml
new file mode 100644
index 00000000..0e482a63
--- /dev/null
+++ b/src/3rdparty/protocol/scaler.xml
@@ -0,0 +1,208 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<protocol name="scaler">
+
+ <copyright>
+ Copyright © 2013-2014 Collabora, Ltd.
+
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice (including the next
+ paragraph) shall be included in all copies or substantial portions of the
+ Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ </copyright>
+
+ <interface name="wl_scaler" version="2">
+ <description summary="surface cropping and scaling">
+ The global interface exposing surface cropping and scaling
+ capabilities is used to instantiate an interface extension for a
+ wl_surface object. This extended interface will then allow
+ cropping and scaling the surface contents, effectively
+ disconnecting the direct relationship between the buffer and the
+ surface size.
+ </description>
+
+ <request name="destroy" type="destructor">
+ <description summary="unbind from the cropping and scaling interface">
+ Informs the server that the client will not be using this
+ protocol object anymore. This does not affect any other objects,
+ wl_viewport objects included.
+ </description>
+ </request>
+
+ <enum name="error">
+ <entry name="viewport_exists" value="0"
+ summary="the surface already has a viewport object associated"/>
+ </enum>
+
+ <request name="get_viewport">
+ <description summary="extend surface interface for crop and scale">
+ Instantiate an interface extension for the given wl_surface to
+ crop and scale its content. If the given wl_surface already has
+ a wl_viewport object associated, the viewport_exists
+ protocol error is raised.
+ </description>
+
+ <arg name="id" type="new_id" interface="wl_viewport"
+ summary="the new viewport interface id"/>
+ <arg name="surface" type="object" interface="wl_surface"
+ summary="the surface"/>
+ </request>
+ </interface>
+
+ <interface name="wl_viewport" version="2">
+ <description summary="crop and scale interface to a wl_surface">
+ An additional interface to a wl_surface object, which allows the
+ client to specify the cropping and scaling of the surface
+ contents.
+
+ This interface allows to define the source rectangle (src_x,
+ src_y, src_width, src_height) from where to take the wl_buffer
+ contents, and scale that to destination size (dst_width,
+ dst_height). This state is double-buffered, and is applied on the
+ next wl_surface.commit.
+
+ The two parts of crop and scale state are independent: the source
+ rectangle, and the destination size. Initially both are unset, that
+ is, no scaling is applied. The whole of the current wl_buffer is
+ used as the source, and the surface size is as defined in
+ wl_surface.attach.
+
+ If the destination size is set, it causes the surface size to become
+ dst_width, dst_height. The source (rectangle) is scaled to exactly
+ this size. This overrides whatever the attached wl_buffer size is,
+ unless the wl_buffer is NULL. If the wl_buffer is NULL, the surface
+ has no content and therefore no size. Otherwise, the size is always
+ at least 1x1 in surface coordinates.
+
+ If the source rectangle is set, it defines what area of the
+ wl_buffer is taken as the source. If the source rectangle is set and
+ the destination size is not set, the surface size becomes the source
+ rectangle size rounded up to the nearest integer. If the source size
+ is already exactly integers, this results in cropping without scaling.
+
+ The coordinate transformations from buffer pixel coordinates up to
+ the surface-local coordinates happen in the following order:
+ 1. buffer_transform (wl_surface.set_buffer_transform)
+ 2. buffer_scale (wl_surface.set_buffer_scale)
+ 3. crop and scale (wl_viewport.set*)
+ This means, that the source rectangle coordinates of crop and scale
+ are given in the coordinates after the buffer transform and scale,
+ i.e. in the coordinates that would be the surface-local coordinates
+ if the crop and scale was not applied.
+
+ If the source rectangle is partially or completely outside of the
+ wl_buffer, then the surface contents are undefined (not void), and
+ the surface size is still dst_width, dst_height.
+
+ The x, y arguments of wl_surface.attach are applied as normal to
+ the surface. They indicate how many pixels to remove from the
+ surface size from the left and the top. In other words, they are
+ still in the surface-local coordinate system, just like dst_width
+ and dst_height are.
+
+ If the wl_surface associated with the wl_viewport is destroyed,
+ the wl_viewport object becomes inert.
+
+ If the wl_viewport object is destroyed, the crop and scale
+ state is removed from the wl_surface. The change will be applied
+ on the next wl_surface.commit.
+ </description>
+
+ <request name="destroy" type="destructor">
+ <description summary="remove scaling and cropping from the surface">
+ The associated wl_surface's crop and scale state is removed.
+ The change is applied on the next wl_surface.commit.
+ </description>
+ </request>
+
+ <enum name="error">
+ <entry name="bad_value" value="0"
+ summary="negative or zero values in width or height"/>
+ </enum>
+
+ <request name="set">
+ <description summary="set the crop and scale state">
+ Set both source rectangle and destination size of the associated
+ wl_surface. See wl_viewport for the description, and relation to
+ the wl_buffer size.
+
+ The bad_value protocol error is raised if src_width or
+ src_height is negative, or if dst_width or dst_height is not
+ positive.
+
+ The crop and scale state is double-buffered state, and will be
+ applied on the next wl_surface.commit.
+
+ Arguments dst_x and dst_y do not exist here, use the x and y
+ arguments to wl_surface.attach. The x, y, dst_width, and dst_height
+ define the surface-local coordinate system irrespective of the
+ attached wl_buffer size.
+ </description>
+
+ <arg name="src_x" type="fixed" summary="source rectangle x"/>
+ <arg name="src_y" type="fixed" summary="source rectangle y"/>
+ <arg name="src_width" type="fixed" summary="source rectangle width"/>
+ <arg name="src_height" type="fixed" summary="source rectangle height"/>
+ <arg name="dst_width" type="int" summary="surface width"/>
+ <arg name="dst_height" type="int" summary="surface height"/>
+ </request>
+
+ <request name="set_source" since="2">
+ <description summary="set the source rectangle for cropping">
+ Set the source rectangle of the associated wl_surface. See
+ wl_viewport for the description, and relation to the wl_buffer
+ size.
+
+ If width is -1.0 and height is -1.0, the source rectangle is unset
+ instead. Any other pair of values for width and height that
+ contains zero or negative values raises the bad_value protocol
+ error.
+
+ The crop and scale state is double-buffered state, and will be
+ applied on the next wl_surface.commit.
+ </description>
+
+ <arg name="x" type="fixed" summary="source rectangle x"/>
+ <arg name="y" type="fixed" summary="source rectangle y"/>
+ <arg name="width" type="fixed" summary="source rectangle width"/>
+ <arg name="height" type="fixed" summary="source rectangle height"/>
+ </request>
+
+ <request name="set_destination" since="2">
+ <description summary="set the surface size for scaling">
+ Set the destination size of the associated wl_surface. See
+ wl_viewport for the description, and relation to the wl_buffer
+ size.
+
+ If width is -1 and height is -1, the destination size is unset
+ instead. Any other pair of values for width and height that
+ contains zero or negative values raises the bad_value protocol
+ error.
+
+ The crop and scale state is double-buffered state, and will be
+ applied on the next wl_surface.commit.
+
+ Arguments x and y do not exist here, use the x and y arguments to
+ wl_surface.attach. The x, y, width, and height define the
+ surface-local coordinate system irrespective of the attached
+ wl_buffer size.
+ </description>
+
+ <arg name="width" type="int" summary="surface width"/>
+ <arg name="height" type="int" summary="surface height"/>
+ </request>
+ </interface>
+</protocol>
diff --git a/src/compositor/extensions/extensions.pri b/src/compositor/extensions/extensions.pri
index 38fe79a2..361f9398 100644
--- a/src/compositor/extensions/extensions.pri
+++ b/src/compositor/extensions/extensions.pri
@@ -10,6 +10,7 @@ WAYLANDSERVERSOURCES += \
../extensions/qt-windowmanager.xml \
../3rdparty/protocol/text-input-unstable-v2.xml \
../3rdparty/protocol/viewporter.xml \
+ ../3rdparty/protocol/scaler.xml \
../3rdparty/protocol/xdg-shell-unstable-v6.xml \
../3rdparty/protocol/xdg-shell.xml \
../3rdparty/protocol/xdg-decoration-unstable-v1.xml \
@@ -30,6 +31,8 @@ HEADERS += \
extensions/qwaylandqtwindowmanager_p.h \
extensions/qwaylandviewporter.h \
extensions/qwaylandviewporter_p.h \
+ extensions/qwaylandwlscaler.h \
+ extensions/qwaylandwlscaler_p.h \
extensions/qwaylandxdgshellv5.h \
extensions/qwaylandxdgshellv5_p.h \
extensions/qwaylandxdgshellv6.h \
@@ -53,6 +56,7 @@ SOURCES += \
extensions/qwaylandtextinputmanager.cpp \
extensions/qwaylandqtwindowmanager.cpp \
extensions/qwaylandviewporter.cpp \
+ extensions/qwaylandwlscaler.cpp \
extensions/qwaylandxdgshellv5.cpp \
extensions/qwaylandxdgshellv6.cpp \
extensions/qwaylandxdgshell.cpp \
diff --git a/src/compositor/extensions/qwaylandwlscaler.cpp b/src/compositor/extensions/qwaylandwlscaler.cpp
new file mode 100644
index 00000000..e097ea3c
--- /dev/null
+++ b/src/compositor/extensions/qwaylandwlscaler.cpp
@@ -0,0 +1,274 @@
+/****************************************************************************
+**
+** 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 "qwaylandwlscaler_p.h"
+
+#include <QtWaylandCompositor/QWaylandSurface>
+#include <QtWaylandCompositor/QWaylandCompositor>
+
+#include <QtWaylandCompositor/private/qwaylandsurface_p.h>
+
+QT_BEGIN_NAMESPACE
+
+#if QT_DEPRECATED_SINCE(5, 13)
+/*!
+ \qmltype WlScaler
+ \inqmlmodule QtWayland.Compositor
+ \since 5.13
+ \brief Provides an extension for surface resizing and cropping.
+
+ The WlScaler extension provides a way for clients to resize and crop surface contents.
+
+ WlScaler corresponds to the Wayland interface, \c wl_scaler.
+
+ \c wl_scaler is a non-standard and deprecated protocol that has largely been replaced by
+ \c wp_viewporter. I.e. This extensions is only useful for supporting legacy clients.
+ \c wp_viewporter support is enabled automatically for all Qml compositors.
+
+ To provide the functionality of the extension in a compositor, create an instance of the
+ WlScaler component and add it to the list of extensions supported by the compositor:
+
+ \code
+ import QtWayland.Compositor 1.13
+
+ WaylandCompositor {
+ // ...
+ WlScaler {}
+ }
+ \endcode
+
+ \deprecated
+*/
+
+/*!
+ \class QWaylandWlScaler
+ \inmodule QtWaylandCompositor
+ \since 5.13
+ \brief Provides an extension for surface resizing and croping.
+
+ The QWaylandWlScaler extension provides a way for clients to resize and crop surface
+ contents.
+
+ QWaylandWlScaler corresponds to the Wayland interface, \c wl_scaler.
+
+ \c wl_scaler is a non-standard and deprecated protocol that has largely been replaced by
+ \c wp_viewporter. I.e. This extensions is only useful for supporting legacy clients.
+
+ \sa QWaylandViewporter
+
+ \deprecated
+*/
+
+/*!
+ Constructs a QWaylandWlScaler object.
+*/
+QWaylandWlScaler::QWaylandWlScaler()
+ : QWaylandCompositorExtensionTemplate<QWaylandWlScaler>(*new QWaylandWlScalerPrivate)
+{
+}
+
+/*!
+ * Constructs a QWaylandWlScaler object for the provided \a compositor.
+ */
+QWaylandWlScaler::QWaylandWlScaler(QWaylandCompositor *compositor)
+ : QWaylandCompositorExtensionTemplate<QWaylandWlScaler>(compositor, *new QWaylandWlScalerPrivate())
+{
+}
+
+/*!
+ Initializes the extension.
+*/
+void QWaylandWlScaler::initialize()
+{
+ Q_D(QWaylandWlScaler);
+
+ QWaylandCompositorExtensionTemplate::initialize();
+ auto *compositor = static_cast<QWaylandCompositor *>(extensionContainer());
+ if (!compositor) {
+ qWarning() << "Failed to find QWaylandCompositor when initializing QWaylandWlScaler";
+ return;
+ }
+ d->init(compositor->display(), 2);
+}
+
+/*!
+ Returns the Wayland interface for the QWaylandWlScaler.
+*/
+const wl_interface *QWaylandWlScaler::interface()
+{
+ return QWaylandWlScalerPrivate::interface();
+}
+
+void QWaylandWlScalerPrivate::scaler_destroy(Resource *resource)
+{
+ // Viewport objects are allowed ot outlive the scaler
+ wl_resource_destroy(resource->handle);
+}
+
+void QWaylandWlScalerPrivate::scaler_get_viewport(Resource *resource, uint id, wl_resource *surfaceResource)
+{
+ auto *surface = QWaylandSurface::fromResource(surfaceResource);
+ if (!surface) {
+ qWarning() << "Couldn't find surface for viewporter";
+ return;
+ }
+
+ // Note: This will only protect us not creating scalers for surfaces with wp_viewport objects
+ auto *surfacePrivate = QWaylandSurfacePrivate::get(surface);
+ if (surfacePrivate->viewport) {
+ wl_resource_post_error(resource->handle, WL_SCALER_ERROR_VIEWPORT_EXISTS,
+ "viewport already exists for surface");
+ return;
+ }
+
+ // We can't set viewport here, since it's of the new type for wp_viewporter
+// surfacePrivate->viewport = new Viewport(surface, resource->client(), id, resource->version());
+ new Viewport(surface, resource->client(), id, resource->version());
+}
+
+QWaylandWlScalerPrivate::Viewport::Viewport(QWaylandSurface *surface, wl_client *client, int id, int version)
+ : QtWaylandServer::wl_viewport(client, id, version)
+ , m_surface(surface)
+{
+ Q_ASSERT(surface);
+}
+
+//TODO: This isn't currently called
+// 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 QWaylandWlScalerPrivate::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()) {
+ //TODO: Do rounding to nearest integer
+ }
+
+ 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) {
+ //TODO: surface contents are no undefined, surface size is still valid though
+ qCDebug(qLcWaylandCompositor) << "Source set outside buffer bounds (client error)";
+ }
+}
+
+
+void QWaylandWlScalerPrivate::Viewport::viewport_destroy_resource(Resource *resource)
+{
+ Q_UNUSED(resource);
+ delete this;
+}
+
+void QWaylandWlScalerPrivate::Viewport::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 QWaylandWlScalerPrivate::Viewport::viewport_set(QtWaylandServer::wl_viewport::Resource *resource, wl_fixed_t src_x, wl_fixed_t src_y, wl_fixed_t src_width, wl_fixed_t src_height, int32_t dst_width, int32_t dst_height)
+{
+ viewport_set_source(resource, src_x, src_y, src_width, src_height);
+ viewport_set_destination(resource, dst_width, dst_height);
+}
+
+void QWaylandWlScalerPrivate::Viewport::viewport_set_source(QtWaylandServer::wl_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) {
+ qCDebug(qLcWaylandCompositor) << "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 QWaylandWlScalerPrivate::Viewport::viewport_set_destination(QtWaylandServer::wl_viewport::Resource *resource, int32_t width, int32_t height)
+{
+ Q_UNUSED(resource);
+
+ if (!m_surface) {
+ qCDebug(qLcWaylandCompositor) << "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;
+}
+#endif // QT_DEPRECATED_SINCE
+
+QT_END_NAMESPACE
diff --git a/src/compositor/extensions/qwaylandwlscaler.h b/src/compositor/extensions/qwaylandwlscaler.h
new file mode 100644
index 00000000..4ecdf396
--- /dev/null
+++ b/src/compositor/extensions/qwaylandwlscaler.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** 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 QWAYLANDWLSCALER_H
+#define QWAYLANDWLSCALER_H
+
+#include <QtWaylandCompositor/QWaylandCompositorExtension>
+
+QT_BEGIN_NAMESPACE
+
+#if QT_DEPRECATED_SINCE(5, 13)
+class QWaylandWlScalerPrivate;
+
+// TODO: We should have used the QT_DEPRECATED macro here, but for some reason
+// header file generation stops working when that's added.
+class Q_WAYLAND_COMPOSITOR_EXPORT QWaylandWlScaler
+ : public QWaylandCompositorExtensionTemplate<QWaylandWlScaler>
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QWaylandWlScaler)
+
+public:
+ explicit QWaylandWlScaler();
+ explicit QWaylandWlScaler(QWaylandCompositor *compositor);
+
+ void initialize() override;
+
+ static const struct wl_interface *interface();
+};
+#endif
+
+QT_END_NAMESPACE
+
+#endif // QWAYLANDWLSCALER_H
diff --git a/src/compositor/extensions/qwaylandwlscaler_p.h b/src/compositor/extensions/qwaylandwlscaler_p.h
new file mode 100644
index 00000000..d3c2edd7
--- /dev/null
+++ b/src/compositor/extensions/qwaylandwlscaler_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 QWAYLANDWLSCALER_P_H
+#define QWAYLANDWLSCALER_P_H
+
+#include "qwaylandwlscaler.h"
+
+#include <QtWaylandCompositor/private/qwaylandcompositorextension_p.h>
+#include <QtWaylandCompositor/private/qwayland-server-scaler.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 QWaylandWlScalerPrivate
+ : public QWaylandCompositorExtensionPrivate
+ , public QtWaylandServer::wl_scaler
+{
+ Q_DECLARE_PUBLIC(QWaylandWlScaler)
+public:
+ explicit QWaylandWlScalerPrivate() = default;
+
+protected:
+ void scaler_destroy(Resource *resource) override;
+ void scaler_get_viewport(Resource *resource, uint32_t id, wl_resource *surface) override;
+
+private:
+ class Viewport : public QtWaylandServer::wl_viewport
+ {
+ public:
+ explicit Viewport(QWaylandSurface *surface, wl_client *client, int id, int version);
+ void checkCommittedState();
+
+ protected:
+ void viewport_destroy_resource(Resource *resource) override;
+ void viewport_destroy(Resource *resource) override;
+ void viewport_set(Resource *resource, wl_fixed_t src_x, wl_fixed_t src_y, wl_fixed_t src_width, wl_fixed_t src_height, int32_t dst_width, int32_t dst_height) override;
+ void viewport_set_source(Resource *resource, wl_fixed_t x, wl_fixed_t y, wl_fixed_t width, wl_fixed_t height) override;
+ void viewport_set_destination(Resource *resource, int32_t width, int32_t height) override;
+
+ private:
+ QPointer<QWaylandSurface> m_surface = nullptr;
+ };
+};
+
+QT_END_NAMESPACE
+
+#endif // QWAYLANDWLSCALER_P_H
diff --git a/src/imports/compositor/qwaylandquickcompositorplugin.cpp b/src/imports/compositor/qwaylandquickcompositorplugin.cpp
index 1c576b6a..d0a38c58 100644
--- a/src/imports/compositor/qwaylandquickcompositorplugin.cpp
+++ b/src/imports/compositor/qwaylandquickcompositorplugin.cpp
@@ -59,6 +59,7 @@
#include <QtWaylandCompositor/QWaylandResource>
#include <QtWaylandCompositor/QWaylandQtWindowManager>
+#include <QtWaylandCompositor/QWaylandWlScaler>
#include <QtWaylandCompositor/QWaylandWlShell>
#include <QtWaylandCompositor/QWaylandTextInputManager>
#include <QtWaylandCompositor/QWaylandXdgShellV5>
@@ -76,6 +77,7 @@ QT_BEGIN_NAMESPACE
Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CONTAINER_CLASS(QWaylandQuickCompositor)
Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS(QWaylandQtWindowManager)
Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS(QWaylandIviApplication)
+Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS(QWaylandWlScaler)
Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS(QWaylandWlShell)
Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS(QWaylandXdgShellV5)
Q_COMPOSITOR_DECLARE_QUICK_EXTENSION_CLASS(QWaylandXdgShellV6)
@@ -173,6 +175,8 @@ public:
qmlRegisterUncreatableType<QWaylandXdgPopup>(uri, 1, 3, "XdgPopup", QObject::tr("Cannot create instance of XdgShellPopup"));
qmlRegisterType<QWaylandXdgDecorationManagerV1QuickExtension>(uri, 1, 3, "XdgDecorationManagerV1");
+
+ qmlRegisterType<QWaylandWlScalerQuickExtension>(uri, 1, 13, "WlScaler");
}
};
//![class decl]
diff --git a/sync.profile b/sync.profile
index 147f2782..a06caa37 100644
--- a/sync.profile
+++ b/sync.profile
@@ -58,6 +58,7 @@
"^qwayland-server-ivi-application.h",
"^qwayland-server-qt-windowmanager.h",
"^qwayland-server-qt-key-unstable-v1.h",
+ "^qwayland-server-scaler.h",
"^qwayland-server-server-buffer-extension.h",
"^qwayland-server-text-input-unstable-v2.h",
"^qwayland-server-touch-extension.h",
@@ -70,6 +71,7 @@
"^wayland-ivi-application-server-protocol.h",
"^wayland-qt-windowmanager-server-protocol.h",
"^wayland-qt-key-unstable-v1-server-protocol.h",
+ "^wayland-scaler-server-protocol.h",
"^wayland-server-buffer-extension-server-protocol.h",
"^wayland-text-input-unstable-v2-server-protocol.h",
"^wayland-viewporter-server-protocol.h",
diff --git a/tests/manual/wlscaler/main.cpp b/tests/manual/wlscaler/main.cpp
new file mode 100644
index 00000000..b836e378
--- /dev/null
+++ b/tests/manual/wlscaler/main.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** 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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui/QGuiApplication>
+#include <QtQml/QQmlApplicationEngine>
+
+int main(int argc, char* argv[])
+{
+ QGuiApplication app(argc, argv);
+ QQmlApplicationEngine engine(QUrl("qrc:/main.qml"));
+ return app.exec();
+}
diff --git a/tests/manual/wlscaler/main.qml b/tests/manual/wlscaler/main.qml
new file mode 100644
index 00000000..ddadf480
--- /dev/null
+++ b/tests/manual/wlscaler/main.qml
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** 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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+import QtQuick.Window 2.2
+import QtWayland.Compositor 1.13
+
+WaylandCompositor {
+ id: comp
+ WaylandOutput {
+ id: output
+ compositor: comp
+ sizeFollowsWindow: true
+ window: Window {
+ id: win
+ width: 500
+ height: 500
+ visible: true
+ title: "wlscaler-compositor - " + comp.socketName
+ Repeater {
+ model: shellSurfaces
+ ShellSurfaceItem {
+ shellSurface: modelData
+ onSurfaceDestroyed: shellSurfaces.remove(index);
+ autoCreatePopupItems: true
+ }
+ }
+ }
+ }
+
+ WlScaler {}
+
+ ListModel { id: shellSurfaces }
+
+ XdgShell {
+ onToplevelCreated: shellSurfaces.append({shellSurface: xdgSurface});
+ }
+
+ // Including legacy shell extensions as well, as clients using wl-scaler
+ // probably use outdated shells as well.
+
+ WlShell {
+ onWlShellSurfaceCreated: shellSurfaces.append({shellSurface: shellSurface});
+ }
+
+ XdgShellV5 {
+ onXdgSurfaceCreated: shellSurfaces.append({shellSurface: xdgSurface});
+ }
+
+ XdgShellV6 {
+ onToplevelCreated: shellSurfaces.append({shellSurface: xdgSurface});
+ }
+}
diff --git a/tests/manual/wlscaler/qml.qrc b/tests/manual/wlscaler/qml.qrc
new file mode 100644
index 00000000..6b2d0a78
--- /dev/null
+++ b/tests/manual/wlscaler/qml.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>main.qml</file>
+</qresource>
+</RCC>
diff --git a/tests/manual/wlscaler/wlscaler.pro b/tests/manual/wlscaler/wlscaler.pro
new file mode 100644
index 00000000..e4ba825f
--- /dev/null
+++ b/tests/manual/wlscaler/wlscaler.pro
@@ -0,0 +1,7 @@
+TEMPLATE = app
+
+QT += gui qml
+
+SOURCES += main.cpp
+
+RESOURCES += qml.qrc