[pr-feature][rendering] Retain window client aspect ratio when resizing #34

Open
ggwp wants to merge 1 commit from ggwp/Darner:feat/window-aspect-ratio into main
Contributor

Fluxer ID: FomalhautCusimanse#7381

What it changes

Dragging any edge or corner of the windowed game let it stretch freely to arbitrary proportions, distorting the swap chain picture.

  • Exposes darner_gpu::swap_chain_size() and updates it whenever the host swap chain is created or resized (ResizeBuffers), so the window hook always locks to the live rendered aspect ratio (16:9, 21:9, etc.).
  • Remembers each top-level title window's initial size in lifecycle.rs as a fallback before the swap chain exists (cleaned up on WM_NCDESTROY).
  • Handles WM_SIZING on top-level, on-screen windows in window_proc via retain_aspect_rect, subtracting live window chrome (GetWindowRect minus GetClientRect) so the client area keeps exact proportions, anchoring the opposite edge or corner across all 8 WMSZ_* handles, and clamping to a proportional minimum size (160 px on the longer axis).
  • Enabled by default; DARNER_LOCK_ASPECT=0 restores free stretching. Documented in README.md.

How it was tested

  • Tested revision: 39a15c0 on main (4a92569).
  • Commands and results:
  • cargo xtask policy: passed (542 files ok)
  • cargo clippy -p darner-gpu -p darner-hle --all-targets --all-features --locked: passed
  • cargo test -p darner-hle --locked lifecycle: passed (23 passed, 0 failed), including unit tests for all edges, corners, chrome offsets, minimum clamp, and a live Win32 WM_SIZING SendMessageW test
  • Coverage gaps: Full workspace cargo test --workspace --locked and multi-monitor DPI drag sweep were not run.

Checklist

  • This PR contains one change based on main.
  • The diff follows docs/asset-policy.md.
  • I recorded this PR's dependencies below.
  • Depends on: none

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
  • Related PRs: none found (open PR #3 is unrelated).
Fluxer ID: FomalhautCusimanse#7381 ## What it changes Dragging any edge or corner of the windowed game let it stretch freely to arbitrary proportions, distorting the swap chain picture. - Exposes `darner_gpu::swap_chain_size()` and updates it whenever the host swap chain is created or resized (`ResizeBuffers`), so the window hook always locks to the live rendered aspect ratio (16:9, 21:9, etc.). - Remembers each top-level title window's initial size in `lifecycle.rs` as a fallback before the swap chain exists (cleaned up on `WM_NCDESTROY`). - Handles `WM_SIZING` on top-level, on-screen windows in `window_proc` via `retain_aspect_rect`, subtracting live window chrome (`GetWindowRect` minus `GetClientRect`) so the **client area** keeps exact proportions, anchoring the opposite edge or corner across all 8 `WMSZ_*` handles, and clamping to a proportional minimum size (160 px on the longer axis). - Enabled by default; `DARNER_LOCK_ASPECT=0` restores free stretching. Documented in `README.md`. ## How it was tested - Tested revision: `39a15c0` on `main` (`4a92569`). - Commands and results: - `cargo xtask policy`: passed (`542 files ok`) - `cargo clippy -p darner-gpu -p darner-hle --all-targets --all-features --locked`: passed - `cargo test -p darner-hle --locked lifecycle`: passed (23 passed, 0 failed), including unit tests for all edges, corners, chrome offsets, minimum clamp, and a live Win32 `WM_SIZING` `SendMessageW` test - Coverage gaps: Full workspace `cargo test --workspace --locked` and multi-monitor DPI drag sweep were not run. ## Checklist - [x] This PR contains one change based on `main`. - [x] The diff follows `docs/asset-policy.md`. - [x] I recorded this PR's dependencies below. - Depends on: none ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. - Related PRs: none found (open PR #3 is unrelated).
Expose the host swap chain size from darner_gpu and handle WM_SIZING on top-level title windows in lifecycle.rs so drag-resizing from any edge or corner preserves the rendered picture aspect ratio inside the client area (accounting for window borders and title bar). Enabled by default; DARNER_LOCK_ASPECT=0 restores free stretching.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'feat/window-aspect-ratio:ggwp-feat/window-aspect-ratio'
git switch 'ggwp-feat/window-aspect-ratio'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'ggwp-feat/window-aspect-ratio'
git switch 'ggwp-feat/window-aspect-ratio'
git rebase 'main'
git switch 'main'
git merge --ff-only 'ggwp-feat/window-aspect-ratio'
git switch 'ggwp-feat/window-aspect-ratio'
git rebase 'main'
git switch 'main'
git merge --no-ff 'ggwp-feat/window-aspect-ratio'
git switch 'main'
git merge --squash 'ggwp-feat/window-aspect-ratio'
git switch 'main'
git merge --ff-only 'ggwp-feat/window-aspect-ratio'
git switch 'main'
git merge 'ggwp-feat/window-aspect-ratio'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
TrustNo1/Darner!34
No description provided.