From 7b01c3d028ee5e6423b65388966162a50813b83b Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 25 Aug 2022 22:34:53 +0200 Subject: [PATCH] allow specifying window for toggle floating --- src/managers/KeybindManager.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index adc77140..ec4755a8 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -463,19 +463,28 @@ void CKeybindManager::clearKeybinds() { } void CKeybindManager::toggleActiveFloating(std::string args) { - const auto ACTIVEWINDOW = g_pCompositor->m_pLastWindow; + CWindow* PWINDOW = nullptr; - if (g_pCompositor->windowValidMapped(ACTIVEWINDOW)) { + if (args != "" && args != "active" && args.length() > 1) { + PWINDOW = g_pCompositor->getWindowByRegex(args); + } else { + PWINDOW = g_pCompositor->m_pLastWindow; + } + + if (!PWINDOW) + return; + + if (g_pCompositor->windowValidMapped(PWINDOW)) { // remove drag status g_pInputManager->currentlyDraggedWindow = nullptr; - ACTIVEWINDOW->m_bIsFloating = !ACTIVEWINDOW->m_bIsFloating; + PWINDOW->m_bIsFloating = !PWINDOW->m_bIsFloating; - if (ACTIVEWINDOW->m_iWorkspaceID == SPECIAL_WORKSPACE_ID) { - moveActiveToWorkspace(std::to_string(g_pCompositor->getMonitorFromID(ACTIVEWINDOW->m_iMonitorID)->activeWorkspace)); + if (PWINDOW->m_iWorkspaceID == SPECIAL_WORKSPACE_ID && PWINDOW == g_pCompositor->m_pLastWindow) { + moveActiveToWorkspace(std::to_string(g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID)->activeWorkspace)); } - g_pLayoutManager->getCurrentLayout()->changeWindowFloatingMode(ACTIVEWINDOW); + g_pLayoutManager->getCurrentLayout()->changeWindowFloatingMode(PWINDOW); } }