commit:     0064478e953065c8b786ed6ef52dbe6132cfdb2a
Author:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 27 07:26:45 2023 +0000
Commit:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
CommitDate: Tue Jun 27 11:25:39 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=0064478e

kde-plasma/kwin: Backport various 5.27.7 fixes

KDE-bug: https://bugs.kde.org/show_bug.cgi?id=469625
KDE-bug: https://bugs.kde.org/show_bug.cgi?id=471285
KDE-bug: https://bugs.kde.org/show_bug.cgi?id=444665
KDE-bug: https://bugs.kde.org/show_bug.cgi?id=471139

Signed-off-by: Andreas Sturmlechner <asturm <AT> gentoo.org>

 .../files/kwin-5.27.6-fix-crash-after-login.patch  |  36 +++++
 .../kwin-5.27.6-fix-crash-click-on-tooltip.patch   |  34 +++++
 ....6-fix-effect-to-only-apply-behind-window.patch |  98 ++++++++++++++
 ...7.6-fix-locale1-use-after-free-xkb_keymap.patch |  57 ++++++++
 kde-plasma/kwin/kwin-5.27.6-r1.ebuild              | 145 +++++++++++++++++++++
 5 files changed, 370 insertions(+)

diff --git a/kde-plasma/kwin/files/kwin-5.27.6-fix-crash-after-login.patch 
b/kde-plasma/kwin/files/kwin-5.27.6-fix-crash-after-login.patch
new file mode 100644
index 000000000000..130bcca50cdf
--- /dev/null
+++ b/kde-plasma/kwin/files/kwin-5.27.6-fix-crash-after-login.patch
@@ -0,0 +1,36 @@
+From ed916ff21629f3e91ee987552d778b1a65d66702 Mon Sep 17 00:00:00 2001
+From: David Edmundson <[email protected]>
+Date: Sat, 17 Jun 2023 13:01:43 +0100
+Subject: [PATCH] effects: Make OpenGL context current before deleting
+ framebuffer
+
+When we delete a window we unredirect, when we unredirect, we delete the
+framebuffer which requires an openGL context.
+
+handleWindowDeleted is the entry point from workspace events to effects
+code, so it's made current here.
+
+BUG: 444665
+BUG: 471139
+
+
+(cherry picked from commit c5a29b4b66c001c49c5bcf9aa9250d8322eefbbd)
+---
+ src/libkwineffects/kwinoffscreeneffect.cpp | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/src/libkwineffects/kwinoffscreeneffect.cpp 
b/src/libkwineffects/kwinoffscreeneffect.cpp
+index 82abea675c1..d1bd2921576 100644
+--- a/src/libkwineffects/kwinoffscreeneffect.cpp
++++ b/src/libkwineffects/kwinoffscreeneffect.cpp
+@@ -238,6 +238,7 @@ void OffscreenEffect::handleWindowDamaged(EffectWindow 
*window)
+ 
+ void OffscreenEffect::handleWindowDeleted(EffectWindow *window)
+ {
++    effects->makeOpenGLContextCurrent();
+     unredirect(window);
+ }
+ 
+-- 
+GitLab
+

