I was playing a game with someone and they left because they knew they were going to lose. This is a really annoying thing that has happened to me. I would like to know if there is a chess program that knows if someone has switched to another screen.
Chess.com detects it as well. If they by chance disconnect due to internet issues, it will show a bar that fluctuates based on wifi strength. They have a certain time to reconnect.
Chess.com additionally gives warnings and will ban that user if they consistently leave matches, so you don't have to worry about them.
For a chess program that can check if they switch screens, I doubt that as of late. It may be possible to check servers, but that could cause an invasion of privacy, as well as consent needed to "share screen" or some sort. If you have suspicions, you can send a message to the developers and tell them, and chess.com allows you to review your opponents accuracy and time of moves, to check if they truly have been making moves they shouldn't have been able to.
Lichess (http://lichess.org) has some ability to detect when your opponent has left the game. When that happens, it gives your opponent a brief chance to rejoin, then allows you to claim a victory or a draw if they do not rejoin. If Lichess detects that your opponent has left, it will show a counter counting down the seconds until you can claim victory. The amount of time on the counter seems to depend on the time control and other factors. If Lichess does not detect that your opponent has left, but they decide to run out the clock, Lichess will not allow you to claim a victory, but will still automatically penalize your opponent with a ban after repeated offenses.
Note that none of this happens in correspondence chess, as temporarily leaving the game is normal in that time control.