Blame SOURCES/0001-main-Unset-the-right-prevFocus-actor-after-the-focus.patch

6f08de
From 0d95c2087aba7f0b07cb303c1f15d097b45f1b09 Mon Sep 17 00:00:00 2001
6f08de
From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= <verdre@v0yd.nl>
6f08de
Date: Tue, 28 Apr 2020 23:26:11 +0200
6f08de
Subject: [PATCH] main: Unset the right prevFocus actor after the focus stack
6f08de
 got shifted
6f08de
MIME-Version: 1.0
6f08de
Content-Type: text/plain; charset=UTF-8
6f08de
Content-Transfer-Encoding: 8bit
6f08de
6f08de
When a modal that's not on top of the modalActorFocusStack gets popped,
6f08de
we shift the focus stack as described in popModal() to ensure the chain
6f08de
remains correct. That however destroys the association of a modal actor
6f08de
and its prevFocus actor on the focus stack, because the prevFocus actors
6f08de
are now moved to different entries of the stack.
6f08de
6f08de
Now when a prevFocus actor gets destroyed, we don't handle that case
6f08de
correctly and search for the modal actor that was associated with the
6f08de
prevFocus actor before the stack was shifted, which means we end up
6f08de
unsetting the wrong prevFocus actor.
6f08de
6f08de
So fix that and search the stack for the prevFocus actor which is being
6f08de
destroyed instead to unset the correct entry.
6f08de
6f08de
Thanks to Florian Müllner for figuring out the actual issue and
6f08de
proposing this fix.
6f08de
6f08de
Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2446
6f08de
---
6f08de
 js/ui/main.js | 4 +++-
6f08de
 1 file changed, 3 insertions(+), 1 deletion(-)
6f08de
6f08de
diff --git a/js/ui/main.js b/js/ui/main.js
6f08de
index dd1d8463d..ca3dcaa3c 100644
6f08de
--- a/js/ui/main.js
6f08de
+++ b/js/ui/main.js
6f08de
@@ -486,7 +486,9 @@ function pushModal(actor, params) {
6f08de
     let prevFocusDestroyId;
6f08de
     if (prevFocus != null) {
6f08de
         prevFocusDestroyId = prevFocus.connect('destroy', () => {
6f08de
-            let index = _findModal(actor);
6f08de
+            const index = modalActorFocusStack.findIndex(
6f08de
+                record => record.prevFocus === prevFocus);
6f08de
+
6f08de
             if (index >= 0)
6f08de
                 modalActorFocusStack[index].prevFocus = null;
6f08de
         });
6f08de
-- 
6f08de
2.35.1
6f08de