diff --git a/src/desktop/Window.hpp b/src/desktop/Window.hpp index 8a368ea6..530501d3 100644 --- a/src/desktop/Window.hpp +++ b/src/desktop/Window.hpp @@ -340,7 +340,8 @@ class CWindow { CAnimatedVariable m_fDimPercent; // swallowing - CWindow* m_pSwallowed = nullptr; + CWindow* m_pSwallowed = nullptr; + CWindow* m_pPreviouslySwallowed = nullptr; // focus stuff bool m_bStayFocused = false; diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 63c0c95f..347e2c77 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -59,6 +59,7 @@ CKeybindManager::CKeybindManager() { m_mDispatchers["cyclenext"] = circleNext; m_mDispatchers["focuswindowbyclass"] = focusWindow; m_mDispatchers["focuswindow"] = focusWindow; + m_mDispatchers["toggleswallow"] = toggleSwallow; m_mDispatchers["submap"] = setSubmap; m_mDispatchers["pass"] = pass; m_mDispatchers["layoutmsg"] = layoutmsg; @@ -1820,6 +1821,28 @@ void CKeybindManager::focusWindow(std::string regexp) { g_pCompositor->warpCursorTo(PWINDOW->middle()); } +void CKeybindManager::toggleSwallow(std::string args) { + CWindow* pWindow = g_pCompositor->m_pLastWindow; + if (pWindow->m_pSwallowed && g_pCompositor->windowExists(pWindow->m_pSwallowed)) { + pWindow->m_pPreviouslySwallowed = pWindow->m_pSwallowed; + + pWindow->m_pSwallowed->setHidden(false); + + g_pLayoutManager->getCurrentLayout()->onWindowCreated(pWindow->m_pSwallowed); + + pWindow->m_pSwallowed = nullptr; + + } else if (pWindow->m_pPreviouslySwallowed && g_pCompositor->windowExists(pWindow->m_pPreviouslySwallowed)) { + pWindow->m_pSwallowed = pWindow->m_pPreviouslySwallowed; + + g_pLayoutManager->getCurrentLayout()->onWindowRemoved(pWindow->m_pPreviouslySwallowed); + + pWindow->m_pPreviouslySwallowed->setHidden(true); + + g_pLayoutManager->getCurrentLayout()->recalculateMonitor(pWindow->m_iMonitorID); + } +} + void CKeybindManager::setSubmap(std::string submap) { if (submap == "reset" || submap == "") { m_szCurrentSelectedSubmap = ""; diff --git a/src/managers/KeybindManager.hpp b/src/managers/KeybindManager.hpp index aec9e02d..110186d1 100644 --- a/src/managers/KeybindManager.hpp +++ b/src/managers/KeybindManager.hpp @@ -151,6 +151,7 @@ class CKeybindManager { static void forceRendererReload(std::string); static void resizeActive(std::string); static void moveActive(std::string); + static void toggleSwallow(std::string); static void moveWindow(std::string); static void resizeWindow(std::string); static void circleNext(std::string);