swallow improvements

This commit is contained in:
Vaxry 2022-10-07 09:46:01 +01:00
parent 28a6e0ce31
commit fd379db846

View file

@ -397,14 +397,22 @@ void Events::listener_mapWindow(void* owner, void* data) {
// verify swallowing
if (*PSWALLOW) {
// 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;
for (int i = 0; i < 5; ++i) {
curppid = getPPIDof(ppid);
if (curppid < 10) {
break;
}
ppid = curppid;
}
if (ppid) {
@ -422,35 +430,18 @@ void Events::listener_mapWindow(void* owner, void* data) {
if (found.size() > 1) {
for (auto& w : found) {
// try get the focus
// try get the focus, otherwise we'll ignore to avoid swallowing incorrect windows
if (w == PFOCUSEDWINDOWPREV) {
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(finalFound), rgx)) {
// swallow
PWINDOW->m_pSwallowed = finalFound;
@ -462,6 +453,7 @@ void Events::listener_mapWindow(void* owner, void* data) {
}
}
}
}
Debug::log(LOG, "Map request dispatched, monitor %s, xywh: %f %f %f %f", PMONITOR->szName.c_str(), PWINDOW->m_vRealPosition.goalv().x, PWINDOW->m_vRealPosition.goalv().y, PWINDOW->m_vRealSize.goalv().x, PWINDOW->m_vRealSize.goalv().y);