Window: VICTORY_CAPTION sets the window caption #434

Open
github-bot wants to merge 4 commits from github-bot/gh-434 into main AGit
Owner

@⁠sennecools on GitHub · 2026-11-25 00:49 UTC · original
sennecools:contrib/window-caption → main · +1108 −85 · 15 files · 4 commits · open

Depends on "Window: configurable size ([window] size) ..." (it changes make_window() and the CreateWindowEx hooks as that PR leaves them); review after it, or this PR's diff also shows that one's commits.

VICTORY_CAPTION=<text> replaces the caption of the window victory-gpu presents in (default VIctory) and of the title's own top-level windows when they are created, e.g. to show a neutral caption while the screen is shared. A window the title creates with CreateWindowExA gets the caption converted to the ANSI code page, as that call expects. The frame meter appended to the caption no longer adds the project's name itself; it follows whatever the caption is (our window reads "VIctory | N fps ..." instead of "VIctory | VIctory N fps ...").

Limitation: text the title sets on its own windows later is not replaced; those windows are kept hidden by the title, so the caption on screen is the one of the presenting window.

README: the variable is added to the environment table.

Testing: unit test for the ANSI conversion; cargo test (WARP) and clippy pass for victory-gpu and victory-hle. Not verified in a title run on this branch.

This change has also been part of our local combined build, which ran the title in the game on an RX 9070 XT (D3D12, Windows 11) several times tonight without problems from it.

AI-assisted.

