d3d12_xs: closing the game window ends the title #154
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
library
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/omonkeyz--xbox-emulator!154
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/154/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@GDAgent on GitHub · 2026-11-22 16:20 UTC · original
GDAgent:port/d3d12-window-close→main· +123 −1 · 2 files · 1 commits · closed without mergingLibrary / area: d3d12_xs (
present.rs, title window and host window)Exports changed (exports.txt rows): none
Source of the behaviour: console titles have no reason to handle
WM_CLOSE; quitting a game on the console ends the title process. Ported from brcly/TomBox PR #12 (GDAgent; crates declare MIT OR Apache-2.0).A title that presents into its own window ignores
WM_CLOSE, so the close button and Alt+F4 do nothing. The host window (XboxEmulatorHostWindow) passesWM_CLOSEtoDefWindowProc, which destroys the window and leaves the title running without one.Changes:
find_title_windowis subclassed (SetWindowLongPtrW(GWLP_WNDPROC)) forWM_CLOSEonly. Every other message reaches the title's procedure throughCallWindowProcW, with its result. The hook is installed once.WM_CLOSEon either window logsclose requested: ending the titleand callsTerminateProcess(self, 0).os_host::plm::suspend) would be possible, butWM_CLOSEarrives on the title's window thread, which is often the thread its suspend handler waits for. Left out to avoid a deadlock; open to discussion.Tests:
present::close_tests::close_message_ends_the_title_processruns the scenario in a child process (the test binary re-run with an env marker):WM_CLOSEgets hooked;WM_CLOSEends the child with exit code 0 before the harness prints its summary.Every other path exits non-zero.
cargo test --release -p d3d12_xs --lib: 477 passed, 4 failed, 39 ignored. The 4 failures also occur on plainmain(alias::tests::msaa_depth_with_a_larger_pc_layout_never_overlaps_the_next_title_placement,placed_offset::tests::uneven_views_get_exact_helpers_and_msaa_shares_the_alias_heap,title_shadow::tests::buffer_then_texture_migrates_to_one_local_heap_and_keeps_bytes,xs_exports::console_fixed_tests::fixed_result_dxgix_exports_match_every_console_d3d12_xs) and are unrelated to this change.Native Windows 11; not run under Proton. Not verified in a title with this repo's build; the scenario test above runs against a real window.
cargo test -p d3d12_xspasses (the 4 failures also occur onmain)No game or console files and no binaries included
No fake success; anything not possible is left
missingwith a note@omonkeyz on GitHub · 2026-11-22 16:28 UTC · original
Applied in
1570be5(merged in604b5a1) with your authorship kept, thanks! I removed one trailing//comment in the test, and fixed a conflict in THIRD_PARTY/CREDITS with #151 by keeping both additions on the TomBox line.Pull request closed