commit:     e6a3ceac80832eabe77639793247db863b4b2a3f
Author:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
AuthorDate: Mon Apr 11 06:12:19 2022 +0000
Commit:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
CommitDate: Mon Apr 11 07:04:12 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e6a3ceac

kde-plasma/kwayland-server: Backport 5.24 branch stability fixes

Upstream commits:
a5c55b68589a8771cde0bf4ce552702da6fca41c
6dcf73adaafeaa40c05e22df5f1c10af88df362b
40364d2ee670a5a74318ef96c643762293ca95f0

KDE-bug: https://bugs.kde.org/show_bug.cgi?id=452044
KDE-bug: https://bugs.kde.org/show_bug.cgi?id=452318
Package-Manager: Portage-3.0.30, Repoman-3.0.3
Signed-off-by: Andreas Sturmlechner <asturm <AT> gentoo.org>

 ...r-5.24.4-fix-crash-on-screen-setup-change.patch | 109 +++++++++++++++++++++
 ...yland-server-5.24.4-fix-layer-shell-reset.patch |  57 +++++++++++
 ...ver-5.24.4-guard-subsurface-parent-access.patch |  44 +++++++++
 .../kwayland-server-5.24.4-r1.ebuild               |  48 +++++++++
 4 files changed, 258 insertions(+)

diff --git 
a/kde-plasma/kwayland-server/files/kwayland-server-5.24.4-fix-crash-on-screen-setup-change.patch
 