**@⁠sennecools** on GitHub · 2026-11-25 00:49 UTC · [original](https://github.com/fxceless/victory-fork/pull/434) `sennecools:contrib/window-caption` → `main` · +1108 −85 · 15 files · 4 commits · open Depends on "Window: configurable size ([window] size) ..." (it changes make_window() and the CreateWindowEx hooks as that PR leaves them); review after it, or this PR's diff also shows that one's commits. `VICTORY_CAPTION=<text>` replaces the caption of the window victory-gpu presents in (default `VIctory`) and of the title's own top-level windows when they are created, e.g. to show a neutral caption while the screen is shared. A window the title creates with CreateWindowExA gets the caption converted to the ANSI code page, as that call expects. The frame meter appended to the caption no longer adds the project's name itself; it follows whatever the caption is (our window reads "VIctory | N fps ..." instead of "VIctory | VIctory N fps ..."). Limitation: text the title sets on its own windows later is not replaced; those windows are kept hidden by the title, so the caption on screen is the one of the presenting window. README: the variable is added to the environment table. Testing: unit test for the ANSI conversion; `cargo test` (WARP) and clippy pass for victory-gpu and victory-hle. Not verified in a title run on this branch. This change has also been part of our local combined build, which ran the title in the game on an RX 9070 XT (D3D12, Windows 11) several times tonight without problems from it. AI-assisted.
A console title sizes its window to its render target, which on a 4K screen fills the whole screen. [window] size in victory.toml, or VICTORY_WINDOW_SIZE, now chooses the window instead: "title" (the default, as before: the title's size shrunk to the work area), "<width>x<height>" (a client area of that size, centred, shrunk to the work area if it does not fit), or "fullscreen" (borderless over the primary screen). Only the window changes; the title renders at its own size and the swap chain stretches the frame to the window.

victory now makes itself per-monitor DPI aware before any window exists, so sizes are physical pixels: on a screen scaled to 150 %, 1920x1080 is a quarter of a 4K screen, not 2880x1620. The client size is estimated with AdjustWindowRectExForDpi and corrected after creation if the real frame differs. The placement is a pure function, tested per mode without a screen.

(cherry picked from commit 3ec3bc906c17d45438a8ec411551a150a86b0a16)

AI-assisted (Claude Code)
The title keeps its own windows hidden, so the window on screen is the one victory-gpu makes to present to, sized to the frame (3840x2160 for this title) and placed by Windows. The placement moves to victory-gpu's window module: in "title" mode that window is now fitted to the work area and centred, "<width>x<height>" sets its client area, "fullscreen" makes it a borderless popup over the primary screen. It is created hidden and shown once its client size is right. The title's own windows only keep the existing shrink-to-the-screen fit: the title may read back its client size or styles, so they are not resized or restyled.

Closing that window (close button, Alt+F4, the taskbar) now ends the title through the same suspend path as closing the title's window, via a callback victory-hle registers; before, the window was destroyed and the title ran on without one. The window menu (Alt, F10) is ignored, so the keyboard pad cannot drive it.

(cherry picked from commit f036d84e77868a3b14850157e502377c70aee7a9)

AI-assisted (Claude Code)
The window we present in and the title's own top-level windows take their caption from VICTORY_CAPTION when it is set, so a shared screen can show a neutral one. A title window made with CreateWindowExA gets it in the ANSI code page, as that call expects. The frame meter in the caption no longer adds the project's name; it follows whatever the caption is.

(cherry picked from commit 23e52663159edb528295545a75881735fa6a0623)

AI-assisted (Claude Code)
The caption test assumed a single-byte ANSI code page and failed on a
double-byte one such as 936, where the accented letter takes two bytes.
The encoder now takes its code page, a new test checks the bytes for
1252, 936 and UTF-8 on any machine, and the length check on the active
code page runs only when that code page is single-byte.

AI-assisted (Claude Code)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:43:13 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-25 00:53 UTC · original

Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-25T00:53:39.842609Z d39096b PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@⁠codex review" or "@⁠codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-25 00:53 UTC · [original](https://github.com/fxceless/victory-fork/pull/434#issuecomment-7148998414) <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"d39096b88ab582ed973d562ae3cd150f4cc5c56e","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-25T00:53:39.842609Z">2026-11-25T00:53:39.842609Z</relative-time> | `d39096b` | PR opened | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@⁠codex review" or "@⁠codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-25 00:53 UTC · original
On crates/victory-hle/src/modules/lifecycle.rs line 404 (outdated):

@@ -332,19 +392,17 @@ mod tests {
     }
 
     #[test]
-    fn oversized_windows_shrink_to_the_screen() {
-        let area = RECT {
-            left: 0,
-            top: 0,
-            right: 1920,
-            bottom: 1040,
-        };
-        assert_eq!(fit_into(&area, 3840, 2160), (1848, 1040));
-        assert_eq!(fit_into(&area, 1280, 720), (1280, 720));
-        assert_eq!(
-            fit_into(&area, wm::CW_USEDEFAULT, 0),
-            (wm::CW_USEDEFAULT, 0)
-        );
+    fn an_ansi_caption_is_in_the_code_page_and_terminated() {
+        assert_eq!(ansi("Neutral caption"), b"Neutral caption\0");
+        assert_eq!(ansi("a\0b"), b"ab\0");
+        assert_eq!(ansi(""), b"\0");
+        // Not passed on as UTF-8 bytes (unless the code page is UTF-8):
+        // one byte per character, whatever the code page makes of it.
+        use windows_sys::Win32::Globalization::{CP_UTF8, GetACP};
+        // SAFETY: a plain query.
+        if unsafe { GetACP() } != CP_UTF8 {
+            assert_eq!(ansi("caf\u{e9}").len(), 5);

P2 Badge Remove the single-byte assumption from the ANSI caption test

On a Windows system using ACP 936 (Simplified Chinese), é encodes as two bytes (A8 A6), so the correctly converted café plus its terminator has length 6, not 5. The guard excludes only UTF-8 and therefore runs this invalid assertion for multibyte ANSI code pages, causing the victory-hle test suite to fail on those hosts. Restrict the fixed-length assertion to a known single-byte code page or compare against the expected encoding for the actual code page.

Useful? React with 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-25 00:53 UTC · [original](https://github.com/fxceless/victory-fork/pull/434#discussion_r4688703074) On `crates/victory-hle/src/modules/lifecycle.rs` line 404 (outdated): ```diff @@ -332,19 +392,17 @@ mod tests { } #[test] - fn oversized_windows_shrink_to_the_screen() { - let area = RECT { - left: 0, - top: 0, - right: 1920, - bottom: 1040, - }; - assert_eq!(fit_into(&area, 3840, 2160), (1848, 1040)); - assert_eq!(fit_into(&area, 1280, 720), (1280, 720)); - assert_eq!( - fit_into(&area, wm::CW_USEDEFAULT, 0), - (wm::CW_USEDEFAULT, 0) - ); + fn an_ansi_caption_is_in_the_code_page_and_terminated() { + assert_eq!(ansi("Neutral caption"), b"Neutral caption\0"); + assert_eq!(ansi("a\0b"), b"ab\0"); + assert_eq!(ansi(""), b"\0"); + // Not passed on as UTF-8 bytes (unless the code page is UTF-8): + // one byte per character, whatever the code page makes of it. + use windows_sys::Win32::Globalization::{CP_UTF8, GetACP}; + // SAFETY: a plain query. + if unsafe { GetACP() } != CP_UTF8 { + assert_eq!(ansi("caf\u{e9}").len(), 5); ``` **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Remove the single-byte assumption from the ANSI caption test** On a Windows system using ACP 936 (Simplified Chinese), `é` encodes as two bytes (`A8 A6`), so the correctly converted `café` plus its terminator has length 6, not 5. The guard excludes only UTF-8 and therefore runs this invalid assertion for multibyte ANSI code pages, causing the `victory-hle` test suite to fail on those hosts. Restrict the fixed-length assertion to a known single-byte code page or compare against the expected encoding for the actual code page. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
Author
Owner

@⁠sennecools on GitHub · 2026-11-25 02:05 UTC · original
On crates/victory-hle/src/modules/lifecycle.rs line 404 (outdated):

@@ -332,19 +392,17 @@ mod tests {
     }
 
     #[test]
-    fn oversized_windows_shrink_to_the_screen() {
-        let area = RECT {
-            left: 0,
-            top: 0,
-            right: 1920,
-            bottom: 1040,
-        };
-        assert_eq!(fit_into(&area, 3840, 2160), (1848, 1040));
-        assert_eq!(fit_into(&area, 1280, 720), (1280, 720));
-        assert_eq!(
-            fit_into(&area, wm::CW_USEDEFAULT, 0),
-            (wm::CW_USEDEFAULT, 0)
-        );
+    fn an_ansi_caption_is_in_the_code_page_and_terminated() {
+        assert_eq!(ansi("Neutral caption"), b"Neutral caption\0");
+        assert_eq!(ansi("a\0b"), b"ab\0");
+        assert_eq!(ansi(""), b"\0");
+        // Not passed on as UTF-8 bytes (unless the code page is UTF-8):
+        // one byte per character, whatever the code page makes of it.
+        use windows_sys::Win32::Globalization::{CP_UTF8, GetACP};
+        // SAFETY: a plain query.
+        if unsafe { GetACP() } != CP_UTF8 {
+            assert_eq!(ansi("caf\u{e9}").len(), 5);

Good catch: the length check assumed a single-byte ANSI code page and failed on double-byte ones such as 936.
The encoder now takes its code page, and a new test checks the exact bytes for 1252, 936 and UTF-8 on any machine.
The length check on the active code page now runs only when that code page is single-byte.

AI-assisted.

**@⁠sennecools** on GitHub · 2026-11-25 02:05 UTC · [original](https://github.com/fxceless/victory-fork/pull/434#discussion_r4689275925) On `crates/victory-hle/src/modules/lifecycle.rs` line 404 (outdated): ```diff @@ -332,19 +392,17 @@ mod tests { } #[test] - fn oversized_windows_shrink_to_the_screen() { - let area = RECT { - left: 0, - top: 0, - right: 1920, - bottom: 1040, - }; - assert_eq!(fit_into(&area, 3840, 2160), (1848, 1040)); - assert_eq!(fit_into(&area, 1280, 720), (1280, 720)); - assert_eq!( - fit_into(&area, wm::CW_USEDEFAULT, 0), - (wm::CW_USEDEFAULT, 0) - ); + fn an_ansi_caption_is_in_the_code_page_and_terminated() { + assert_eq!(ansi("Neutral caption"), b"Neutral caption\0"); + assert_eq!(ansi("a\0b"), b"ab\0"); + assert_eq!(ansi(""), b"\0"); + // Not passed on as UTF-8 bytes (unless the code page is UTF-8): + // one byte per character, whatever the code page makes of it. + use windows_sys::Win32::Globalization::{CP_UTF8, GetACP}; + // SAFETY: a plain query. + if unsafe { GetACP() } != CP_UTF8 { + assert_eq!(ansi("caf\u{e9}").len(), 5); ``` Good catch: the length check assumed a single-byte ANSI code page and failed on double-byte ones such as 936. The encoder now takes its code page, and a new test checks the exact bytes for 1252, 936 and UTF-8 on any machine. The length check on the active code page now runs only when that code page is single-byte. AI-assisted.
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/Cargo.toml
  • crates/victory-gpu/src/lib.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/434/head:github-bot/gh-434'
git switch 'github-bot/gh-434'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-434'
git switch 'github-bot/gh-434'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-434'
git switch 'github-bot/gh-434'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-434'
git switch 'main'
git merge --squash 'github-bot/gh-434'
git switch 'main'
git merge --ff-only 'github-bot/gh-434'
git switch 'main'
git merge 'github-bot/gh-434'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.