From 37b79a5968dc708b1afc699195ef4982e6262e6a Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Wed, 30 Oct 2019 10:33:34 -0400 Subject: [PATCH 01/15] Client: Update to new signature for startSystemMove() In a319f4a5, we temporarily disabled the override to let qt5.git update, now we add it back with the new signature. This means QWindow::startSystemMove now works for Wayland. Task-number: QTBUG-81751 Task-number: QTBUG-73011 Change-Id: I1459300d6f7fb77a9ae07bb4f5c2b80722f9b02c Reviewed-by: Pier Luigi Fiorini --- src/plugins/platforms/wayland/qwaylandwindow.cpp | 3 +-- src/plugins/platforms/wayland/qwaylandwindow_p.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index 8cc26d71ca1..7802aca6673 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -1185,9 +1185,8 @@ void QWaylandWindow::propagateSizeHints() mShellSurface->propagateSizeHints(); } -bool QtWaylandClient::QWaylandWindow::startSystemMove(const QPoint &pos) +bool QtWaylandClient::QWaylandWindow::startSystemMove() { - Q_UNUSED(pos); if (auto seat = display()->lastInputDevice()) return mShellSurface && mShellSurface->move(seat); return false; diff --git a/src/plugins/platforms/wayland/qwaylandwindow_p.h b/src/plugins/platforms/wayland/qwaylandwindow_p.h index c0328996d5d..8a22baccaf9 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow_p.h +++ b/src/plugins/platforms/wayland/qwaylandwindow_p.h @@ -196,7 +196,7 @@ public: void propagateSizeHints() override; void addAttachOffset(const QPoint point); - bool startSystemMove(const QPoint &pos); + bool startSystemMove() override; void timerEvent(QTimerEvent *event) override; void requestUpdate() override; From 84209cf53b82df6fd4085546d66ee66798d842da Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Mon, 14 Jan 2019 09:38:51 +0100 Subject: [PATCH 02/15] Client: Implement QPlatformWindow::startSystemResize Task-number: QTBUG-73011 Change-Id: Ife0d9949b4d4dd7e6f16d3de88d0cb4bf4991e09 Reviewed-by: Pier Luigi Fiorini Reviewed-by: David Edmundson --- .../shellintegration/wl-shell/qwaylandwlshellsurface.cpp | 3 ++- .../shellintegration/wl-shell/qwaylandwlshellsurface_p.h | 2 +- .../shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5.cpp | 3 ++- .../shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5_p.h | 2 +- .../shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp | 7 +++++-- .../shellintegration/xdg-shell-v6/qwaylandxdgshellv6_p.h | 2 +- .../shellintegration/xdg-shell/qwaylandxdgshell.cpp | 7 +++++-- .../shellintegration/xdg-shell/qwaylandxdgshell_p.h | 2 +- src/plugins/platforms/wayland/qwaylandshellsurface_p.h | 3 +-- src/plugins/platforms/wayland/qwaylandwindow.cpp | 7 +++++++ src/plugins/platforms/wayland/qwaylandwindow_p.h | 1 + 11 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/qwaylandwlshellsurface.cpp b/src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/qwaylandwlshellsurface.cpp index 48e14c753fe..245fec19670 100644 --- a/src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/qwaylandwlshellsurface.cpp +++ b/src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/qwaylandwlshellsurface.cpp @@ -76,10 +76,11 @@ QWaylandWlShellSurface::~QWaylandWlShellSurface() delete m_extendedWindow; } -void QWaylandWlShellSurface::resize(QWaylandInputDevice *inputDevice, Qt::Edges edges) +bool QWaylandWlShellSurface::resize(QWaylandInputDevice *inputDevice, Qt::Edges edges) { enum resize resizeEdges = convertToResizeEdges(edges); resize(inputDevice->wl_seat(), inputDevice->serial(), resizeEdges); + return true; } bool QWaylandWlShellSurface::move(QWaylandInputDevice *inputDevice) diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/qwaylandwlshellsurface_p.h b/src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/qwaylandwlshellsurface_p.h index 324c10aacae..ca7ba602c73 100644 --- a/src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/qwaylandwlshellsurface_p.h +++ b/src/plugins/platforms/wayland/plugins/shellintegration/wl-shell/qwaylandwlshellsurface_p.h @@ -76,7 +76,7 @@ public: ~QWaylandWlShellSurface() override; using QtWayland::wl_shell_surface::resize; - void resize(QWaylandInputDevice *inputDevice, Qt::Edges edges) override; + bool resize(QWaylandInputDevice *inputDevice, Qt::Edges edges) override; using QtWayland::wl_shell_surface::move; bool move(QWaylandInputDevice *inputDevice) override; diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5.cpp b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5.cpp index e8bff91935e..770fad7e853 100644 --- a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5.cpp +++ b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5.cpp @@ -82,10 +82,11 @@ QtWayland::xdg_surface_v5::resize_edge QWaylandXdgSurfaceV5::convertToResizeEdge | ((edges & Qt::RightEdge) ? resize_edge_right : 0)); } -void QWaylandXdgSurfaceV5::resize(QWaylandInputDevice *inputDevice, Qt::Edges edges) +bool QWaylandXdgSurfaceV5::resize(QWaylandInputDevice *inputDevice, Qt::Edges edges) { resize_edge resizeEdges = convertToResizeEdges(edges); resize(inputDevice->wl_seat(), inputDevice->serial(), resizeEdges); + return true; } bool QWaylandXdgSurfaceV5::move(QWaylandInputDevice *inputDevice) diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5_p.h b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5_p.h index feebee7f431..bf221079e99 100644 --- a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5_p.h +++ b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5_p.h @@ -80,7 +80,7 @@ public: using QtWayland::xdg_surface_v5::resize; static resize_edge convertToResizeEdges(Qt::Edges edges); - void resize(QWaylandInputDevice *inputDevice, Qt::Edges edges) override; + bool resize(QWaylandInputDevice *inputDevice, Qt::Edges edges) override; using QtWayland::xdg_surface_v5::move; bool move(QWaylandInputDevice *inputDevice) override; diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp index dc3cfdbfa11..c137b308bc0 100644 --- a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp +++ b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp @@ -237,11 +237,14 @@ QWaylandXdgSurfaceV6::~QWaylandXdgSurfaceV6() destroy(); } -void QWaylandXdgSurfaceV6::resize(QWaylandInputDevice *inputDevice, Qt::Edges edges) +bool QWaylandXdgSurfaceV6::resize(QWaylandInputDevice *inputDevice, Qt::Edges edges) { - Q_ASSERT(m_toplevel && m_toplevel->isInitialized()); + if (!m_toplevel || !m_toplevel->isInitialized()) + return false; + auto resizeEdges = Toplevel::convertToResizeEdges(edges); m_toplevel->resize(inputDevice->wl_seat(), inputDevice->serial(), resizeEdges); + return true; } bool QWaylandXdgSurfaceV6::move(QWaylandInputDevice *inputDevice) diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6_p.h b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6_p.h index f77a4d4baeb..757b982b9db 100644 --- a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6_p.h +++ b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6_p.h @@ -77,7 +77,7 @@ public: QWaylandXdgSurfaceV6(QWaylandXdgShellV6 *shell, ::zxdg_surface_v6 *surface, QWaylandWindow *window); ~QWaylandXdgSurfaceV6() override; - void resize(QWaylandInputDevice *inputDevice, Qt::Edges edges) override; + bool resize(QWaylandInputDevice *inputDevice, Qt::Edges edges) override; bool move(QWaylandInputDevice *inputDevice) override; bool showWindowMenu(QWaylandInputDevice *seat) override; void setTitle(const QString &title) override; diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp index bd1f5a210e5..a8e66267919 100644 --- a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp +++ b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp @@ -266,11 +266,14 @@ QWaylandXdgSurface::~QWaylandXdgSurface() destroy(); } -void QWaylandXdgSurface::resize(QWaylandInputDevice *inputDevice, Qt::Edges edges) +bool QWaylandXdgSurface::resize(QWaylandInputDevice *inputDevice, Qt::Edges edges) { - Q_ASSERT(m_toplevel && m_toplevel->isInitialized()); + if (!m_toplevel || !m_toplevel->isInitialized()) + return false; + auto resizeEdges = Toplevel::convertToResizeEdges(edges); m_toplevel->resize(inputDevice->wl_seat(), inputDevice->serial(), resizeEdges); + return true; } bool QWaylandXdgSurface::move(QWaylandInputDevice *inputDevice) diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h index 8f8682a4792..0c98be35cdc 100644 --- a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h +++ b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h @@ -80,7 +80,7 @@ public: QWaylandXdgSurface(QWaylandXdgShell *shell, ::xdg_surface *surface, QWaylandWindow *window); ~QWaylandXdgSurface() override; - void resize(QWaylandInputDevice *inputDevice, Qt::Edges edges) override; + bool resize(QWaylandInputDevice *inputDevice, Qt::Edges edges) override; bool move(QWaylandInputDevice *inputDevice) override; bool showWindowMenu(QWaylandInputDevice *seat) override; void setTitle(const QString &title) override; diff --git a/src/plugins/platforms/wayland/qwaylandshellsurface_p.h b/src/plugins/platforms/wayland/qwaylandshellsurface_p.h index f5f202d0817..989cdb81b1c 100644 --- a/src/plugins/platforms/wayland/qwaylandshellsurface_p.h +++ b/src/plugins/platforms/wayland/qwaylandshellsurface_p.h @@ -73,8 +73,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandShellSurface : public QObject public: explicit QWaylandShellSurface(QWaylandWindow *window); ~QWaylandShellSurface() override {} - virtual void resize(QWaylandInputDevice * /*inputDevice*/, Qt::Edges /*edges*/) {} - + virtual bool resize(QWaylandInputDevice *, Qt::Edges) { return false; } virtual bool move(QWaylandInputDevice *) { return false; } virtual bool showWindowMenu(QWaylandInputDevice *seat) { Q_UNUSED(seat); return false; } virtual void setTitle(const QString & /*title*/) {} diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index 7802aca6673..c8a01dc2e3f 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -1185,6 +1185,13 @@ void QWaylandWindow::propagateSizeHints() mShellSurface->propagateSizeHints(); } +bool QWaylandWindow::startSystemResize(Qt::Edges edges) +{ + if (auto *seat = display()->lastInputDevice()) + return mShellSurface && mShellSurface->resize(seat, edges); + return false; +} + bool QtWaylandClient::QWaylandWindow::startSystemMove() { if (auto seat = display()->lastInputDevice()) diff --git a/src/plugins/platforms/wayland/qwaylandwindow_p.h b/src/plugins/platforms/wayland/qwaylandwindow_p.h index 8a22baccaf9..823e4a9701b 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow_p.h +++ b/src/plugins/platforms/wayland/qwaylandwindow_p.h @@ -196,6 +196,7 @@ public: void propagateSizeHints() override; void addAttachOffset(const QPoint point); + bool startSystemResize(Qt::Edges edges) override; bool startSystemMove() override; void timerEvent(QTimerEvent *event) override; From b74257332f2d9a69cbfa2d874db43ffb14a1905f Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Tue, 11 Feb 2020 14:28:32 +0100 Subject: [PATCH 03/15] Client: Don't allow decorations for frameless windows This only fixes it for when Qt::FramelessWindowHint is set appropriately before the window is shown. [ChangeLog][QPA plugin] Windows with Qt::FramelessWindowHint no longer create zxdg_toplevel_decoration_v1, as that allowed compositors to force server-side decorations. Fixes: QTBUG-80702 Change-Id: I47a582a59f6682a57128c0c9d4e4b9a6181925a4 Reviewed-by: Pier Luigi Fiorini --- .../xdg-shell/qwaylandxdgshell.cpp | 7 ++++--- .../xdgdecorationv1/tst_xdgdecorationv1.cpp | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp index a8e66267919..56d77ec4f5a 100644 --- a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp +++ b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp @@ -56,10 +56,11 @@ QWaylandXdgSurface::Toplevel::Toplevel(QWaylandXdgSurface *xdgSurface) : QtWayland::xdg_toplevel(xdgSurface->get_toplevel()) , m_xdgSurface(xdgSurface) { - if (auto *decorationManager = m_xdgSurface->m_shell->decorationManager()) - m_decoration = decorationManager->createToplevelDecoration(object()); - QWindow *window = xdgSurface->window()->window(); + if (auto *decorationManager = m_xdgSurface->m_shell->decorationManager()) { + if (!(window->flags() & Qt::FramelessWindowHint)) + m_decoration = decorationManager->createToplevelDecoration(object()); + } requestWindowStates(window->windowStates()); requestWindowFlags(window->flags()); } diff --git a/tests/auto/wayland/xdgdecorationv1/tst_xdgdecorationv1.cpp b/tests/auto/wayland/xdgdecorationv1/tst_xdgdecorationv1.cpp index 386713cf567..391abd83bd2 100644 --- a/tests/auto/wayland/xdgdecorationv1/tst_xdgdecorationv1.cpp +++ b/tests/auto/wayland/xdgdecorationv1/tst_xdgdecorationv1.cpp @@ -153,6 +153,7 @@ private slots: void initTestCase(); void cleanup() { QTRY_VERIFY2(isClean(), qPrintable(dirtyMessage())); } void clientSidePreferredByCompositor(); + void initialFramelessWindowHint(); }; void tst_xdgdecorationv1::initTestCase() @@ -182,5 +183,22 @@ void tst_xdgdecorationv1::clientSidePreferredByCompositor() QTRY_VERIFY(!window.frameMargins().isNull()); } +void tst_xdgdecorationv1::initialFramelessWindowHint() +{ + QRasterWindow window; + window.setFlag(Qt::FramelessWindowHint, true); + window.show(); + QCOMPOSITOR_TRY_COMPARE(get()->resourceMap().size(), 1); + QCOMPOSITOR_TRY_VERIFY(xdgToplevel()); + exec([=]{ + xdgToplevel()->sendCompleteConfigure(); + }); + QCOMPOSITOR_TRY_VERIFY(xdgSurface()->m_committedConfigureSerial); + + // The client should not have create a decoration object, because that allows the compositor + // to override our decision and add server side decorations to our window. + QCOMPOSITOR_TRY_VERIFY(!toplevelDecoration()); +} + QCOMPOSITOR_TEST_MAIN(tst_xdgdecorationv1) #include "tst_xdgdecorationv1.moc" From ea3a3638e688fcc37fdbe9eb665aca12c0d8d4bd Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Mon, 20 Jan 2020 19:05:46 +0100 Subject: [PATCH 04/15] Make generated files more resilient to crashes If m_resource is not initialized when calling a send_* method it will simply crash. This change checks for it beforehand so we get a warning instead. Change-Id: I601f9070a35a1b3e595567991f7e54e9a6572c2d Reviewed-by: Johan Helsing --- src/tools/qtwaylandscanner/qtwaylandscanner.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/tools/qtwaylandscanner/qtwaylandscanner.cpp b/src/tools/qtwaylandscanner/qtwaylandscanner.cpp index 05f00beee7b..3cecb5bcfbe 100644 --- a/src/tools/qtwaylandscanner/qtwaylandscanner.cpp +++ b/src/tools/qtwaylandscanner/qtwaylandscanner.cpp @@ -906,6 +906,11 @@ bool Scanner::process() printEvent(e); printf("\n"); printf(" {\n"); + printf(" Q_ASSERT_X(m_resource, \"%s::%s\", \"Uninitialised resource\");\n", interfaceName, e.name.constData()); + printf(" if (Q_UNLIKELY(!m_resource)) {\n"); + printf(" qWarning(\"could not call %s::%s as it's not initialised\");\n", interfaceName, e.name.constData()); + printf(" return;\n"); + printf(" }\n"); printf(" send_%s(\n", e.name.constData()); printf(" m_resource->handle"); for (const WaylandArgument &a : e.arguments) { From d4027bc3fe44b4d24df56e28f35e61459e169701 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Thu, 9 Jan 2020 10:28:24 +0100 Subject: [PATCH 05/15] Move XdgOutput mocking to shared folder Change-Id: Ia4fe187d33ddfd25a87dac8567143de6466c75a2 Reviewed-by: Shawn Rutledge --- tests/auto/wayland/shared/shared.pri | 3 + tests/auto/wayland/shared/xdgoutputv1.cpp | 35 +++++++ tests/auto/wayland/shared/xdgoutputv1.h | 93 +++++++++++++++++++ .../auto/wayland/xdgoutput/tst_xdgoutput.cpp | 60 +----------- 4 files changed, 133 insertions(+), 58 deletions(-) create mode 100644 tests/auto/wayland/shared/xdgoutputv1.cpp create mode 100644 tests/auto/wayland/shared/xdgoutputv1.h diff --git a/tests/auto/wayland/shared/shared.pri b/tests/auto/wayland/shared/shared.pri index c86183b3d62..e4d368b9a0d 100644 --- a/tests/auto/wayland/shared/shared.pri +++ b/tests/auto/wayland/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/wayland/shared/xdgoutputv1.cpp b/tests/auto/wayland/shared/xdgoutputv1.cpp new file mode 100644 index 00000000000..21bfdaca54b --- /dev/null +++ b/tests/auto/wayland/shared/xdgoutputv1.cpp @@ -0,0 +1,35 @@ +/**************************************************************************** +** +** 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; + +} // namespace MockCompositor diff --git a/tests/auto/wayland/shared/xdgoutputv1.h b/tests/auto/wayland/shared/xdgoutputv1.h new file mode 100644 index 00000000000..e37b01e649b --- /dev/null +++ b/tests/auto/wayland/shared/xdgoutputv1.h @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** 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 + +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 addResource(wl_client *client, int id, int version) + { + auto *resource = add(client, id, version)->handle; + 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); + send_done(resource); + } + 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 = 2) + : QtWaylandServer::zxdg_output_manager_v1(compositor->m_display, version) + , m_version(version) + {} + int m_version = 1; // TODO: remove on libwayland upgrade + QMap 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(outputResource); + auto *xdgOutput = getXdgOutput(output); + xdgOutput->addResource(resource->client(), id, resource->version()); + } +}; + +} // namespace MockCompositor + +#endif // MOCKCOMPOSITOR_XDGOUTPUTV1_H diff --git a/tests/auto/wayland/xdgoutput/tst_xdgoutput.cpp b/tests/auto/wayland/xdgoutput/tst_xdgoutput.cpp index a628810d19c..2f28d1fe6b0 100644 --- a/tests/auto/wayland/xdgoutput/tst_xdgoutput.cpp +++ b/tests/auto/wayland/xdgoutput/tst_xdgoutput.cpp @@ -26,71 +26,15 @@ ** ****************************************************************************/ +#include "xdgoutputv1.h" #include "mockcompositor.h" + #include #include #include -#include - using namespace MockCompositor; -// TODO: move to shared folder? -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 addResource(wl_client *client, int id, int version) - { - auto *resource = add(client, id, version)->handle; - 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); - send_done(resource); - } - Output *m_output = nullptr; - QRect m_logicalGeometry; - QString m_name; - QString m_description = "This is an Xdg Output description"; - static int s_nextId; -}; - -int XdgOutputV1::s_nextId = 1; - -class XdgOutputManagerV1 : public Global, public QtWaylandServer::zxdg_output_manager_v1 -{ - Q_OBJECT -public: - explicit XdgOutputManagerV1(CoreCompositor *compositor, int version = 2) - : QtWaylandServer::zxdg_output_manager_v1(compositor->m_display, version) - , m_version(version) - {} - int m_version = 1; // TODO: remove on libwayland upgrade - QMap 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(outputResource); - auto *xdgOutput = getXdgOutput(output); - xdgOutput->addResource(resource->client(), id, resource->version()); - } -}; - class XdgOutputV1Compositor : public DefaultCompositor { public: explicit XdgOutputV1Compositor() From a23d0f458771ae52abafbe89f4d40f04a8796d0e Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Thu, 9 Jan 2020 12:20:23 +0100 Subject: [PATCH 06/15] Client tests for xdg-output unstable v1 version 3 Change-Id: If6d7547c14dfaf06532a83ab2fbda4d0198837dc Reviewed-by: Shawn Rutledge Reviewed-by: Pier Luigi Fiorini --- tests/auto/wayland/shared/coreprotocol.cpp | 8 ++++ tests/auto/wayland/shared/coreprotocol.h | 1 + tests/auto/wayland/shared/xdgoutputv1.cpp | 24 ++++++++++ tests/auto/wayland/shared/xdgoutputv1.h | 19 +++----- .../auto/wayland/xdgoutput/tst_xdgoutput.cpp | 45 ++++++++++++++++++- 5 files changed, 83 insertions(+), 14 deletions(-) diff --git a/tests/auto/wayland/shared/coreprotocol.cpp b/tests/auto/wayland/shared/coreprotocol.cpp index b0be2cb4e5b..0d98852160d 100644 --- a/tests/auto/wayland/shared/coreprotocol.cpp +++ b/tests/auto/wayland/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/wayland/shared/coreprotocol.h b/tests/auto/wayland/shared/coreprotocol.h index a12d22d3658..8d5e2d66d31 100644 --- a/tests/auto/wayland/shared/coreprotocol.h +++ b/tests/auto/wayland/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/wayland/shared/xdgoutputv1.cpp b/tests/auto/wayland/shared/xdgoutputv1.cpp index 21bfdaca54b..2b491d2ee76 100644 --- a/tests/auto/wayland/shared/xdgoutputv1.cpp +++ b/tests/auto/wayland/shared/xdgoutputv1.cpp @@ -32,4 +32,28 @@ 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/wayland/shared/xdgoutputv1.h b/tests/auto/wayland/shared/xdgoutputv1.h index e37b01e649b..85b134500a0 100644 --- a/tests/auto/wayland/shared/xdgoutputv1.h +++ b/tests/auto/wayland/shared/xdgoutputv1.h @@ -44,17 +44,12 @@ public: , m_name(QString("WL-%1").arg(s_nextId++)) {} - void addResource(wl_client *client, int id, int version) - { - auto *resource = add(client, id, version)->handle; - 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); - send_done(resource); - } + 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; @@ -66,7 +61,7 @@ class XdgOutputManagerV1 : public Global, public QtWaylandServer::zxdg_output_ma { Q_OBJECT public: - explicit XdgOutputManagerV1(CoreCompositor *compositor, int version = 2) + explicit XdgOutputManagerV1(CoreCompositor *compositor, int version = 3) : QtWaylandServer::zxdg_output_manager_v1(compositor->m_display, version) , m_version(version) {} diff --git a/tests/auto/wayland/xdgoutput/tst_xdgoutput.cpp b/tests/auto/wayland/xdgoutput/tst_xdgoutput.cpp index 2f28d1fe6b0..80429608101 100644 --- a/tests/auto/wayland/xdgoutput/tst_xdgoutput.cpp +++ b/tests/auto/wayland/xdgoutput/tst_xdgoutput.cpp @@ -40,7 +40,7 @@ public: explicit XdgOutputV1Compositor() { exec([this] { - int version = 2; // version 2 of of unstable-v1 + int version = 3; // version 3 of of unstable-v1 add(version); }); } @@ -54,11 +54,13 @@ private slots: void cleanup(); void primaryScreen(); void overrideGeometry(); + void changeGeometry(); }; void tst_xdgoutput::cleanup() { QCOMPOSITOR_COMPARE(getAll().size(), 1); // Only the default output should be left + QTRY_COMPARE(QGuiApplication::screens().size(), 1); QTRY_VERIFY2(isClean(), qPrintable(dirtyMessage())); } @@ -68,7 +70,8 @@ void tst_xdgoutput::primaryScreen() QCOMPOSITOR_TRY_COMPARE(get()->resourceMap().size(), 1); exec([=] { auto *resource = xdgOutput()->resourceMap().value(client()); - QCOMPARE(resource->version(), 2); + QCOMPARE(resource->version(), 3); + QCOMPARE(xdgOutput()->m_logicalGeometry.size(), QSize(1920, 1080)); }); auto *s = QGuiApplication::primaryScreen(); QTRY_COMPARE(s->size(), QSize(1920, 1080)); @@ -93,5 +96,43 @@ void tst_xdgoutput::overrideGeometry() exec([=] { remove(output(1)); }); } +void tst_xdgoutput::changeGeometry() +{ + auto *xdgOutput = exec([=] { + auto *output = add(); + auto *xdgOutput = get()->getXdgOutput(output); + xdgOutput->m_logicalGeometry = QRect(10, 20, 800, 1200); + return xdgOutput; + }); + + QTRY_COMPARE(QGuiApplication::screens().size(), 2); + auto *screen = QGuiApplication::screens()[1]; + QTRY_COMPARE(screen->size(), QSize(800, 1200)); + + exec([=] { + xdgOutput->sendLogicalSize(QSize(1024, 768)); + }); + + // Now we want to check that the client doesn't apply the size immediately, but waits for the + // done event. If we TRY_COMPARE immediately, we risk that the client just hasn't handled the + // logical_size request yet, so we add a screen and verify it on the client side just to give + // the client a chance to mess up. + exec([=] { add(); }); + QTRY_COMPARE(QGuiApplication::screens().size(), 3); + exec([=] { remove(output(2)); }); + + // The logical_size event should have been handled by now, but state should not have been applied yet. + QTRY_COMPARE(screen->size(), QSize(800, 1200)); + + exec([=] { + xdgOutput->m_output->sendDone(); + }); + + // Finally, the size should change + QTRY_COMPARE(screen->size(), QSize(1024, 768)); + + exec([=] { remove(output(1)); }); +} + QCOMPOSITOR_TEST_MAIN(tst_xdgoutput) #include "tst_xdgoutput.moc" From 75fd4b4669afa9c699b35cd7e0f88f402294c1be Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Tue, 11 Feb 2020 15:45:32 +0100 Subject: [PATCH 07/15] Client: Workaround for QPlatformWindow::setVisible(true) being called twice Fixes a crash. Otherwise we created two shell surface objects in some cases. Change-Id: Ieded56261061da6acf27ccabba81c8f578ca1596 Reviewed-by: Pier Luigi Fiorini --- src/plugins/platforms/wayland/qwaylandwindow.cpp | 5 +++++ src/plugins/platforms/wayland/qwaylandwindow_p.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index c8a01dc2e3f..3a335563c93 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -414,6 +414,11 @@ QPlatformScreen *QWaylandWindow::calculateScreenFromSurfaceEvents() const void QWaylandWindow::setVisible(bool visible) { + // Workaround for issue where setVisible may be called with the same value twice + if (lastVisible == visible) + return; + lastVisible = visible; + if (visible) { if (window()->type() == Qt::Popup || window()->type() == Qt::ToolTip) activePopups << this; diff --git a/src/plugins/platforms/wayland/qwaylandwindow_p.h b/src/plugins/platforms/wayland/qwaylandwindow_p.h index 823e4a9701b..352df89daf6 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow_p.h +++ b/src/plugins/platforms/wayland/qwaylandwindow_p.h @@ -270,6 +270,7 @@ private: void handleScreensChanged(); bool mInResizeFromApplyConfigure = false; + bool lastVisible = false; QRect mLastExposeGeometry; static const wl_callback_listener callbackListener; From 9b50fed3c4184ceb49f8f1a225d331bd2733db96 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Tue, 11 Feb 2020 14:46:17 +0100 Subject: [PATCH 08/15] Client: Delete decoration object when frameless window hint is added We don't want windows with FramelessWindowHint to have a zxdg_toplevel_decoration_v1 object, because that allows the compositor to force server-side window decorations. We already have code in place that avoids creating the decoration object when the window is created. However, if the frameless window hint is added after the window has been shown, then the decoration object has already been created. The protocol states that if a decoration object is destroyed, the window will switch back to a mode without any server-side decorations on the next commit... so this is what we do in this patch. Unfortunately, there is no clean way to handle the case when the hint is removed while the window is visible since the protocol explicitly forbids creating toplevel decoration objects for surfaces with committed buffers. Discussion is ongoing as to whether this should be fixed in the next version of the protocol: https://gitlab.freedesktop.org/wayland/wayland-protocols/issues/9 If we want to work around it, it is perhaps possible to destroy and create a new wl_surface, but ideally, it will be fixed in the next version of the xdg-decoration protocol and we can just wait for that. Task-number: QTBUG-80702 Change-Id: I7e76c05fc3629f1fbbba1d18482808fe588e3878 Reviewed-by: Shawn Rutledge --- .../xdg-shell/qwaylandxdgshell.cpp | 8 +++++--- .../xdgdecorationv1/tst_xdgdecorationv1.cpp | 20 +++++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp index 56d77ec4f5a..b6d23ac10a6 100644 --- a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp +++ b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp @@ -156,10 +156,12 @@ void QWaylandXdgSurface::Toplevel::xdg_toplevel_close() void QWaylandXdgSurface::Toplevel::requestWindowFlags(Qt::WindowFlags flags) { if (m_decoration) { - if (flags & Qt::FramelessWindowHint) - m_decoration->requestMode(QWaylandXdgToplevelDecorationV1::mode_client_side); - else + if (flags & Qt::FramelessWindowHint) { + delete m_decoration; + m_decoration = nullptr; + } else { m_decoration->unsetMode(); + } } } diff --git a/tests/auto/wayland/xdgdecorationv1/tst_xdgdecorationv1.cpp b/tests/auto/wayland/xdgdecorationv1/tst_xdgdecorationv1.cpp index 391abd83bd2..e02ebeff962 100644 --- a/tests/auto/wayland/xdgdecorationv1/tst_xdgdecorationv1.cpp +++ b/tests/auto/wayland/xdgdecorationv1/tst_xdgdecorationv1.cpp @@ -154,6 +154,7 @@ private slots: void cleanup() { QTRY_VERIFY2(isClean(), qPrintable(dirtyMessage())); } void clientSidePreferredByCompositor(); void initialFramelessWindowHint(); + void delayedFramelessWindowHint(); }; void tst_xdgdecorationv1::initTestCase() @@ -200,5 +201,24 @@ void tst_xdgdecorationv1::initialFramelessWindowHint() QCOMPOSITOR_TRY_VERIFY(!toplevelDecoration()); } +void tst_xdgdecorationv1::delayedFramelessWindowHint() +{ + QRasterWindow window; + window.show(); + QCOMPOSITOR_TRY_COMPARE(get()->resourceMap().size(), 1); + QCOMPOSITOR_TRY_VERIFY(xdgToplevel()); + exec([=]{ + xdgToplevel()->sendCompleteConfigure(); + }); + QCOMPOSITOR_TRY_VERIFY(xdgSurface()->m_committedConfigureSerial); + QCOMPOSITOR_TRY_VERIFY(toplevelDecoration()); + + window.setFlag(Qt::FramelessWindowHint, true); + + // The client should now destroy the decoration object, so the compositor is no longer + // able to force window decorations + QCOMPOSITOR_TRY_VERIFY(!toplevelDecoration()); +} + QCOMPOSITOR_TEST_MAIN(tst_xdgdecorationv1) #include "tst_xdgdecorationv1.moc" From f5e071ee2ce938987ab26b58c9e8a7a028196ffe Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 25 Feb 2020 15:41:37 +0100 Subject: [PATCH 09/15] Use Qt::SplitBehavior in preference to QString::SplitBehavior The Qt version was added in 5.14 "for use as eventual replacement for QString::SplitBehavior." Move another step closer to that goal. Change-Id: Ie19f7580d75694982ac26c08ad5aabb73d830494 Reviewed-by: Johan Helsing --- src/plugins/platforms/wayland/qwaylandwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index 3a335563c93..5830c1368c2 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -157,7 +157,7 @@ void QWaylandWindow::initWindow() QFileInfo fi = QCoreApplication::instance()->applicationFilePath(); QStringList domainName = QCoreApplication::instance()->organizationDomain().split(QLatin1Char('.'), - QString::SkipEmptyParts); + Qt::SkipEmptyParts); if (domainName.isEmpty()) { mShellSurface->setAppId(fi.baseName()); From ecd7d9658d340921de7c312b87cd9ac692c2016f Mon Sep 17 00:00:00 2001 From: Samuli Piippo Date: Wed, 26 Feb 2020 16:14:30 +0200 Subject: [PATCH 10/15] Test the EGL wayland platform extensions before using them The Khronos headers may be recent enough to have the ifdefs but implementation might still be missing on some platforms. Don't use the extensions unless the configure test passes. Change-Id: I23129115729567fa92bc23da099d27df598fc206 Reviewed-by: James McDonnell --- src/plugins/platforms/wayland/configure.json | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/wayland/configure.json b/src/plugins/platforms/wayland/configure.json index 9b8b4345741..73f233622be 100644 --- a/src/plugins/platforms/wayland/configure.json +++ b/src/plugins/platforms/wayland/configure.json @@ -231,9 +231,14 @@ "condition": "features.wayland-client", "output": [ "privateFeature" ] }, + "egl-extension-platform-wayland": { + "label": "EGL wayland platform extension", + "condition": "features.wayland-client && features.opengl && features.egl && tests.egl_1_5-wayland", + "output": [ "privateFeature" ] + }, "wayland-egl": { "label": "EGL", - "condition": "features.wayland-client && features.opengl && features.egl && libs.wayland-egl && (!config.qnx || tests.egl_1_5-wayland)", + "condition": "features.wayland-client && features.opengl && features.egl && libs.wayland-egl && (!config.qnx || features.egl-extension-platform-wayland)", "output": [ "privateFeature" ] }, "wayland-brcm": { @@ -253,7 +258,7 @@ }, "wayland-drm-egl-server-buffer": { "label": "DRM EGL", - "condition": "features.wayland-client && features.opengl && features.egl && tests.drm-egl-server && (!config.qnx || tests.egl_1_5-wayland)", + "condition": "features.wayland-client && features.opengl && features.egl && tests.drm-egl-server && (!config.qnx || features.egl-extension-platform-wayland)", "output": [ "privateFeature" ] }, "wayland-libhybris-egl-server-buffer": { From ef26bf8ff54f60147f27e1d5caa6afc072f5d4e1 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 10 Mar 2020 13:08:07 +0100 Subject: [PATCH 11/15] Fix incomplete QPainterPath Fixes: QTBUG-82789 Change-Id: I8cab4edfac68aec81bc86cfdf022c3600f7a32a8 Reviewed-by: Jarek Kobus --- .../platforms/wayland/plugins/decorations/bradient/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/platforms/wayland/plugins/decorations/bradient/main.cpp b/src/plugins/platforms/wayland/plugins/decorations/bradient/main.cpp index e8e35775e58..e75fda3ced5 100644 --- a/src/plugins/platforms/wayland/plugins/decorations/bradient/main.cpp +++ b/src/plugins/platforms/wayland/plugins/decorations/bradient/main.cpp @@ -40,6 +40,7 @@ #include #include +#include #include #include From c78ea023d4ea4c90c5f02ecb0f60179e3a5927e2 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 17 Mar 2020 10:05:25 +0100 Subject: [PATCH 12/15] Fix invalid json in qt_attribution.json Amends 4d844d364045977 Change-Id: Ifec3dc5d8698229cc0c2f375eebd5a4ebfd62d35 Reviewed-by: Johan Helsing --- src/3rdparty/wayland/protocols/qt_attribution.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/3rdparty/wayland/protocols/qt_attribution.json b/src/3rdparty/wayland/protocols/qt_attribution.json index ddda0e9716c..87f2422761d 100644 --- a/src/3rdparty/wayland/protocols/qt_attribution.json +++ b/src/3rdparty/wayland/protocols/qt_attribution.json @@ -103,7 +103,7 @@ Copyright (c) 2013 BMW Car IT GmbH" "LicenseId": "MIT", "License": "MIT License", "LicenseFile": "MIT_LICENSE.txt", - "Copyright": "Copyright 2014 © Stephen "Lyude" Chandler Paul + "Copyright": "Copyright 2014 © Stephen \"Lyude\" Chandler Paul Copyright 2015-2016 © Red Hat, Inc." }, From 592cfb27f8d52ae33bbd0bec34ca9a55255ebf88 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Tue, 23 Jul 2019 08:44:46 +0200 Subject: [PATCH 13/15] Client: Remove recursion in data offer retrieval A loop functions just as well is more readable and uses less stack memory. Change-Id: I6f6c6b7b8047c42080fb8b9e0bc3eae96f8872ab Reviewed-by: David Faure Reviewed-by: Johan Helsing (cherry picked from commit 97c1e5337e7e214c4ada98e1cc360b7e674996aa) Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../platforms/wayland/qwaylanddataoffer.cpp | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/plugins/platforms/wayland/qwaylanddataoffer.cpp b/src/plugins/platforms/wayland/qwaylanddataoffer.cpp index 4c06277fe87..2297e8a16d6 100644 --- a/src/plugins/platforms/wayland/qwaylanddataoffer.cpp +++ b/src/plugins/platforms/wayland/qwaylanddataoffer.cpp @@ -170,24 +170,27 @@ int QWaylandMimeData::readData(int fd, QByteArray &data) const timeout.tv_sec = 1; timeout.tv_usec = 0; - int ready = select(FD_SETSIZE, &readset, nullptr, nullptr, &timeout); - if (ready < 0) { - qWarning() << "QWaylandDataOffer: select() failed"; - return -1; - } else if (ready == 0) { - qWarning("QWaylandDataOffer: timeout reading from pipe"); - return -1; - } else { - char buf[4096]; - int n = QT_READ(fd, buf, sizeof buf); + Q_FOREVER { + int ready = select(FD_SETSIZE, &readset, nullptr, nullptr, &timeout); + if (ready < 0) { + qWarning() << "QWaylandDataOffer: select() failed"; + return -1; + } else if (ready == 0) { + qWarning("QWaylandDataOffer: timeout reading from pipe"); + return -1; + } else { + char buf[4096]; + int n = QT_READ(fd, buf, sizeof buf); - if (n > 0) { - data.append(buf, n); - n = readData(fd, data); - } else if (n < 0) { - qWarning("QWaylandDataOffer: read() failed"); + if (n < 0) { + qWarning("QWaylandDataOffer: read() failed"); + return -1; + } else if (n == 0) { + return 0; + } else if (n > 0) { + data.append(buf, n); + } } - return n; } } From 88eb97dd0abeef7d5112f66de00e84b23a9af6c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Tue, 24 Mar 2020 10:02:13 +0100 Subject: [PATCH 14/15] Update connects to QSocketNotifier::activated The int-overload will in some cases truncate the descriptor. So it's being replaced. On Linux it won't truncate, so the slot can stay as int, but we still update which signal to connect to. Task-number: QTBUG-70441 Change-Id: I516a453c381e8d29464febabfd69c788e58db5fe Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/wayland/qwaylandintegration.cpp | 2 +- tests/auto/wayland/client/tst_client.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/wayland/qwaylandintegration.cpp b/src/plugins/platforms/wayland/qwaylandintegration.cpp index 85c1990b612..e3b86ee9fd6 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.cpp +++ b/src/plugins/platforms/wayland/qwaylandintegration.cpp @@ -198,7 +198,7 @@ void QWaylandIntegration::initialize() int fd = wl_display_get_fd(mDisplay->wl_display()); QSocketNotifier *sn = new QSocketNotifier(fd, QSocketNotifier::Read, mDisplay.data()); - QObject::connect(sn, SIGNAL(activated(int)), mDisplay.data(), SLOT(flushRequests())); + QObject::connect(sn, SIGNAL(activated(QSocketDescriptor)), mDisplay.data(), SLOT(flushRequests())); // Qt does not support running with no screens mDisplay->ensureScreen(); diff --git a/tests/auto/wayland/client/tst_client.cpp b/tests/auto/wayland/client/tst_client.cpp index 499a93a1dde..42e23b54ce9 100644 --- a/tests/auto/wayland/client/tst_client.cpp +++ b/tests/auto/wayland/client/tst_client.cpp @@ -149,7 +149,7 @@ public: : compositor(c) { QSocketNotifier *notifier = new QSocketNotifier(compositor->waylandFileDescriptor(), QSocketNotifier::Read, this); - connect(notifier, SIGNAL(activated(int)), this, SLOT(processWaylandEvents())); + connect(notifier, SIGNAL(activated(QSocketDescriptor)), this, SLOT(processWaylandEvents())); // connect to the event dispatcher to make sure to flush out the outgoing message queue connect(QCoreApplication::eventDispatcher(), &QAbstractEventDispatcher::awake, this, &tst_WaylandClient::processWaylandEvents); connect(QCoreApplication::eventDispatcher(), &QAbstractEventDispatcher::aboutToBlock, this, &tst_WaylandClient::processWaylandEvents); From 849d741b218545a16d90efa9d9bcff79b62eacfb Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 21 Apr 2020 09:12:16 -0700 Subject: [PATCH 15/15] Fix GCC 9 warning about redundant std::move use qwaylandcursor.cpp:254:21: warning: redundant move in return statement [-Wredundant-move] Change-Id: I9709abb1c3734e10a7defffd1607e1b3ed279d32 Reviewed-by: David Edmundson --- src/plugins/platforms/wayland/qwaylandcursor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/wayland/qwaylandcursor.cpp b/src/plugins/platforms/wayland/qwaylandcursor.cpp index 1d3d88bea3a..3263b17f1e3 100644 --- a/src/plugins/platforms/wayland/qwaylandcursor.cpp +++ b/src/plugins/platforms/wayland/qwaylandcursor.cpp @@ -251,7 +251,7 @@ QSharedPointer QWaylandCursor::cursorBitmapBuffer(QWaylandDispla const QImage &img = cursor->pixmap().toImage(); QSharedPointer buffer(new QWaylandShmBuffer(display, img.size(), img.format())); memcpy(buffer->image()->bits(), img.bits(), size_t(img.sizeInBytes())); - return std::move(buffer); + return buffer; } void QWaylandCursor::changeCursor(QCursor *cursor, QWindow *window)