From cd20a4a868c8f1755b7c672049119e9d7d3be2d8 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Thu, 13 May 2021 15:27:53 +0100 Subject: [PATCH] Add patch to fix focus follows mouse (#1960208) --- kwin-fix-focus-follows-mouse-policy.patch | 89 +++++++++++++++++++++++ kwin.spec | 7 +- 2 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 kwin-fix-focus-follows-mouse-policy.patch diff --git a/kwin-fix-focus-follows-mouse-policy.patch b/kwin-fix-focus-follows-mouse-policy.patch new file mode 100644 index 0000000..a1e1d42 --- /dev/null +++ b/kwin-fix-focus-follows-mouse-policy.patch @@ -0,0 +1,89 @@ +From 073b6efc144d8aabef2eea8f64b84ffdca87b6b5 Mon Sep 17 00:00:00 2001 +From: Vlad Zahorodnii +Date: Mon, 3 May 2021 11:24:22 +0300 +Subject: [PATCH] wayland: Fix focus follows mouse policy + +We want to update the input focus only if the pointer is moved. Due to +that, AbstractClient::enterEvent() checks the last seen pointer position +to decide whether the window needs to be focused. + +The issue is that when the pointer moves from a decoration to a surface, +the cached pointer position will be updated to the current pointer +position, and thus the check in AbstractClient::enterEvent() will fail. + +We need to update the cached pointer position only if there is a focused +decoration. +--- + src/input.cpp | 26 +++++++++++++------------- + src/pointer_input.cpp | 2 -- + 2 files changed, 13 insertions(+), 15 deletions(-) + +diff --git a/src/input.cpp b/src/input.cpp +index 9377e9334..b1b961e39 100644 +--- a/input.cpp ++++ b/input.cpp +@@ -2846,6 +2846,7 @@ void InputDeviceHandler::update() + setAt(toplevel); + + if (focusUpdatesBlocked()) { ++ workspace()->updateFocusMousePosition(position().toPoint()); + return; + } + +@@ -2860,21 +2861,20 @@ void InputDeviceHandler::update() + // went onto or off from decoration, update focus + updateFocus(); + } +- return; +- } +- updateInternalWindow(nullptr); ++ } else { ++ updateInternalWindow(nullptr); + +- if (m_focus.focus != m_at.at) { +- // focus change +- updateDecoration(); +- updateFocus(); +- return; +- } +- // check if switched to/from decoration while staying on the same Toplevel +- if (updateDecoration()) { +- // went onto or off from decoration, update focus +- updateFocus(); ++ if (m_focus.focus != m_at.at) { ++ // focus change ++ updateDecoration(); ++ updateFocus(); ++ } else if (updateDecoration()) { ++ // went onto or off from decoration, update focus ++ updateFocus(); ++ } + } ++ ++ workspace()->updateFocusMousePosition(position().toPoint()); + } + + Toplevel *InputDeviceHandler::at() const +diff --git a/src/pointer_input.cpp b/src/pointer_input.cpp +index bf59197d3..a93c2cf55 100644 +--- a/pointer_input.cpp ++++ b/pointer_input.cpp +@@ -473,7 +473,6 @@ void PointerInputRedirection::cleanupDecoration(Decoration::DecoratedClientImpl + { + disconnect(m_decorationGeometryConnection); + m_decorationGeometryConnection = QMetaObject::Connection(); +- workspace()->updateFocusMousePosition(position().toPoint()); + + if (old) { + // send leave event to old decoration +@@ -524,7 +523,6 @@ void PointerInputRedirection::focusUpdate(Toplevel *focusOld, Toplevel *focusNow + + if (AbstractClient *ac = qobject_cast(focusNow)) { + ac->enterEvent(m_pos.toPoint()); +- workspace()->updateFocusMousePosition(m_pos.toPoint()); + } + + if (internalWindow()) { +-- +GitLab + diff --git a/kwin.spec b/kwin.spec index 6f9bd1e..7584b7f 100644 --- a/kwin.spec +++ b/kwin.spec @@ -17,7 +17,7 @@ Name: kwin Version: 5.21.5 -Release: 2%{?dist} +Release: 3%{?dist} Summary: KDE Window manager # all sources are effectively GPLv2+, except for: @@ -38,6 +38,8 @@ Source0: http://download.kde.org/%{stable}/plasma/%{version}/%{name}-%{version}. ## upstream patches Patch0: kwin-use-dmabufs-only-when-client-asks-for-it.patch +# https://bugs.kde.org/show_bug.cgi?id=395970 +Patch1: kwin-fix-focus-follows-mouse-policy.patch ## proposed patches @@ -361,6 +363,9 @@ make test ARGS="--output-on-failure --timeout 10" -C %{_target_platform} ||: %changelog +* Thu May 13 2021 Jonathan Wakely - 5.21.5-3 +- Add patch to fix focus follows mouse (#1960208) + * Wed May 05 2021 Jan Grulich - 5.21.5-2 - Use dma-bufs for screensharing only when client asks for it