b/kde-plasma/kwayland-server/files/kwayland-server-5.24.4-fix-crash-on-screen-setup-change.patch
new file mode 100644
index 000000000000..4ddd9737e759
--- /dev/null
+++ 
b/kde-plasma/kwayland-server/files/kwayland-server-5.24.4-fix-crash-on-screen-setup-change.patch
@@ -0,0 +1,109 @@
+From 40364d2ee670a5a74318ef96c643762293ca95f0 Mon Sep 17 00:00:00 2001
+From: Vlad Zahorodnii <[email protected]>
+Date: Fri, 8 Apr 2022 12:44:33 +0300
+Subject: [PATCH] Simplify code that announces available modes and current mode
+
+If no mode has the current flag set, the first mode object will be
+announced twice.
+
+There's also no benefit from sending the current mode as last. If the
+current mode changes, the compositor will send the current_mode event,
+not the mode event.
+
+BUG: 452318
+
+
+(cherry picked from commit b40c4e3f4108b9a0be9b4f5d437e72f7c2aa3fea)
+---
+ src/server/outputdevice_v2_interface.cpp | 35 ++++++++----------------
+ 1 file changed, 11 insertions(+), 24 deletions(-)
+
+diff --git a/src/server/outputdevice_v2_interface.cpp 
b/src/server/outputdevice_v2_interface.cpp
+index 31ab16ca..9093bd2f 100644
+--- a/src/server/outputdevice_v2_interface.cpp
++++ b/src/server/outputdevice_v2_interface.cpp
+@@ -31,7 +31,7 @@ public:
+ 
+     void sendGeometry(Resource *resource);
+     wl_resource *sendNewMode(Resource *resource, OutputDeviceModeV2Interface 
*mode);
+-    void sendCurrentMode(Resource *resource, OutputDeviceModeV2Interface 
*mode);
++    void sendCurrentMode(Resource *resource);
+     void sendDone(Resource *resource);
+     void sendUuid(Resource *resource);
+     void sendEdid(Resource *resource);
+@@ -180,7 +180,7 @@ void 
OutputDeviceV2Interface::setCurrentMode(OutputDeviceModeV2Interface *mode)
+     const auto clientResources = d->resourceMap();
+     for (auto it = clientResources.begin(); it != clientResources.end(); 
++it) {
+         auto resource = *it;
+-        d->sendCurrentMode(resource, d->currentMode);
++        d->sendCurrentMode(resource);
+         d->sendDone(resource);
+     }
+     d->updateGeometry();
+@@ -257,22 +257,10 @@ void 
OutputDeviceV2InterfacePrivate::kde_output_device_v2_bind_resource(Resource
+     sendName(resource);
+     sendSerialNumber(resource);
+ 
+-    auto currentModeIt = modes.end();
+-    for (auto it = modes.begin(); it != modes.end(); ++it) {
+-        auto &mode = *it;
+-        if 
(mode->flags().testFlag(OutputDeviceModeV2Interface::ModeFlag::Current)) {
+-            // needs to be sent as last mode
+-            currentModeIt = it;
+-            continue;
+-        }
++    for (OutputDeviceModeV2Interface *mode : std::as_const(modes)) {
+         sendNewMode(resource, mode);
+     }
+-
+-    if (currentModeIt != modes.end()) {
+-        auto modeResource = sendNewMode(resource, *currentModeIt);
+-        send_current_mode(resource->handle, modeResource);
+-    }
+-
++    sendCurrentMode(resource);
+     sendUuid(resource);
+     sendEdid(resource);
+     sendEnabled(resource);
+@@ -296,9 +284,9 @@ wl_resource 
*OutputDeviceV2InterfacePrivate::sendNewMode(Resource *resource, Out
+     return modeResource->handle;
+ }
+ 
+-void OutputDeviceV2InterfacePrivate::sendCurrentMode(Resource 
*outputResource, OutputDeviceModeV2Interface *mode)
++void OutputDeviceV2InterfacePrivate::sendCurrentMode(Resource *outputResource)
+ {
+-    const auto modeResource = 
OutputDeviceModeV2InterfacePrivate::get(mode)->findResource(outputResource);
++    const auto modeResource = 
OutputDeviceModeV2InterfacePrivate::get(currentMode)->findResource(outputResource);
+     send_current_mode(outputResource->handle, modeResource->handle);
+ }
+ 
+@@ -506,12 +494,12 @@ void OutputDeviceV2Interface::setModes(const 
QList<OutputDeviceModeV2Interface *
+         d->modes << outputDeviceMode;
+         outputDeviceMode->setParent(this);
+ 
++        for (auto resource : clientResources) {
++            d->sendNewMode(resource, outputDeviceMode);
++        }
++
+         if 
(outputDeviceMode->flags().testFlag(OutputDeviceModeV2Interface::ModeFlag::Current))
 {
+             d->currentMode = outputDeviceMode;
+-        } else {
+-            for (auto resource : clientResources) {
+-                d->sendNewMode(resource, outputDeviceMode);
+-            }
+         }
+     }
+ 
+@@ -520,8 +508,7 @@ void OutputDeviceV2Interface::setModes(const 
QList<OutputDeviceModeV2Interface *
+     }
+ 
+     for (auto resource : clientResources) {
+-        d->sendNewMode(resource, d->currentMode);
+-        d->sendCurrentMode(resource, d->currentMode);
++        d->sendCurrentMode(resource);
+     }
+ 
+     qDeleteAll(oldModes.crbegin(), oldModes.crend());
+-- 
+GitLab
+

diff --git 
a/kde-plasma/kwayland-server/files/kwayland-server-5.24.4-fix-layer-shell-reset.patch
 
b/kde-plasma/kwayland-server/files/kwayland-server-5.24.4-fix-layer-shell-reset.patch
new file mode 100644
index 000000000000..a3a0b2067f5d
--- /dev/null
+++ 
b/kde-plasma/kwayland-server/files/kwayland-server-5.24.4-fix-layer-shell-reset.patch
@@ -0,0 +1,57 @@
+From 97df88c6c8af925382bb1f59b7c6ad75f28142a0 Mon Sep 17 00:00:00 2001
+From: David Edmundson <[email protected]>
+Date: Tue, 5 Apr 2022 13:26:26 +0100
+Subject: [PATCH] Fix layer shell reset
+
+In the current form any client committing multiple times without
+attaching a buffer would unset the cached state and trigger an error.
+
+It's legal (though weird) to commit multiple times before attaching a
+buffer.
+
+We should only reset the state if we commit an empty buffer after having
+committed an existing buffer. This brings us in line with XdgShell.
+
+
+(cherry picked from commit a5c55b68589a8771cde0bf4ce552702da6fca41c)
+---
+ src/server/layershell_v1_interface.cpp | 8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/src/server/layershell_v1_interface.cpp 
b/src/server/layershell_v1_interface.cpp
+index 17086334..19fcd68e 100644
+--- a/src/server/layershell_v1_interface.cpp
++++ b/src/server/layershell_v1_interface.cpp
+@@ -69,6 +69,7 @@ public:
+     bool isClosed = false;
+     bool isConfigured = false;
+     bool isCommitted = false;
++    bool firstBufferAttached = false;
+ 
+ protected:
+     void zwlr_layer_surface_v1_destroy_resource(Resource *resource) override;
+@@ -290,8 +291,10 @@ void LayerSurfaceV1InterfacePrivate::commit()
+         return;
+     }
+ 
+-    if (!surface->isMapped() && isCommitted) {
++    // detect reset
++    if (!surface->isMapped() && firstBufferAttached) {
+         isCommitted = false;
++        firstBufferAttached = false;
+         isConfigured = false;
+ 
+         current = LayerSurfaceV1State();
+@@ -303,6 +306,9 @@ void LayerSurfaceV1InterfacePrivate::commit()
+     const LayerSurfaceV1State previous = std::exchange(current, pending);
+ 
+     isCommitted = true; // Must set the committed state before emitting any 
signals.
++    if (surface->isMapped()) {
++        firstBufferAttached = true;
++    }
+ 
+     if (previous.acceptsFocus != current.acceptsFocus) {
+         Q_EMIT q->acceptsFocusChanged();
+-- 
+GitLab
+

diff --git 
a/kde-plasma/kwayland-server/files/kwayland-server-5.24.4-guard-subsurface-parent-access.patch
 
b/kde-plasma/kwayland-server/files/kwayland-server-5.24.4-guard-subsurface-parent-access.patch
new file mode 100644
index 000000000000..e40189ab2744
--- /dev/null
+++ 
b/kde-plasma/kwayland-server/files/kwayland-server-5.24.4-guard-subsurface-parent-access.patch
@@ -0,0 +1,44 @@
+From 6dcf73adaafeaa40c05e22df5f1c10af88df362b Mon Sep 17 00:00:00 2001
+From: David Edmundson <[email protected]>
+Date: Wed, 30 Mar 2022 14:57:12 +0100
+Subject: [PATCH] Guard subsurface parent access.
+
+Whilst a subsurface must have a parent at the time of creation, the
+lifespan is not guaranteed afterwards.
+
+It's a weird thing for a client to do, but we need to not crash
+afterwards.
+
+If the parent surface is destroyed we should consider the surface
+unmapped.
+
+BUG: 452044
+
+
+(cherry picked from commit 1d2424a56a13dc55aeab699a38234a7cafa091d8)
+---
+ src/server/surface_interface.cpp | 8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/src/server/surface_interface.cpp 
b/src/server/surface_interface.cpp
+index ef2584f4..8bfac95f 100644
+--- a/src/server/surface_interface.cpp
++++ b/src/server/surface_interface.cpp
+@@ -678,7 +678,13 @@ void SurfaceInterfacePrivate::commitFromCache()
+ 
+ bool SurfaceInterfacePrivate::computeEffectiveMapped() const
+ {
+-    return bufferRef && (!subSurface || 
subSurface->parentSurface()->isMapped());
++    if (!bufferRef) {
++        return false;
++    }
++    if (subSurface) {
++        return subSurface->parentSurface() && 
subSurface->parentSurface()->isMapped();
++    }
++    return true;
+ }
+ 
+ void SurfaceInterfacePrivate::updateEffectiveMapped()
+-- 
+GitLab
+

diff --git a/kde-plasma/kwayland-server/kwayland-server-5.24.4-r1.ebuild 
b/kde-plasma/kwayland-server/kwayland-server-5.24.4-r1.ebuild
new file mode 100644
index 000000000000..033b2c03dc1c
--- /dev/null
+++ b/kde-plasma/kwayland-server/kwayland-server-5.24.4-r1.ebuild
@@ -0,0 +1,48 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+ECM_QTHELP="true"
+ECM_TEST="true"
+KFMIN=5.90.0
+PVCUT=$(ver_cut 1-2)
+QTMIN=5.15.2
+inherit ecm kde.org
+
+DESCRIPTION="Wayland Server Components built on KDE Frameworks"
+HOMEPAGE="https://invent.kde.org/plasma/kwayland-server";
+
+LICENSE="LGPL-2.1"
+SLOT="5"
+KEYWORDS="~amd64 ~arm ~arm64 ~ppc64 ~riscv ~x86"
+IUSE=""
+
+# All failing, I guess we need a virtual wayland server
+RESTRICT="test"
+
+RDEPEND="
+       >=dev-libs/wayland-1.19.0
+       >=dev-qt/qtconcurrent-${QTMIN}:5
+       >=dev-qt/qtgui-${QTMIN}:5[egl]
+       >=dev-qt/qtwayland-${QTMIN}:5
+       >=kde-frameworks/kwayland-${KFMIN}:5
+       media-libs/libglvnd
+"
+DEPEND="${RDEPEND}
+       >=dev-libs/plasma-wayland-protocols-1.6.0
+       >=dev-libs/wayland-protocols-1.24
+"
+BDEPEND="
+       || (
+               >=dev-qt/qtwaylandscanner-${QTMIN}:5
+               <dev-qt/qtwayland-5.15.3:5
+       )
+       dev-util/wayland-scanner
+"
+
+PATCHES=(
+       "${FILESDIR}"/${P}-fix-layer-shell-reset.patch
+       "${FILESDIR}"/${P}-guard-subsurface-parent-access.patch # bug 452044
+       "${FILESDIR}"/${P}-fix-crash-on-screen-setup-change.patch # bug 452318
+)

Reply via email to