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 // verify swallowing
if (*PSWALLOW) { if (*PSWALLOW) {
// don't swallow ourselves
std::regex rgx(*PSWALLOWREGEX);
if (!std::regex_match(g_pXWaylandManager->getAppIDClass(PWINDOW), rgx)) {
// check parent // check parent
int ppid = getPPIDof(PWINDOW->getPID()); int ppid = getPPIDof(PWINDOW->getPID());
const auto PPPID = getPPIDof(ppid); int curppid = 0;
// why? no clue. Blame terminals. for (int i = 0; i < 5; ++i) {
if (PPPID > 2) { curppid = getPPIDof(ppid);
ppid = PPPID;
if (curppid < 10) {
break;
}
ppid = curppid;
} }
if (ppid) { if (ppid) {
@ -422,35 +430,18 @@ void Events::listener_mapWindow(void* owner, void* data) {
if (found.size() > 1) { if (found.size() > 1) {
for (auto& w : found) { for (auto& w : found) {
// try get the focus // try get the focus, otherwise we'll ignore to avoid swallowing incorrect windows
if (w == PFOCUSEDWINDOWPREV) { if (w == PFOCUSEDWINDOWPREV) {
finalFound = w; finalFound = w;
break; 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) { } else if (found.size() == 1) {
finalFound = found[0]; finalFound = found[0];
} }
if (finalFound) { if (finalFound) {
// check if it's the window we want // check if it's the window we want
std::regex rgx(*PSWALLOWREGEX);
if (std::regex_match(g_pXWaylandManager->getAppIDClass(finalFound), rgx)) { if (std::regex_match(g_pXWaylandManager->getAppIDClass(finalFound), rgx)) {
// swallow // swallow
PWINDOW->m_pSwallowed = finalFound; 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); 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);