diff options
| author | Tom Benham <38216488+tomben13@users.noreply.github.com> | 2025-02-05 10:56:41 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-05 09:56:41 +0000 |
| commit | 84c9baecc6b73f6321b2739061e3c232710f73bf (patch) | |
| tree | 30bf9787abd8c5c2b7ca069de390bb78576b3bb9 /src/managers/KeybindManager.cpp | |
| parent | 3b99e906df8b439d65e740301940e57efc057012 (diff) | |
keybinds: Added `toggleswallow` dispatcher (#5548)
* Added `toggleswallow` dispatcher
* clang-format
* Removed brackets for 1-line if
Diffstat (limited to 'src/managers/KeybindManager.cpp')
| -rw-r--r-- | src/managers/KeybindManager.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 47cc4f67..2d6b2cb8 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -113,6 +113,7 @@ CKeybindManager::CKeybindManager() { m_mDispatchers["focuswindowbyclass"] = focusWindow; m_mDispatchers["focuswindow"] = focusWindow; m_mDispatchers["tagwindow"] = tagWindow; + m_mDispatchers["toggleswallow"] = toggleSwallow; m_mDispatchers["submap"] = setSubmap; m_mDispatchers["pass"] = pass; m_mDispatchers["sendshortcut"] = sendshortcut; @@ -2306,6 +2307,27 @@ SDispatchResult CKeybindManager::tagWindow(std::string args) { return {}; } +SDispatchResult CKeybindManager::toggleSwallow(std::string args) { + PHLWINDOWREF pWindow = g_pCompositor->m_pLastWindow; + + if (!valid(pWindow) || !valid(pWindow->m_pSwallowed)) + return {}; + + if (pWindow->m_pSwallowed->m_bCurrentlySwallowed) { + // Unswallow + pWindow->m_pSwallowed->m_bCurrentlySwallowed = false; + pWindow->m_pSwallowed->setHidden(false); + g_pLayoutManager->getCurrentLayout()->onWindowCreated(pWindow->m_pSwallowed.lock()); + } else { + // Reswallow + pWindow->m_pSwallowed->m_bCurrentlySwallowed = true; + pWindow->m_pSwallowed->setHidden(true); + g_pLayoutManager->getCurrentLayout()->onWindowRemoved(pWindow->m_pSwallowed.lock()); + } + + return {}; +} + SDispatchResult CKeybindManager::setSubmap(std::string submap) { if (submap == "reset" || submap == "") { m_szCurrentSelectedSubmap = ""; |
