allow specifying window for toggle floating

This commit is contained in:
vaxerski 2022-08-25 22:34:53 +02:00
parent 89018bfa95
commit 7b01c3d028

View file

@ -463,19 +463,28 @@ void CKeybindManager::clearKeybinds() {
} }
void CKeybindManager::toggleActiveFloating(std::string args) { 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 // remove drag status
g_pInputManager->currentlyDraggedWindow = nullptr; g_pInputManager->currentlyDraggedWindow = nullptr;
ACTIVEWINDOW->m_bIsFloating = !ACTIVEWINDOW->m_bIsFloating; PWINDOW->m_bIsFloating = !PWINDOW->m_bIsFloating;
if (ACTIVEWINDOW->m_iWorkspaceID == SPECIAL_WORKSPACE_ID) { if (PWINDOW->m_iWorkspaceID == SPECIAL_WORKSPACE_ID && PWINDOW == g_pCompositor->m_pLastWindow) {
moveActiveToWorkspace(std::to_string(g_pCompositor->getMonitorFromID(ACTIVEWINDOW->m_iMonitorID)->activeWorkspace)); moveActiveToWorkspace(std::to_string(g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID)->activeWorkspace));
} }
g_pLayoutManager->getCurrentLayout()->changeWindowFloatingMode(ACTIVEWINDOW); g_pLayoutManager->getCurrentLayout()->changeWindowFloatingMode(PWINDOW);
} }
} }