mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 23:35:53 +01:00
[PR #2344] lifecycle: subclass the title window in its own character set (LIFECYCLE-ANSI-SUBCLASS) #2347
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#2347
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/2344
Author: @syfyra
Created: 11/26/2026
Status: 🔄 Open
Base:
main← Head:fix/lifecycle-ansi-subclass📝 Commits (1)
9206032lifecycle: subclass the title window in its own character set (LIFECYCLE-ANSI-SUBCLASS)📊 Changes
4 files changed (+107 additions, -7 deletions)
View changed files
📝
runtime/CMakeLists.txt(+18 -0)📝
runtime/shims/lifecycle.cpp(+25 -6)📝
runtime/test/lifecycle_test.cpp(+54 -1)➕
runtime/test/utf8_codepage.manifest(+10 -0)📄 Description
Claimed in the coordination issue as: LIFECYCLE-ANSI-SUBCLASS
What and why
runtime/shims/lifecycle.cppsubclasses the title's first top-level window soSC_CLOSEruns the suspend callbacks. It always did so withGetWindowLongPtrW/SetWindowLongPtrW. The retail title creates its window withCreateWindowExA(its import table names it from the-ansi-window set), which makes an ANSI window when the class was registered with the A function too; the title's class registration is not recorded indocs/, so whether the retail window is ANSI is not measured here. Setting a W procedure on an ANSI window turns it into a Unicode window:IsWindowUnicodebecomesTRUE, and every text message the title posts and dispatches with the A functions is converted to Unicode for the hook.CallWindowProcWthen converts it back for the title's ANSI procedure.With a single-byte code page the round trip is lossless. With UTF-8 as the ANSI code page it is not. That is the code page of Windows' "Beta: Use Unicode UTF-8 for worldwide language support" option, or of a process whose manifest asks for it. Measured on Windows 11 with a small probe, an ANSI window with
PostMessageA(WM_CHAR, byte)for each byte of "é€" (C3 A9 E2 82 AC), thenDispatchMessageA:c3 a9 e2 82 acSetWindowLongPtrW(main)83 c3 a9 c2 a2 c3 80 e2 ac c2SetWindowLongPtrA(this change)c3 a9 e2 82 acWith code page 1252 all three receive the bytes unchanged. Only
IsWindowUnicodediffers there.The hook now reads and sets the window procedure in the window's own character set (
IsWindowUnicode), with an A and a W variant of the procedure that call the title's withCallWindowProcA/CallWindowProcWand fall back toDefWindowProcA/DefWindowProcW. A Unicode window is hooked as before.Tested
Windows 11, MSVC 14.44 (Build Tools), RelWithDebInfo:
lifecycle_testgets a section 5. An ANSI class's window is created through theCreateWindowExAshim, and the test checks that it is hooked, that it stays an ANSI window, that the fiveWM_CHARcodes reach its procedure unchanged and in order, and thatWM_SETTEXT/WM_GETTEXTstill forward. A further check confirms a Unicode title window stays Unicode.main: 1 of 35 checks fails (the window becomes Unicode).lifecycle_utf8_test(MSVC only): the same source withtest/utf8_codepage.manifestembedded (activeCodePageUTF-8), plus a check thatGetACP()is 65001.main: 2 of 36 checks fail; the title's procedure receives83 c3 a9 c2 a2 c3 80 e2 ac c2.ctest -j 8over the 170 CPU tests (no Vulkan SDK here): all pass.runtime/CMakeLists.txt,runtime/shims/lifecycle.cpporruntime/test/lifecycle_test.cpp, including #2054.scripts/check_no_game_data.pyon the four files.Not tested under Wine, where the manifest test may need Wine's own
activeCodePagesupport.GPUs tested: n/a (CPU tests)
AI-assisted: yes (Claude Code, Claude Opus 5.5)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.