Avoid getting stuck when swtiching from one window to another with the same PID
This commit is contained in:
11
main.cpp
11
main.cpp
@ -94,7 +94,7 @@ public:
|
||||
atoms.wmClientMachine = getAtom("WM_CLIENT_MACHINE");
|
||||
if(atoms.netActiveWindow == 0)
|
||||
{
|
||||
std::cerr<<"WM_CLIENT_MACHINE is required\n";
|
||||
std::cerr<<" is required\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -177,6 +177,10 @@ public:
|
||||
{
|
||||
return pid == in.pid;
|
||||
}
|
||||
bool operator!=(const Process& in)
|
||||
{
|
||||
return pid != in.pid;
|
||||
}
|
||||
Process(){}
|
||||
Process(pid_t pidIn)
|
||||
{
|
||||
@ -266,6 +270,8 @@ int main(int argc, char* argv[])
|
||||
pid_t windowPid = xinstance.getPid(wid);
|
||||
Process process(windowPid);
|
||||
|
||||
if(process != prevProcess)
|
||||
{
|
||||
for(size_t i = 0; i < applicationNames.size(); ++i)
|
||||
{
|
||||
if(process.name == applicationNames[i] && process.name != "" && wid != 0)
|
||||
@ -273,12 +279,13 @@ int main(int argc, char* argv[])
|
||||
kill(process.pid, SIGCONT);
|
||||
std::cout<<"Resumeing: "<<wid<<" pid: "<<process.pid<<" name: "<<process.name<<'\n';
|
||||
}
|
||||
else if(prevProcess.name == applicationNames[i] && prevWindow != 0 && process.name != "" && wid != 0)
|
||||
else if(prevProcess.name == applicationNames[i] && prevWindow != 0 && prevProcess.name != "")
|
||||
{
|
||||
kill(prevProcess.pid, SIGSTOP);
|
||||
std::cout<<"Stoping: "<<prevWindow<<" pid: "<<prevProcess.pid<<" name: "<<prevProcess.name<<'\n';
|
||||
}
|
||||
}
|
||||
}
|
||||
prevProcess = process;
|
||||
prevWindow = wid;
|
||||
std::cout<<"Active window: "<<wid<<" pid: "<<windowPid<<" name: "<<Process(windowPid).name<<'\n';
|
||||
|
Reference in New Issue
Block a user