From ef9d3a1cd01326ca8aba0ea5ba9a5ac9b7bb17c4 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Wed, 21 Aug 2024 15:59:05 +0300 Subject: [PATCH] Add safety guards in FocusChain::move{After,Before}Window() If the `window` is the same as the `reference`, the `window` will be inserted at index "-1", which is wrong. --- src/focuschain.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/focuschain.cpp b/src/focuschain.cpp index dd36127019..5d62223f26 100644 --- a/src/focuschain.cpp +++ b/src/focuschain.cpp @@ -139,6 +139,9 @@ void FocusChain::moveAfterWindow(Window *window, Window *reference) if (!window->wantsTabFocus()) { return; } + if (reference == window) { + return; + } for (auto it = m_desktopFocusChains.begin(); it != m_desktopFocusChains.end(); @@ -159,6 +162,9 @@ void FocusChain::moveBeforeWindow(Window *window, Window *reference) if (!window->wantsTabFocus()) { return; } + if (reference == window) { + return; + } for (auto it = m_desktopFocusChains.begin(); it != m_desktopFocusChains.end();