Fix halved Screen Bounds, WorkArea, and Size on Retina Macs#5168
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughConverts NSScreen point-based coordinates and dimensions to device pixels in Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
v3/pkg/application/screen_darwin.go (1)
128-178:⚠️ Potential issue | 🔴 CriticalTop-level
Screen.X/Yare not rescaled byapplyDPIScaling(), breaking the invariant that they must mirrorBounds.X/Y.The
applyDPIScaling()implementation (screenmanager.go:289–306) rescalesBounds,WorkArea, andSize, but does not touch top-levelScreen.XorScreen.Y. After your change, both will initially be in device pixels fromtoPhysical(), butapplyDPIScaling()will divideBounds.X/Yinto DIPs while leaving the top-levelX/Yin device pixels. This violates the documented invariant thatScreen.X/Ymust mirrorBounds.X/Y(which is relied upon bymove(),areScreensTouching(), andcalculateScreenPlacement()). Either extendapplyDPIScaling()to rescale top-levelX/Y, or set them here to unscaled point values so they align with post-scalingBounds.Note:
Sizeis handled correctly—it is reassigned to match scaledBoundsat lines 304–305, so it will end up in DIPs as intended.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@v3/pkg/application/screen_darwin.go` around lines 128 - 178, cScreenToScreen currently sets top-level Screen.X and Screen.Y using toPhysical (device pixels) while applyDPIScaling rescales Bounds.* into DIPs, breaking the invariant that Screen.X/Y mirror Bounds.X/Y; fix by making Screen.X and Screen.Y use the unscaled point values (i.e., use the raw screen.x/screen.y points rather than toPhysical) so they match Bounds after applyDPIScaling, or alternatively update applyDPIScaling to also rescale top-level Screen.X/Screen.Y (modify applyDPIScaling in screenmanager.go to divide Screen.X/Screen.Y by ScaleFactor); update cScreenToScreen or applyDPIScaling accordingly (see function cScreenToScreen, struct Screen, and applyDPIScaling).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@v3/pkg/application/screen_darwin.go`:
- Around line 128-178: cScreenToScreen currently sets top-level Screen.X and
Screen.Y using toPhysical (device pixels) while applyDPIScaling rescales
Bounds.* into DIPs, breaking the invariant that Screen.X/Y mirror Bounds.X/Y;
fix by making Screen.X and Screen.Y use the unscaled point values (i.e., use the
raw screen.x/screen.y points rather than toPhysical) so they match Bounds after
applyDPIScaling, or alternatively update applyDPIScaling to also rescale
top-level Screen.X/Screen.Y (modify applyDPIScaling in screenmanager.go to
divide Screen.X/Screen.Y by ScaleFactor); update cScreenToScreen or
applyDPIScaling accordingly (see function cScreenToScreen, struct Screen, and
applyDPIScaling).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: ff8fe672-0bdc-4792-ac3e-8f90dfb80649
📒 Files selected for processing (2)
v3/UNRELEASED_CHANGELOG.mdv3/pkg/application/screen_darwin.go
|
wails3 doctor System┌──────────────────────────────────────────────────┐ Build Environment┌────────────────────────────────┐ Dependencies┌──────────────────────────────────────────────────────────────────────────────┐ Checking for issuesSUCCESS No issues found |
|
Thanks for the PR! This looks good to me, I believe @leaanthony setup an automated change log? Lea does this mean PR's shouldnt include change to Pending that clarification good to merge imo |
|
Hi @leaanthony - Can you please update what to do regarding the |
|
Thanks @wayneforrest 🙏 |
Description
Fix halved Screen Bounds, WorkArea, and Size on Retina Macs.
With the Fix.
INFO[15:44:17.959] [screen-probe] [0] scale=2.00 size=1496x967 bounds={X:0 Y:0
Width:1496 Height:967} physicalBounds={X:0 Y:0 Width:2992 Height:1934} workArea={X:0
Y:80 Width:1496 Height:858} physicalWorkArea={X:0 Y:160 Width:2992 Height:1716}
Without the Fix.
INFO[15:47:10.655] [screen-probe] [0] scale=2.00 size=748x484 bounds={X:0 Y:0 Width:748 Height:484} physicalBounds={X:0 Y:0 Width:1496 Height:967} workArea={X:0 Y:40 Width:748 Height:429} physicalWorkArea={X:0 Y:80 Width:1496 Height:858}
Fixes #5167
Type of change
Please select the option that is relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration using
wails doctor.If you checked Linux, please specify the distro and version.
Test Configuration
Please paste the output of
wails doctor. If you are unable to run this command, please describe your environment in as much detail as possible.Checklist:
website/src/pages/changelog.mdxwith details of this PRSummary by CodeRabbit