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`.
This commit is contained in:
Vlad Zahorodnii 2024-08-21 15:54:53 +03:00
parent 1c7c16f28b
commit 22e10f6efb

View file

@ -184,7 +184,7 @@ void FocusChain::moveAfterWindowInChain(Window *window, Window *reference, Chain
chain.insert(chain.indexOf(reference), window); chain.insert(chain.indexOf(reference), window);
} else { } else {
chain.removeAll(window); 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))) { if (Window::belongToSameApplication(reference, chain.at(i))) {
chain.insert(i, window); chain.insert(i, window);
break; break;