Added toggleswallow dispatcher

This commit is contained in:
Tom Benham 2024-04-11 12:05:31 +02:00
parent ac0f3411c1
commit d48468d59c
3 changed files with 26 additions and 1 deletions

View file

@ -340,7 +340,8 @@ class CWindow {
CAnimatedVariable<float> m_fDimPercent;
// swallowing
CWindow* m_pSwallowed = nullptr;
CWindow* m_pSwallowed = nullptr;
CWindow* m_pPreviouslySwallowed = nullptr;
// focus stuff
bool m_bStayFocused = false;

View file

@ -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 = "";

View file

@ -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);