From fb644d12e38135b7ca5ea2e2d4c7d947bb901dc4 Mon Sep 17 00:00:00 2001 From: Tom Benham Date: Thu, 15 Jan 2026 11:43:44 +0100 Subject: [PATCH] swallowing: fix unwanted reswallow when process opens a secondary window --- src/desktop/view/Window.cpp | 12 ++++++++---- src/desktop/view/Window.hpp | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/desktop/view/Window.cpp b/src/desktop/view/Window.cpp index b2f4821b8..298129d7a 100644 --- a/src/desktop/view/Window.cpp +++ b/src/desktop/view/Window.cpp @@ -2090,9 +2090,12 @@ void CWindow::mapWindow() { // Verify window swallowing. Get the swallower before calling onWindowCreated(m_self.lock()) because getSwallower() wouldn't get it after if m_self.lock() gets auto grouped. const auto SWALLOWER = getSwallower(); - m_swallowed = SWALLOWER; - if (m_swallowed) - m_swallowed->m_currentlySwallowed = true; + // m_hasSwallower prevents secondary windows to swallow the parent when it's been unswallowed with `toggleswallow`. + if (SWALLOWER && !SWALLOWER->m_hasSwallower) { + SWALLOWER->m_currentlySwallowed = true; + SWALLOWER->m_hasSwallower = true; + m_swallowed = SWALLOWER; + } // emit the IPC event before the layout might focus the window to avoid a focus event first g_pEventManager->postEvent(SHyprIPCEvent{"openwindow", std::format("{:x},{},{},{}", m_self.lock(), PWORKSPACE->m_name, m_class, m_title)}); @@ -2223,7 +2226,7 @@ void CWindow::mapWindow() { } // swallow - if (SWALLOWER) { + if (m_swallowed) { g_layoutManager->removeTarget(SWALLOWER->layoutTarget()); SWALLOWER->setHidden(true); } @@ -2321,6 +2324,7 @@ void CWindow::unmapWindow() { } m_swallowed->m_groupSwallowed = false; + m_swallowed->m_hasSwallower = false; m_swallowed.reset(); } diff --git a/src/desktop/view/Window.hpp b/src/desktop/view/Window.hpp index 32a7bcfe2..0e139ae13 100644 --- a/src/desktop/view/Window.hpp +++ b/src/desktop/view/Window.hpp @@ -260,6 +260,7 @@ namespace Desktop::View { PHLWINDOWREF m_swallowed; bool m_currentlySwallowed = false; bool m_groupSwallowed = false; + bool m_hasSwallower = false; // for toplevel monitor events MONITORID m_lastSurfaceMonitorID = -1;