diff options
| author | vaxerski <vaxry@vaxry.net> | 2022-10-04 10:17:03 +0100 |
|---|---|---|
| committer | vaxerski <vaxry@vaxry.net> | 2022-10-04 10:17:10 +0100 |
| commit | 3e3f6aef5efa5d3b20c9cb3db8df40127b9222d1 (patch) | |
| tree | 2cbcdce8ed5f7ef6f3a7154edbd360dee6bc5297 /src/events/Windows.cpp | |
| parent | 996938b7e76636fb2ce3020f482898622f4b2f40 (diff) | |
additional logic for identical pid swallowing
Diffstat (limited to 'src/events/Windows.cpp')
| -rw-r--r-- | src/events/Windows.cpp | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index ce927dca..e95b3c3b 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -392,27 +392,56 @@ void Events::listener_mapWindow(void* owner, void* data) { if (ppid) { // get window by pid - CWindow* found = nullptr; + 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 = w.get(); + found.push_back(w.get()); break; } } - if (found) { + if (found.size() > 1) { + for (auto& w : found) { + // try get the focus + if (w == g_pCompositor->m_pLastWindow) { + finalFound = w; + break; + } + } + + if (!finalFound) { + // just get the closest (ws) + for (auto& w : found) { + if (w->m_iWorkspaceID == g_pCompositor->m_pLastMonitor->activeWorkspace) { + finalFound = w; + break; + } + } + } + + if (!finalFound) { + // what, just use 0 + 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(found), rgx)) { + if (std::regex_match(g_pXWaylandManager->getAppIDClass(finalFound), rgx)) { // swallow - PWINDOW->m_pSwallowed = found; + PWINDOW->m_pSwallowed = finalFound; - g_pLayoutManager->getCurrentLayout()->onWindowRemoved(found); + g_pLayoutManager->getCurrentLayout()->onWindowRemoved(finalFound); - found->m_bHidden = true; + finalFound->m_bHidden = true; } } } |
