From 91fe58f8f278d126852877eadc87c50ca7b9b78d Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sat, 15 Jun 2024 18:20:09 +0200 Subject: window: improve swallowing functionality cleanups, fixes, etc. ref #6095 --- src/events/Windows.cpp | 69 +++++--------------------------------------------- 1 file changed, 7 insertions(+), 62 deletions(-) (limited to 'src/events/Windows.cpp') diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index becff152..d37ba12b 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -44,7 +44,6 @@ void Events::listener_mapWindow(void* owner, void* data) { static auto PDIMSTRENGTH = CConfigValue("decoration:dim_strength"); static auto PSWALLOW = CConfigValue("misc:enable_swallow"); static auto PSWALLOWREGEX = CConfigValue("misc:swallow_regex"); - static auto PSWALLOWEXREGEX = CConfigValue("misc:swallow_exception_regex"); static auto PNEWTAKESOVERFS = CConfigValue("misc:new_window_takes_over_fullscreen"); static auto PINITIALWSTRACKING = CConfigValue("misc:initial_workspace_tracking"); @@ -527,71 +526,17 @@ void Events::listener_mapWindow(void* owner, void* data) { // verify swallowing if (*PSWALLOW && std::string{*PSWALLOWREGEX} != STRVAL_EMPTY) { - // don't swallow ourselves - std::regex rgx(*PSWALLOWREGEX); - if (!std::regex_match(PWINDOW->m_szClass, rgx)) { - // check parent - int ppid = getPPIDof(PWINDOW->getPID()); + const auto SWALLOWER = PWINDOW->getSwallower(); - int curppid = 0; + if (SWALLOWER) { + // swallow + PWINDOW->m_pSwallowed = SWALLOWER; - for (int i = 0; i < 5; ++i) { - curppid = getPPIDof(ppid); + g_pLayoutManager->getCurrentLayout()->onWindowRemoved(SWALLOWER); - if (curppid < 10) { - break; - } - - ppid = curppid; - } - - if (ppid) { - // get window by pid - std::vector found; - PHLWINDOW finalFound; - for (auto& w : g_pCompositor->m_vWindows) { - if (!w->m_bIsMapped || w->isHidden()) - continue; - - if (w->getPID() == ppid) { - found.push_back(w); - } - } - - if (found.size() > 1) { - for (auto& w : found) { - // try get the focus, otherwise we'll ignore to avoid swallowing incorrect windows - if (w == PFOCUSEDWINDOWPREV) { - finalFound = w; - break; - } - } - } else if (found.size() == 1) { - finalFound = found[0]; - } - - if (finalFound) { - bool valid = std::regex_match(PWINDOW->m_szClass, rgx); - - if (std::string{*PSWALLOWEXREGEX} != STRVAL_EMPTY) { - std::regex exc(*PSWALLOWEXREGEX); - - valid = valid && !std::regex_match(PWINDOW->m_szTitle, exc); - } - - // check if it's the window we want & not exempt from getting swallowed - if (valid) { - // swallow - PWINDOW->m_pSwallowed = finalFound; + SWALLOWER->setHidden(true); - g_pLayoutManager->getCurrentLayout()->onWindowRemoved(finalFound); - - finalFound->setHidden(true); - - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PWINDOW->m_iMonitorID); - } - } - } + g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PWINDOW->m_iMonitorID); } } -- cgit v1.2.3