From 4f88897fc0eaa176032c5163eb19043133b36863 Mon Sep 17 00:00:00 2001 From: memchr <118117622+memchr@users.noreply.github.com> Date: Wed, 13 Sep 2023 10:44:02 +0000 Subject: [PATCH] keybinds: avoid onWindowRemoved & onWindowCreated when group has one member (#3286) Make moveWindowOutOfGroup behave like toggleGroup on a group with single member, this prevents the window from moving around rabidly. --- src/managers/KeybindManager.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index e8c7a069..7e2f2f3f 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -1977,15 +1977,19 @@ void CKeybindManager::moveWindowOutOfGroup(CWindow* pWindow, const std::string& default: direction = DIRECTION_DEFAULT; } - g_pLayoutManager->getCurrentLayout()->onWindowRemoved(pWindow); + if (pWindow->m_sGroupData.pNextWindow == pWindow) { + pWindow->m_sGroupData.pNextWindow = nullptr; + pWindow->updateWindowDecos(); + } else { + g_pLayoutManager->getCurrentLayout()->onWindowRemoved(pWindow); - const auto GROUPSLOCKEDPREV = g_pKeybindManager->m_bGroupsLocked; + const auto GROUPSLOCKEDPREV = g_pKeybindManager->m_bGroupsLocked; + g_pKeybindManager->m_bGroupsLocked = true; - g_pKeybindManager->m_bGroupsLocked = true; + g_pLayoutManager->getCurrentLayout()->onWindowCreated(pWindow, direction); - g_pLayoutManager->getCurrentLayout()->onWindowCreated(pWindow, direction); - - g_pKeybindManager->m_bGroupsLocked = GROUPSLOCKEDPREV; + g_pKeybindManager->m_bGroupsLocked = GROUPSLOCKEDPREV; + } if (*BFOCUSREMOVEDWINDOW) { g_pCompositor->focusWindow(pWindow);