Skip to content

fix: keep the Playnite session while a game runs and follow renamed screens - #191

Merged
lippdev merged 1 commit into
mainfrom
fix/playnite-game-launch
Nov 1, 2026
Merged

lippdev merged 1 commit into
mainfrom
fix/playnite-game-launch

Conversation

@lippdev

@lippdev lippdev commented Nov 1, 2026

Copy link
Copy Markdown
Owner

What

Two bugs from the owner's session on 2026-11-01 (Playnite with the Selene theme, the LG TV as the game screen, both desk monitors detached):

  1. Starting a game ended the session. Playnite's fullscreen setting "Minimize after game startup" (on in Selene) hides its window while the game runs. With no big window for 20 s, PlayniteExitPolicy took Playnite as closed (and logged "Playnite fechou" though the process was running), so the desk came back mid-game. The window that was watched still exists (same handle, hidden and iconic) and comes back when the game ends, unlike a loading window swapped for the main one, which is destroyed. The session now goes on while that window is put away, and ends when the process exits.
  2. The restore turned off the wrong monitor. During that session Windows renamed the screens: the TV went in as DISPLAY3 and came out as DISPLAY1, and the HP took DISPLAY3. The backup layout already followed monitors by MonitorID, but the names saved next to it (primary, game screen, hidden screens) did not, so the restore detached DISPLAY3 (now the HP) as "the TV". The same rename made the 1440p mode fail at the start (=> -1) and the window placement miss the TV.
    • The start looks the game screen up again by its id after turning the TV on and after detaching the others (FollowFocusRename).
    • The restore maps the meta file's names to the current ones (DisplayIdentity.CurrentNames, tested with the owner's exact swap).
    • The primary is put back before the TV is detached: Windows refuses to detach the primary (error 87 for ~10 s on every restore of this setup), and that refusal used to be recorded as "Não foi possível desconectar" even when the later round worked, which kept the session journal and re-ran the restore on the next start. Only a screen still on at the end is a failure now.

Verified on the owner's PC (debug build, owner's config)

  • Session with Playnite → game started through Playnite (playnite://playnite/start/…) → 60 s later the session is still active; the log says "Playnite escondeu a janela (jogo aberto); a sessão continua". Before the fix, the same steps restored the desk 20 s after the game started.
  • Closing the game: "Playnite voltou a mostrar a janela", Playnite back on the TV, session still active.
  • Closing Playnite: session ends, "Restore: concluído com sucesso", no 87 retries, desk exactly as before (25G64 primary, HP portrait at 1920,-301, TV off). One more start/stop cycle: same.
  • The rename itself didn't happen again in three sessions (it is intermittent); it is covered by the unit test and logged ("a tela de jogo passou de … para …", "telas com outro nome desde o backup").
  • dotnet test: 675 passing. Manual checks added to docs/TESTING.md.

🤖 Generated with Claude Code

…creens

Playnite hides its fullscreen window while a game it started runs
("Minimize after game startup", on in the Selene theme). After 20 s the
loop took it as closed and restored the desk mid-game. The window that
was watched still exists, hidden or minimized, so the session goes on
until the Playnite process exits.

Windows can also rename the screens during a session (the TV went in as
DISPLAY3 and came out as DISPLAY1). The start now looks the game screen
up again by its id after each display change, and the restore maps the
names saved next to the backup to the current ones by MonitorID, so it
no longer detaches a desk monitor taking it for the TV. The primary goes
back before the TV is detached (Windows refuses to detach the primary),
and only a screen still on at the end counts as a failed detach.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes This review covers the Playnite session tracking and display identity/restore changes, including their tests and manual checks.

  • Playnite session tracking. The exit policy now keeps a session alive while Playnite's existing fullscreen window is hidden for a launched game, and still ends the session when the Playnite process exits.
  • Display identity across transitions. Startup re-resolves the focus display after topology changes, while restore remaps saved names by monitor ID and restores the original primary before detaching displays.
  • Coverage. Added unit tests cover hidden-window exit policy and swapped display names; the manual checklist documents the hardware-dependent scenarios.

Pullfrog  | View workflow run | Using gpt-6-luna | 𝕏

@lippdev
lippdev merged commit 1a4201e into main Nov 1, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant