From a3d3b4fd64a51a8c1663b450bd2a408f1f0fa9b3 Mon Sep 17 00:00:00 2001 From: Aqa-Ib Date: Sun, 27 Oct 2024 00:44:55 +0000 Subject: groups: fix swallowing (#8223) * fix swallowing for groups * remove unnecessary check * clang-format * clarify comment * make variables consistent * make aditional variables consistent --- src/events/Windows.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'src/events/Windows.cpp') diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index 57a28948..e8abe30d 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -44,8 +44,6 @@ void Events::listener_mapWindow(void* owner, void* data) { static auto PINACTIVEALPHA = CConfigValue("decoration:inactive_opacity"); static auto PACTIVEALPHA = CConfigValue("decoration:active_opacity"); static auto PDIMSTRENGTH = CConfigValue("decoration:dim_strength"); - static auto PSWALLOW = CConfigValue("misc:enable_swallow"); - static auto PSWALLOWREGEX = CConfigValue("misc:swallow_regex"); static auto PNEWTAKESOVERFS = CConfigValue("misc:new_window_takes_over_fullscreen"); static auto PINITIALWSTRACKING = CConfigValue("misc:initial_workspace_tracking"); @@ -322,6 +320,10 @@ void Events::listener_mapWindow(void* owner, void* data) { PWINDOW->updateWindowData(); + // Verify window swallowing. Get the swallower before calling onWindowCreated(PWINDOW) because getSwallower() wouldn't get it after if PWINDOW gets auto grouped. + const auto SWALLOWER = PWINDOW->getSwallower(); + PWINDOW->m_pSwallowed = SWALLOWER; + if (PWINDOW->m_bIsFloating) { g_pLayoutManager->getCurrentLayout()->onWindowCreated(PWINDOW); PWINDOW->m_bCreatedOverFullscreen = true; @@ -567,20 +569,12 @@ void Events::listener_mapWindow(void* owner, void* data) { g_pCompositor->focusWindow(nullptr); } - // verify swallowing - if (*PSWALLOW && std::string{*PSWALLOWREGEX} != STRVAL_EMPTY) { - const auto SWALLOWER = PWINDOW->getSwallower(); - - if (SWALLOWER) { - // swallow - PWINDOW->m_pSwallowed = SWALLOWER; - - g_pLayoutManager->getCurrentLayout()->onWindowRemoved(SWALLOWER); - - SWALLOWER->setHidden(true); - - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PWINDOW->m_iMonitorID); - } + // swallow + if (SWALLOWER) { + g_pLayoutManager->getCurrentLayout()->onWindowRemoved(SWALLOWER); + g_pHyprRenderer->damageWindow(SWALLOWER); + SWALLOWER->setHidden(true); + g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PWINDOW->m_iMonitorID); } PWINDOW->m_bFirstMap = false; @@ -662,7 +656,13 @@ void Events::listener_unmapWindow(void* owner, void* data) { // swallowing if (valid(PWINDOW->m_pSwallowed)) { PWINDOW->m_pSwallowed->setHidden(false); + + if (PWINDOW->m_sGroupData.pNextWindow.lock()) + PWINDOW->m_pSwallowed->m_bGroupSwallowed = true; // flag for the swallowed window to be created into the group where it belongs when auto_group = false. + g_pLayoutManager->getCurrentLayout()->onWindowCreated(PWINDOW->m_pSwallowed.lock()); + + PWINDOW->m_pSwallowed->m_bGroupSwallowed = false; PWINDOW->m_pSwallowed.reset(); } -- cgit v1.2.3