summaryrefslogtreecommitdiffstats
path: root/tests/auto/client/shared
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2020-04-27 08:51:53 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-04-29 13:51:58 +0200
commit6319bc72e2dc63175ca797ee3042955f852e008f (patch)
treec9c1c71c43394a4cd2f0f6a75df8ba6f3a2550f3 /tests/auto/client/shared
parent00c8a79da0c80616f18329cdfc61338a2c1af7df (diff)
parent28e7d940c42c47cf039522709883ae3de9f4fb88 (diff)
Merge remote-tracking branch 'origin/5.15' into dev
Conflicts: tests/auto/client/xdgoutput/tst_xdgoutput.cpp Regenerated CMake projects. Removed duplicate wayland source in tests/auto/client/xdgoutput/xdgoutput.pro. It's still referenced via the included shared.pri file. Regenerated the CMake project to adapt to that. Otherwise the CMake project fails to configure due to duplicate rules with a error like the one below CMake Error at src/compositor/Qt6WaylandCompositorMacros.cmake:13 (add_custom_command): Attempt to add a custom rule to output tests/auto/client/xdgoutput/wayland-xdg-output-unstable-v1-server-protocol.h.rule Also use a workaround fix for configuring CMake standalone tests due to regression introduced by dd7e40b1086020f6a054957f4972720cd684 in qtbase. Change-Id: Ib364b851a1fa828c153efbf8653c9e4ef5e618cd
Diffstat (limited to 'tests/auto/client/shared')
-rw-r--r--tests/auto/client/shared/coreprotocol.cpp8
-rw-r--r--tests/auto/client/shared/coreprotocol.h1
-rw-r--r--tests/auto/client/shared/shared.pri3
-rw-r--r--tests/auto/client/shared/xdgoutputv1.cpp59
-rw-r--r--tests/auto/client/shared/xdgoutputv1.h88
5 files changed, 159 insertions, 0 deletions
diff --git a/tests/auto/client/shared/coreprotocol.cpp b/tests/auto/client/shared/coreprotocol.cpp
index b0be2cb4e..0d9885216 100644
--- a/tests/auto/client/shared/coreprotocol.cpp
+++ b/tests/auto/client/shared/coreprotocol.cpp
@@ -158,6 +158,14 @@ void Output::sendScale(Resource *resource)
wl_output::send_scale(resource->handle, m_data.scale);
}
+void Output::sendDone(wl_client *client)
+{
+ Q_ASSERT(m_version >= WL_OUTPUT_DONE_SINCE_VERSION);
+ auto resources = resourceMap().values(client);
+ for (auto *r : resources)
+ wl_output::send_done(r->handle);
+}
+
void Output::sendDone()
{
Q_ASSERT(m_version >= WL_OUTPUT_DONE_SINCE_VERSION);
diff --git a/tests/auto/client/shared/coreprotocol.h b/tests/auto/client/shared/coreprotocol.h
index a12d22d36..8d5e2d66d 100644
--- a/tests/auto/client/shared/coreprotocol.h
+++ b/tests/auto/client/shared/coreprotocol.h
@@ -245,6 +245,7 @@ public:
void sendScale(int factor);
void sendScale(Resource *resource); // Sends current scale to only one client
+ void sendDone(wl_client *client);
void sendDone();
int scale() const { return m_data.scale; }
diff --git a/tests/auto/client/shared/shared.pri b/tests/auto/client/shared/shared.pri
index b59cdc481..97202e787 100644
--- a/tests/auto/client/shared/shared.pri
+++ b/tests/auto/client/shared/shared.pri
@@ -4,6 +4,7 @@ QMAKE_USE += wayland-server
WAYLANDSERVERSOURCES += \
$$PWD/../../../../src/3rdparty/protocol/wayland.xml \
+ $$PWD/../../../../src/3rdparty/protocol/xdg-output-unstable-v1.xml \
$$PWD/../../../../src/3rdparty/protocol/xdg-shell.xml \
$$PWD/../../../../src/3rdparty/protocol/text-input-unstable-v2.xml
@@ -14,6 +15,7 @@ HEADERS += \
$$PWD/coreprotocol.h \
$$PWD/datadevice.h \
$$PWD/mockcompositor.h \
+ $$PWD/xdgoutputv1.h \
$$PWD/xdgshell.h \
$$PWD/textinput.h
@@ -22,5 +24,6 @@ SOURCES += \
$$PWD/coreprotocol.cpp \
$$PWD/datadevice.cpp \
$$PWD/mockcompositor.cpp \
+ $$PWD/xdgoutputv1.cpp \
$$PWD/xdgshell.cpp \
$$PWD/textinput.cpp
diff --git a/tests/auto/client/shared/xdgoutputv1.cpp b/tests/auto/client/shared/xdgoutputv1.cpp
new file mode 100644
index 000000000..2b491d2ee
--- /dev/null
+++ b/tests/auto/client/shared/xdgoutputv1.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "xdgoutputv1.h"
+
+namespace MockCompositor {
+
+int XdgOutputV1::s_nextId = 1;
+
+void XdgOutputV1::sendLogicalSize(const QSize &size)
+{
+ m_logicalGeometry.setSize(size);
+ for (auto *resource : resourceMap())
+ zxdg_output_v1::send_logical_size(resource->handle, size.width(), size.height());
+}
+
+void XdgOutputV1::addResource(wl_client *client, int id, int version)
+{
+ auto *resource = add(client, id, version)->handle;
+ zxdg_output_v1::send_logical_size(resource, m_logicalGeometry.width(), m_logicalGeometry.height());
+ send_logical_position(resource, m_logicalGeometry.x(), m_logicalGeometry.y());
+ if (version >= ZXDG_OUTPUT_V1_NAME_SINCE_VERSION)
+ send_name(resource, m_name);
+ if (version >= ZXDG_OUTPUT_V1_DESCRIPTION_SINCE_VERSION)
+ send_description(resource, m_description);
+
+ if (version < 3) // zxdg_output_v1.done has been deprecated
+ zxdg_output_v1::send_done(resource);
+ else {
+ m_output->sendDone(client);
+ }
+}
+
+} // namespace MockCompositor
diff --git a/tests/auto/client/shared/xdgoutputv1.h b/tests/auto/client/shared/xdgoutputv1.h
new file mode 100644
index 000000000..85b134500
--- /dev/null
+++ b/tests/auto/client/shared/xdgoutputv1.h
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MOCKCOMPOSITOR_XDGOUTPUTV1_H
+#define MOCKCOMPOSITOR_XDGOUTPUTV1_H
+
+#include "coreprotocol.h"
+
+#include <qwayland-server-xdg-output-unstable-v1.h>
+
+namespace MockCompositor {
+
+class XdgOutputV1 : public QObject, public QtWaylandServer::zxdg_output_v1
+{
+public:
+ explicit XdgOutputV1(Output *output)
+ : m_output(output)
+ , m_logicalGeometry(m_output->m_data.position, QSize(m_output->m_data.mode.resolution / m_output->m_data.scale))
+ , m_name(QString("WL-%1").arg(s_nextId++))
+ {}
+
+ void send_logical_size(int32_t width, int32_t height) = delete;
+ void sendLogicalSize(const QSize &size);
+
+ void send_done() = delete; // zxdg_output_v1.done has been deprecated (in protocol version 3)
+
+ void addResource(wl_client *client, int id, int version);
+ Output *m_output = nullptr;
+ QRect m_logicalGeometry;
+ QString m_name;
+ QString m_description = "This is an Xdg Output description";
+ static int s_nextId;
+};
+
+class XdgOutputManagerV1 : public Global, public QtWaylandServer::zxdg_output_manager_v1
+{
+ Q_OBJECT
+public:
+ explicit XdgOutputManagerV1(CoreCompositor *compositor, int version = 3)
+ : QtWaylandServer::zxdg_output_manager_v1(compositor->m_display, version)
+ , m_version(version)
+ {}
+ int m_version = 1; // TODO: remove on libwayland upgrade
+ QMap<Output *, XdgOutputV1 *> m_xdgOutputs;
+ XdgOutputV1 *getXdgOutput(Output *output)
+ {
+ if (auto *xdgOutput = m_xdgOutputs.value(output))
+ return xdgOutput;
+ return m_xdgOutputs[output] = new XdgOutputV1(output); // TODO: free memory
+ }
+
+protected:
+ void zxdg_output_manager_v1_get_xdg_output(Resource *resource, uint32_t id, wl_resource *outputResource) override
+ {
+ auto *output = fromResource<Output>(outputResource);
+ auto *xdgOutput = getXdgOutput(output);
+ xdgOutput->addResource(resource->client(), id, resource->version());
+ }
+};
+
+} // namespace MockCompositor
+
+#endif // MOCKCOMPOSITOR_XDGOUTPUTV1_H