diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp index 00bea61e..574b2d9b 100644 --- a/src/debug/HyprCtl.cpp +++ b/src/debug/HyprCtl.cpp @@ -208,7 +208,7 @@ static std::string getWindowData(CWindow* w, eHyprCtlOutputFormat format) { escapeJSONStrings(g_pXWaylandManager->getAppIDClass(w)), escapeJSONStrings(g_pXWaylandManager->getTitle(w)), escapeJSONStrings(w->m_szInitialClass), escapeJSONStrings(w->m_szInitialTitle), w->getPID(), ((int)w->m_bIsX11 == 1 ? "true" : "false"), (w->m_bPinned ? "true" : "false"), (w->m_bIsFullscreen ? "true" : "false"), (w->m_bIsFullscreen ? (w->m_pWorkspace ? (int)w->m_pWorkspace->m_efFullscreenMode : 0) : 0), - w->m_bFakeFullscreenState ? "true" : "false", getGroupedData(w, format), (uintptr_t)w->m_pSwallowed, getFocusHistoryID(w)); + w->m_bFakeFullscreenState ? "true" : "false", getGroupedData(w, format), w->m_bCurrentlySwallowing ? (uintptr_t)w->m_pSwallowed : 0, getFocusHistoryID(w)); } else { return std::format("Window {:x} -> {}:\n\tmapped: {}\n\thidden: {}\n\tat: {},{}\n\tsize: {},{}\n\tworkspace: {} ({})\n\tfloating: {}\n\tmonitor: {}\n\tclass: {}\n\ttitle: " "{}\n\tinitialClass: {}\n\tinitialTitle: {}\n\tpid: " @@ -219,7 +219,7 @@ static std::string getWindowData(CWindow* w, eHyprCtlOutputFormat format) { (!w->m_pWorkspace ? "" : std::to_string(w->workspaceID())), (int)w->m_bIsFloating, (int64_t)w->m_iMonitorID, g_pXWaylandManager->getAppIDClass(w), g_pXWaylandManager->getTitle(w), w->m_szInitialClass, w->m_szInitialTitle, w->getPID(), (int)w->m_bIsX11, (int)w->m_bPinned, (int)w->m_bIsFullscreen, (w->m_bIsFullscreen ? (w->m_pWorkspace ? w->m_pWorkspace->m_efFullscreenMode : 0) : 0), (int)w->m_bFakeFullscreenState, getGroupedData(w, format), - (uintptr_t)w->m_pSwallowed, getFocusHistoryID(w)); + w->m_bCurrentlySwallowing ? (uintptr_t)w->m_pSwallowed : 0, getFocusHistoryID(w)); } } diff --git a/src/desktop/Window.hpp b/src/desktop/Window.hpp index 7e700199..19a40c62 100644 --- a/src/desktop/Window.hpp +++ b/src/desktop/Window.hpp @@ -341,8 +341,8 @@ class CWindow { // swallowing CWindow* m_pSwallowed = nullptr; - CWindow* m_pPreviouslySwallowed = nullptr; CWindow* m_pSwallowedBy = nullptr; + bool m_bCurrentlySwallowing = false; // focus stuff bool m_bStayFocused = false; diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index 2ac198e7..00d87078 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -583,8 +583,9 @@ void Events::listener_mapWindow(void* owner, void* data) { // check if it's the window we want & not exempt from getting swallowed if (valid) { // swallow - PWINDOW->m_pSwallowed = finalFound; - finalFound->m_pSwallowedBy = PWINDOW; + PWINDOW->m_pSwallowed = finalFound; + finalFound->m_pSwallowedBy = PWINDOW; + PWINDOW->m_bCurrentlySwallowing = true; g_pLayoutManager->getCurrentLayout()->onWindowRemoved(finalFound); diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index a703664f..2aa5e0e5 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -1823,25 +1823,24 @@ void CKeybindManager::focusWindow(std::string regexp) { void CKeybindManager::toggleSwallow(std::string args) { CWindow* pWindow = g_pCompositor->m_pLastWindow; - if (pWindow->m_pSwallowed) { - pWindow->m_pPreviouslySwallowed = pWindow->m_pSwallowed; + if (!pWindow->m_pSwallowed) + return; + + if (pWindow->m_bCurrentlySwallowing) { + // Unswallow pWindow->m_pSwallowed->setHidden(false); - g_pLayoutManager->getCurrentLayout()->onWindowCreated(pWindow->m_pSwallowed); - pWindow->m_pSwallowed->m_pSwallowedBy = nullptr; - pWindow->m_pSwallowed = nullptr; - - } else if (pWindow->m_pPreviouslySwallowed) { - pWindow->m_pSwallowed = pWindow->m_pPreviouslySwallowed; - pWindow->m_pSwallowed->m_pSwallowedBy = pWindow; - - g_pLayoutManager->getCurrentLayout()->onWindowRemoved(pWindow->m_pPreviouslySwallowed); - - pWindow->m_pPreviouslySwallowed->setHidden(true); + pWindow->m_bCurrentlySwallowing = false; + } else { + // Reswallow + g_pLayoutManager->getCurrentLayout()->onWindowRemoved(pWindow->m_pSwallowed); + pWindow->m_pSwallowed->setHidden(true); g_pLayoutManager->getCurrentLayout()->recalculateMonitor(pWindow->m_iMonitorID); + + pWindow->m_bCurrentlySwallowing = true; } }