Skip to content

Commit

Permalink
Added toggleswallow dispatcher
Browse files Browse the repository at this point in the history
  • Loading branch information
tomben13 committed Jan 31, 2025
1 parent 32c0fa2 commit c69e94a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/managers/KeybindManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,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;
Expand Down Expand Up @@ -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->isHidden()) {
// Unswallow
pWindow->m_pSwallowed->setHidden(false);
g_pLayoutManager->getCurrentLayout()->onWindowCreated(pWindow->m_pSwallowed.lock());
} else {
// Reswallow
g_pLayoutManager->getCurrentLayout()->onWindowRemoved(pWindow->m_pSwallowed.lock());
pWindow->m_pSwallowed->setHidden(true);

g_pLayoutManager->getCurrentLayout()->recalculateMonitor(pWindow->monitorID());
}

return {};
}

SDispatchResult CKeybindManager::setSubmap(std::string submap) {
if (submap == "reset" || submap == "") {
m_szCurrentSelectedSubmap = "";
Expand Down
1 change: 1 addition & 0 deletions src/managers/KeybindManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ class CKeybindManager {
static SDispatchResult circleNext(std::string);
static SDispatchResult focusWindow(std::string);
static SDispatchResult tagWindow(std::string);
static SDispatchResult toggleSwallow(std::string);
static SDispatchResult setSubmap(std::string);
static SDispatchResult pass(std::string);
static SDispatchResult sendshortcut(std::string);
Expand Down

0 comments on commit c69e94a

Please sign in to comment.