fix(app): only a reading made with no game running is kept as other programs' memory

- a normal placement keeps its reading only when no game runs: the perf loop passes whether a
  game runs to every switch, so the way back from a failed game stage while the game runs keeps
  the reading from before the game
- game detection also looks at every running program once as the services start: a program in
  a launcher's game folder or the person's games list counts, also behind other windows
- checked on the win-ci VM: a minimised program in a Steam game folder is found at the start
  while nothing is in front

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-14 10:52:48 +09:00
parent 4a81b88d41
commit 5316f4e9b0
6 changed files with 175 additions and 41 deletions

View File

@@ -44,3 +44,18 @@ fn a_launcher_game_turns_game_mode_on_until_it_ends() {
assert_eq!(off, serde_json::Value::Null, "game mode ends with the game");
w.stop();
}
/// A game program running behind other windows when the watch starts is found by what it is.
/// Runs only with `JARVIS_TEST_BACKGROUND_GAME=1` (a launcher-folder program runs) or `=0` (none).
#[test]
fn a_game_running_behind_other_windows_is_found_at_the_start() {
let Ok(want) = std::env::var("JARVIS_TEST_BACKGROUND_GAME") else {
eprintln!("skipped: set JARVIS_TEST_BACKGROUND_GAME");
return;
};
let w = GameWatch::start(GameSettings { detect: true, games: vec![], not_games: vec![], other_room_gb: 1.0,
reserve_gb: 8.0, revert_seconds: 30, pause_in_game: false });
eprintln!("in front: {}, at the start: {}", w.on(), w.in_background_at_start());
assert_eq!(w.in_background_at_start(), want == "1");
w.stop();
}