From 22e10f6efb01c53314b7af4b96dc08c6149f6738 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Wed, 21 Aug 2024 15:54:53 +0300 Subject: [PATCH] Correct traversal order in FocusChain::moveAfterWindowInChain() The first item in the `chain` list corresponds to the last item in the focus chain. The last item in the `chain` list corresponds to the first item in the focus chain. Given that, we need to traverse the list from the start to the end in order to find the first window owned by the same app as `reference`. --- src/focuschain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/focuschain.cpp b/src/focuschain.cpp index 048a40d13c..dd36127019 100644 --- a/src/focuschain.cpp +++ b/src/focuschain.cpp @@ -184,7 +184,7 @@ void FocusChain::moveAfterWindowInChain(Window *window, Window *reference, Chain chain.insert(chain.indexOf(reference), window); } else { chain.removeAll(window); - for (int i = chain.size() - 1; i >= 0; --i) { + for (int i = 0; i < chain.size(); ++i) { if (Window::belongToSameApplication(reference, chain.at(i))) { chain.insert(i, window); break;