diff --git a/kde-plasma/kwin/files/kwin-5.27.6-fix-crash-click-on-tooltip.patch 
b/kde-plasma/kwin/files/kwin-5.27.6-fix-crash-click-on-tooltip.patch
new file mode 100644
index 000000000000..b8384cd9abed
--- /dev/null
+++ b/kde-plasma/kwin/files/kwin-5.27.6-fix-crash-click-on-tooltip.patch
@@ -0,0 +1,34 @@
+From 21d193506851e0727860927ab289869732b06102 Mon Sep 17 00:00:00 2001
+From: Xaver Hugl <[email protected]>
+Date: Wed, 21 Jun 2023 12:39:15 +0200
+Subject: [PATCH] input: don't crash if the internal handle is nullptr
+
+Pointer focus can stay on a closed tooltip while focus updates are blocked,
+so this needs to be checked for
+
+BUG: 471285
+
+
+(cherry picked from commit c25aaa2c9fbf8ec10f1ba16fecd4b31704fdaf0c)
+---
+ src/input.cpp | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/input.cpp b/src/input.cpp
+index b4940f123ad..d3d32020580 100644
+--- a/src/input.cpp
++++ b/src/input.cpp
+@@ -1185,6 +1185,10 @@ class InternalWindowEventFilter : public 
InputEventFilter
+             return false;
+         }
+         QWindow *internal = static_cast<InternalWindow 
*>(input()->pointer()->focus())->handle();
++        if (!internal) {
++            // the handle can be nullptr if the tooltip gets closed while 
focus updates are blocked
++            return false;
++        }
+         QMouseEvent mouseEvent(event->type(),
+                                event->pos() - internal->position(),
+                                event->globalPos(),
+-- 
+GitLab
+

diff --git 
a/kde-plasma/kwin/files/kwin-5.27.6-fix-effect-to-only-apply-behind-window.patch
 
b/kde-plasma/kwin/files/kwin-5.27.6-fix-effect-to-only-apply-behind-window.patch
new file mode 100644
index 000000000000..b2c8c026316b
--- /dev/null
+++ 
b/kde-plasma/kwin/files/kwin-5.27.6-fix-effect-to-only-apply-behind-window.patch
@@ -0,0 +1,98 @@
+From 69151896615ec272d78860b2ef42e61657f435f1 Mon Sep 17 00:00:00 2001
+From: Xaver Hugl <[email protected]>
+Date: Thu, 22 Jun 2023 11:35:27 +0200
+Subject: [PATCH] plugins/backgroundcontrast,blur: ensure the effect is only
+ applied behind the window
+
+When a window is translated and/or scaled, the effect must be strictly behind 
the
+window and never beyond it, as that is very noticeable.
+
+BUG: 469625
+(cherry picked from commit cd94cdaf3a04227073c3f99833139a712d195d3a)
+---
+ src/effects/backgroundcontrast/contrast.cpp | 22 +++++++++++++--------
+ src/effects/blur/blur.cpp                   | 19 ++++++++++++------
+ 2 files changed, 27 insertions(+), 14 deletions(-)
+
+diff --git a/src/effects/backgroundcontrast/contrast.cpp 
b/src/effects/backgroundcontrast/contrast.cpp
+index 8921a481e3f..66dffd99a94 100644
+--- a/src/effects/backgroundcontrast/contrast.cpp
++++ b/src/effects/backgroundcontrast/contrast.cpp
+@@ -382,25 +382,31 @@ void ContrastEffect::drawWindow(EffectWindow *w, int 
mask, const QRegion &region
+         const QRect screen = effects->renderTargetRect();
+         QRegion shape = region & 
contrastRegion(w).translated(w->pos().toPoint()) & screen;
+ 
+-        // let's do the evil parts - someone wants to blur behind a 
transformed window
++        // let's do the evil parts - someone wants to contrast behind a 
transformed window
+         const bool translated = data.xTranslation() || data.yTranslation();
+         const bool scaled = data.xScale() != 1 || data.yScale() != 1;
+         if (scaled) {
+             QPoint pt = shape.boundingRect().topLeft();
+             QRegion scaledShape;
+             for (QRect r : shape) {
+-                r.moveTo(pt.x() + (r.x() - pt.x()) * data.xScale() + 
data.xTranslation(),
+-                         pt.y() + (r.y() - pt.y()) * data.yScale() + 
data.yTranslation());
+-                r.setWidth(std::ceil(r.width() * data.xScale()));
+-                r.setHeight(std::ceil(r.height() * data.yScale()));
+-                scaledShape |= r;
++                const QPointF topLeft(pt.x() + (r.x() - pt.x()) * 
data.xScale() + data.xTranslation(),
++                                      pt.y() + (r.y() - pt.y()) * 
data.yScale() + data.yTranslation());
++                const QPoint bottomRight(std::floor(topLeft.x() + r.width() * 
data.xScale()) - 1,
++                                         std::floor(topLeft.y() + r.height() 
* data.yScale()) - 1);
++                scaledShape |= QRect(QPoint(std::floor(topLeft.x()), 
std::floor(topLeft.y())), bottomRight);
+             }
+             shape = scaledShape & region;
+ 
+             // Only translated, not scaled
+         } else if (translated) {
+-            shape = shape.translated(data.xTranslation(), 
data.yTranslation());
+-            shape = shape & region;
++            QRegion translated;
++            for (QRect r : shape) {
++                const QRectF t = QRectF(r).translated(data.xTranslation(), 
data.yTranslation());
++                const QPoint topLeft(std::ceil(t.x()), std::ceil(t.y()));
++                const QPoint bottomRight(std::floor(t.x() + t.width() - 1), 
std::floor(t.y() + t.height() - 1));
++                translated |= QRect(topLeft, bottomRight);
++            }
++            shape = translated & region;
+         }
+ 
+         if (!shape.isEmpty()) {
+diff --git a/src/effects/blur/blur.cpp b/src/effects/blur/blur.cpp
+index ec08e6cc968..1b6d9997c98 100644
+--- a/src/effects/blur/blur.cpp
++++ b/src/effects/blur/blur.cpp
+@@ -625,17 +625,24 @@ void BlurEffect::drawWindow(EffectWindow *w, int mask, 
const QRegion &region, Wi
+             QPoint pt = shape.boundingRect().topLeft();
+             QRegion scaledShape;
+             for (QRect r : shape) {
+-                r.moveTo(pt.x() + (r.x() - pt.x()) * data.xScale() + 
data.xTranslation(),
+-                         pt.y() + (r.y() - pt.y()) * data.yScale() + 
data.yTranslation());
+-                r.setWidth(std::ceil(r.width() * data.xScale()));
+-                r.setHeight(std::ceil(r.height() * data.yScale()));
+-                scaledShape |= r;
++                const QPointF topLeft(pt.x() + (r.x() - pt.x()) * 
data.xScale() + data.xTranslation(),
++                                      pt.y() + (r.y() - pt.y()) * 
data.yScale() + data.yTranslation());
++                const QPoint bottomRight(std::floor(topLeft.x() + r.width() * 
data.xScale()) - 1,
++                                         std::floor(topLeft.y() + r.height() 
* data.yScale()) - 1);
++                scaledShape |= QRect(QPoint(std::floor(topLeft.x()), 
std::floor(topLeft.y())), bottomRight);
+             }
+             shape = scaledShape;
+ 
+             // Only translated, not scaled
+         } else if (translated) {
+-            shape = shape.translated(data.xTranslation(), 
data.yTranslation());
++            QRegion translated;
++            for (QRect r : shape) {
++                const QRectF t = QRectF(r).translated(data.xTranslation(), 
data.yTranslation());
++                const QPoint topLeft(std::ceil(t.x()), std::ceil(t.y()));
++                const QPoint bottomRight(std::floor(t.x() + t.width() - 1), 
std::floor(t.y() + t.height() - 1));
++                translated |= QRect(topLeft, bottomRight);
++            }
++            shape = translated;
+         }
+ 
+         EffectWindow *modal = w->transientFor();
+-- 
+GitLab
+

diff --git 
a/kde-plasma/kwin/files/kwin-5.27.6-fix-locale1-use-after-free-xkb_keymap.patch 
b/kde-plasma/kwin/files/kwin-5.27.6-fix-locale1-use-after-free-xkb_keymap.patch
new file mode 100644
index 000000000000..6fcd3af4cfda
--- /dev/null
+++ 
b/kde-plasma/kwin/files/kwin-5.27.6-fix-locale1-use-after-free-xkb_keymap.patch
@@ -0,0 +1,57 @@
+From 2d09d7961b09693aa56a99eb3ba9680e84192936 Mon Sep 17 00:00:00 2001
+From: Aleksei Bavshin <[email protected]>
+Date: Fri, 23 Jun 2023 03:14:09 -0700
+Subject: [PATCH] locale1: fix use-after-free in xkb_keymap creation
+
+qPrintable creates temporary objects that are destroyed before
+`xkb_keymap_new_from_names` is called. It's highly likely that the data
+we pass to xkbcommon will be overwritten by random data by that point.
+
+Fix that by storing values as QByteArrays just like
+`Xkb::loadKeymapFromConfig` does.
+
+
+(cherry picked from commit f70bda9f6de2d38ae3859afb3f96cad1e9c47590)
+---
+ src/xkb.cpp | 22 +++++++++++++++-------
+ 1 file changed, 15 insertions(+), 7 deletions(-)
+
+diff --git a/src/xkb.cpp b/src/xkb.cpp
+index 4a5f72d940a..b3bb5e77252 100644
+--- a/src/xkb.cpp
++++ b/src/xkb.cpp
+@@ -250,16 +250,24 @@ xkb_keymap *Xkb::loadKeymapFromLocale1()
+ {
+     OrgFreedesktopDBusPropertiesInterface 
locale1Properties(s_locale1Interface, "/org/freedesktop/locale1", 
QDBusConnection::systemBus(), this);
+     const QVariantMap properties = 
locale1Properties.GetAll(s_locale1Interface);
+-    const QString layouts = properties["X11Layout"].toString();
++
++    const QByteArray model = properties["X11Model"].toByteArray();
++    const QByteArray layout = properties["X11Layout"].toByteArray();
++    const QByteArray variant = properties["X11Variant"].toByteArray();
++    const QByteArray options = properties["X11Options"].toByteArray();
++
+     xkb_rule_names ruleNames = {
+-        nullptr,
+-        qPrintable(properties["X11Model"].toString()),
+-        qPrintable(layouts),
+-        qPrintable(properties["X11Variant"].toString()),
+-        qPrintable(properties["X11Options"].toString()),
++        .rules = nullptr,
++        .model = model.constData(),
++        .layout = layout.constData(),
++        .variant = variant.constData(),
++        .options = options.constData(),
+     };
++
+     applyEnvironmentRules(ruleNames);
+-    m_layoutList = layouts.split(QLatin1Char(','));
++
++    m_layoutList = 
QString::fromLatin1(ruleNames.layout).split(QLatin1Char(','));
++
+     return xkb_keymap_new_from_names(m_context, &ruleNames, 
XKB_KEYMAP_COMPILE_NO_FLAGS);
+ }
+ 
+-- 
+GitLab
+

diff --git a/kde-plasma/kwin/kwin-5.27.6-r1.ebuild 
b/kde-plasma/kwin/kwin-5.27.6-r1.ebuild
new file mode 100644
index 000000000000..3ccb2eace546
--- /dev/null
+++ b/kde-plasma/kwin/kwin-5.27.6-r1.ebuild
@@ -0,0 +1,145 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+ECM_HANDBOOK="optional"
+ECM_TEST="optional"
+KFMIN=5.106.0
+PVCUT=$(ver_cut 1-3)
+QTMIN=5.15.9
+inherit ecm plasma.kde.org optfeature
+
+DESCRIPTION="Flexible, composited Window Manager for windowing systems on 
Linux"
+
+LICENSE="GPL-2+"
+SLOT="5"
+KEYWORDS="~amd64 ~arm ~arm64 ~loong ~ppc64 ~riscv ~x86"
+IUSE="accessibility caps gles2-only lock multimedia plasma screencast"
+
+RESTRICT="test"
+
+COMMON_DEPEND="
+       >=dev-libs/libinput-1.19
+       >=dev-libs/wayland-1.21.0
+       >=dev-qt/qtconcurrent-${QTMIN}:5
+       >=dev-qt/qtdbus-${QTMIN}:5
+       >=dev-qt/qtdeclarative-${QTMIN}:5
+       >=dev-qt/qtgui-${QTMIN}:5=[egl,gles2-only=,libinput]
+       >=dev-qt/qtwayland-${QTMIN}:5
+       >=dev-qt/qtwidgets-${QTMIN}:5
+       >=dev-qt/qtx11extras-${QTMIN}:5
+       >=kde-frameworks/kactivities-${KFMIN}:5
+       >=kde-frameworks/kauth-${KFMIN}:5
+       >=kde-frameworks/kcmutils-${KFMIN}:5
+       >=kde-frameworks/kconfig-${KFMIN}:5[qml]
+       >=kde-frameworks/kconfigwidgets-${KFMIN}:5
+       >=kde-frameworks/kcoreaddons-${KFMIN}:5
+       >=kde-frameworks/kcrash-${KFMIN}:5
+       >=kde-frameworks/kdbusaddons-${KFMIN}:5
+       >=kde-frameworks/kdeclarative-${KFMIN}:5
+       >=kde-frameworks/kglobalaccel-${KFMIN}:5=[X]
+       >=kde-frameworks/ki18n-${KFMIN}:5
+       >=kde-frameworks/kidletime-${KFMIN}:5=
+       >=kde-frameworks/kitemviews-${KFMIN}:5
+       >=kde-frameworks/knewstuff-${KFMIN}:5
+       >=kde-frameworks/knotifications-${KFMIN}:5
+       >=kde-frameworks/kpackage-${KFMIN}:5
+       >=kde-frameworks/kservice-${KFMIN}:5
+       >=kde-frameworks/kwayland-${KFMIN}:5
+       >=kde-frameworks/kwidgetsaddons-${KFMIN}:5
+       >=kde-frameworks/kwindowsystem-${KFMIN}:5=[X]
+       >=kde-frameworks/kxmlgui-${KFMIN}:5
+       >=kde-frameworks/plasma-${KFMIN}:5
+       >=kde-plasma/breeze-${PVCUT}:5
+       >=kde-plasma/kdecoration-${PVCUT}:5
+       media-libs/fontconfig
+       media-libs/freetype
+       media-libs/lcms:2
+       media-libs/libepoxy
+       media-libs/libglvnd
+       >=media-libs/mesa-21.3[egl(+),gbm(+),wayland,X]
+       virtual/libudev:=
+       x11-libs/libX11
+       x11-libs/libXi
+       >=x11-libs/libdrm-2.4.112
+       >=x11-libs/libxcb-1.10
+       >=x11-libs/libxcvt-0.1.1
+       >=x11-libs/libxkbcommon-1.5.0
+       x11-libs/xcb-util-cursor
+       x11-libs/xcb-util-image
+       x11-libs/xcb-util-keysyms
+       x11-libs/xcb-util-wm
+       accessibility? ( media-libs/libqaccessibilityclient:5 )
+       caps? ( sys-libs/libcap )
+       gles2-only? ( media-libs/mesa[gles2] )
+       lock? ( >=kde-plasma/kscreenlocker-${PVCUT}:5 )
+       plasma? ( >=kde-frameworks/krunner-${KFMIN}:5 )
+       screencast? ( >=media-video/pipewire-0.3:= )
+"
+RDEPEND="${COMMON_DEPEND}
+       !kde-plasma/kwayland-server
+       >=dev-qt/qtquickcontrols-${QTMIN}:5
+       >=dev-qt/qtquickcontrols2-${QTMIN}:5
+       >=dev-qt/qtvirtualkeyboard-${QTMIN}:5
+       >=kde-frameworks/kirigami-${KFMIN}:5
+       >=kde-frameworks/kitemmodels-${KFMIN}:5[qml]
+       sys-apps/hwdata
+       x11-base/xwayland
+       multimedia? ( >=dev-qt/qtmultimedia-${QTMIN}:5[gstreamer,qml] )
+"
+DEPEND="${COMMON_DEPEND}
+       >=dev-libs/plasma-wayland-protocols-1.9
+       >=dev-libs/wayland-protocols-1.31
+       >=dev-qt/designer-${QTMIN}:5
+       >=dev-qt/qtconcurrent-${QTMIN}:5
+       x11-base/xorg-proto
+"
+BDEPEND="
+       >=dev-qt/qtwaylandscanner-${QTMIN}:5
+       dev-util/wayland-scanner
+       >=kde-frameworks/kcmutils-${KFMIN}:5
+"
+PDEPEND=">=kde-plasma/kde-cli-tools-${PVCUT}:5"
+
+PATCHES=(
+       "${FILESDIR}/${P}-fix-crash-click-on-tooltip.patch" # KDE-bug 471285
+       "${FILESDIR}/${P}-fix-crash-after-login.patch" # KDE-bugs 444665, 471139
+       "${FILESDIR}/${P}-fix-effect-to-only-apply-behind-window.patch"
+       "${FILESDIR}/${P}-fix-locale1-use-after-free-xkb_keymap.patch" # 
KDE-bug 469625
+)
+
+src_prepare() {
+       ecm_src_prepare
+       use multimedia || eapply 
"${FILESDIR}/${PN}-5.26.80-gstreamer-optional.patch"
+
+       # TODO: try to get a build switch upstreamed
+       if ! use screencast; then
+               sed -e "s/^pkg_check_modules.*PipeWire/#&/" -i CMakeLists.txt 
|| die
+       fi
+}
+
+src_configure() {
+       local mycmakeargs=(
+               # KWIN_BUILD_NOTIFICATIONS exists, but kdeclarative still 
hard-depends on it
+               $(cmake_use_find_package accessibility QAccessibilityClient)
+               $(cmake_use_find_package caps Libcap)
+               -DKWIN_BUILD_SCREENLOCKER=$(usex lock)
+               $(cmake_use_find_package plasma KF5Runner)
+       )
+
+       ecm_src_configure
+}
+
+pkg_postinst() {
+       ecm_pkg_postinst
+       optfeature "color management support" x11-misc/colord
+       elog
+       elog "In Plasma 5.20, default behavior of the Task Switcher to move 
minimised"
+       elog "windows to the end of the list was changed so that it remains in 
the"
+       elog "original order. To revert to the well established behavior:"
+       elog
+       elog " - Edit ~/.config/kwinrc"
+       elog " - Find [TabBox] section"
+       elog " - Add \"MoveMinimizedWindowsToEndOfTabBoxFocusChain=true\""
+}

Reply via email to