diff options
author | vaxerski <[email protected]> | 2022-10-07 09:46:01 +0100 |
---|---|---|
committer | vaxerski <[email protected]> | 2022-10-07 09:46:01 +0100 |
commit | fd379db8466985edb9ed43823f05372f8b81f058 (patch) | |
tree | 3e2814b3392cfeb7f2accbcd49ca017e87cb6f9a | |
parent | 28a6e0ce3178527e54070fb3ee19d90239110bf7 (diff) | |
download | Hyprland-fd379db8466985edb9ed43823f05372f8b81f058.tar.gz Hyprland-fd379db8466985edb9ed43823f05372f8b81f058.zip |
swallow improvements
-rw-r--r-- | src/events/Windows.cpp | 76 |
1 files changed, 34 insertions, 42 deletions
diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index 9d5cd446..9ceae914 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -397,67 +397,59 @@ void Events::listener_mapWindow(void* owner, void* data) { // verify swallowing if (*PSWALLOW) { - // check parent - int ppid = getPPIDof(PWINDOW->getPID()); + // don't swallow ourselves + std::regex rgx(*PSWALLOWREGEX); + if (!std::regex_match(g_pXWaylandManager->getAppIDClass(PWINDOW), rgx)) { + // check parent + int ppid = getPPIDof(PWINDOW->getPID()); - const auto PPPID = getPPIDof(ppid); + int curppid = 0; - // why? no clue. Blame terminals. - if (PPPID > 2) { - ppid = PPPID; - } - - if (ppid) { - // get window by pid - std::vector<CWindow*> found; - CWindow* finalFound = nullptr; - for (auto& w : g_pCompositor->m_vWindows) { - if (!w->m_bIsMapped || w->m_bHidden) - continue; + for (int i = 0; i < 5; ++i) { + curppid = getPPIDof(ppid); - if (w->getPID() == ppid) { - found.push_back(w.get()); + if (curppid < 10) { + break; } + + ppid = curppid; } - if (found.size() > 1) { - for (auto& w : found) { - // try get the focus - if (w == PFOCUSEDWINDOWPREV) { - finalFound = w; - break; + if (ppid) { + // get window by pid + std::vector<CWindow*> found; + CWindow* finalFound = nullptr; + for (auto& w : g_pCompositor->m_vWindows) { + if (!w->m_bIsMapped || w->m_bHidden) + continue; + + if (w->getPID() == ppid) { + found.push_back(w.get()); } } - if (!finalFound) { - // just get the closest (ws) + if (found.size() > 1) { for (auto& w : found) { - if (w->m_iWorkspaceID == g_pCompositor->m_pLastMonitor->activeWorkspace) { + // try get the focus, otherwise we'll ignore to avoid swallowing incorrect windows + if (w == PFOCUSEDWINDOWPREV) { finalFound = w; break; } } - } - - if (!finalFound) { - // what, just use 0 + } else if (found.size() == 1) { finalFound = found[0]; } - } else if (found.size() == 1) { - finalFound = found[0]; - } - - if (finalFound) { - // check if it's the window we want - std::regex rgx(*PSWALLOWREGEX); - if (std::regex_match(g_pXWaylandManager->getAppIDClass(finalFound), rgx)) { - // swallow - PWINDOW->m_pSwallowed = finalFound; + if (finalFound) { + // check if it's the window we want + if (std::regex_match(g_pXWaylandManager->getAppIDClass(finalFound), rgx)) { + // swallow + PWINDOW->m_pSwallowed = finalFound; - g_pLayoutManager->getCurrentLayout()->onWindowRemoved(finalFound); + g_pLayoutManager->getCurrentLayout()->onWindowRemoved(finalFound); - finalFound->m_bHidden = true; + finalFound->m_bHidden = true; + } } } } |