Repository navigation
fix(v3): report macOS and GTK screens in DIP space (mixed-DPI bounds) - #6346
Conversation
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes.
|
| Layer / File(s) | Summary |
|---|---|
DIP layout and field completion v3/pkg/application/screenmanager.go, v3/pkg/application/screenmanager_dip_test.go |
layoutDIPScreens retains screen positions, selects the primary screen, and rejects unusable input. It derives missing physical rectangles from DIP values and scale factors. Tests cover mixed-scale layouts, window-to-screen matching, field completion, and invalid inputs. |
Platform screen conversion and layout v3/pkg/application/screen_darwin.go, v3/pkg/application/screen_linux.go, v3/UNRELEASED_CHANGELOG.md |
macOS uses point-based bounds for logical geometry and scales physical rectangles. macOS and GTK use layoutDIPScreens. The changelog records the coordinate fix. |
Priority:
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix · Severity of issue fixed: Medium
Suggested reviewers: leaanthony
Merge Risk: 
Minimal · up to ff6a5
-
No known issue blocks merging. GTK hardware validation remains desirable but does not establish a defect.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Description check
-
Explanation
The description is complete and relevant. It explains the issue, implementation, affected platforms, testing, test configuration, and checklist status. It also links issue
#5409and notes that GTK hardware testing was not performed.
Full details: Linked Issues check
-
Explanation
#5409requires macOS mixed-DPI screen coordinates to remain in the logical coordinate space used by window positioning. The reviewed macOS code keepsBoundsandWorkAreacoordinates unscaled, scales onlyPhysical*rectangles, and passes enumerated screens tolayoutDIPScreens. That method preserves reported DIP positions and fillsSizeand physical bookkeeping without running the device-pixel placement walk. The added tests cover the reported 1x-primary and 2x-secondary-above arrangement, mixed-DPI coordinates, and finding a window on the second display.
Full details: Out of Scope Changes check
-
Explanation
The changes remain connected to
#5409. The sharedlayoutDIPScreensmethod implements the required already-DIP input contract. The GTK call-site change applies the same coordinate-space correction described by the PR. The tests verify the shared behavior, and the changelog records the fix. Windows, iOS, and Android retain their existingLayoutScreenspaths.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 62.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 4 files. (1 skipped: 1 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
A rabbit checks the screens at night,
Each keeps its bounds in points just right.
The scaled rectangles join the show,
Across mixed displays, positions flow.
Then carrots mark the tests as green.
Comment @coderabbitai help to get the list of available commands.
…ured in cScreenToScreen multiplied every NSScreen coordinate, origins included, by that screen's own backingScaleFactor, to synthesise the device-pixel input LayoutScreens expects and have applyDPIScaling divide it back out again. applyDPIScaling rescales sizes, not origins, so a non-primary screen's Bounds.X/Y were left in the scaled space (wailsapp#5409). A second fault sits behind that one. calculateScreensDipCoordinates is Chromium's screen_win algorithm, whose input contract is a single coherent device-pixel layout. Multiplying each screen's logical origin by its own scale factor does not produce one: displays that abut exactly in logical space stop abutting as soon as their scale factors differ, so findAndRemoveTouchingScreens never reaches the screen, no placement is applied to it and applyDPIScaling never runs on it at all. A 2x display beside a 1x primary therefore kept both a doubled origin and a doubled size. Windows reports a coherent device-pixel layout natively and continues to use LayoutScreens. macOS and GTK report logical coordinates against one shared origin, where a screen's DIP position can be read off rather than rebuilt, so both now feed layoutDIPScreens: it resolves the primary, completes the Size and Physical* bookkeeping, and positions nothing. On GTK3 this also stops a scaled display from reporting its work-area insets halved. The visible effect was that Screen.Bounds and Screen.WorkArea for such a display described a region no window is ever reported in. Code asking which screen a window occupied was told it occupied none of them, and an application that acts on that answer — moving a window it believes has been left off-screen — would haul every window on that display back to the primary. iOS and Android also report logical coordinates, but each has a single display at the origin, where both paths agree; they are left on LayoutScreens.
ff6a56b to
72ca78d
Compare
|
Thanks! These are tricky ones! |
… and GTK screens in DIP space (mixed-DPI bounds)
Description
Fixes #5409.
This implements the fix shape recommended in the triage of #5409: an explicit already-DIP input path, so macOS and GTK no longer go through the placement walk that assumes a coherent device-pixel layout.
cScreenToScreenmultiplied every NSScreen coordinate, origins included, by that screen's ownbackingScaleFactorto synthesise the device-pixel inputLayoutScreensexpects. That fails in two ways, both from the issue's triage:applyDPIScalingrescales sizes, not origins, so a non-primary screen'sBounds.X/Ystay in the scaled space.calculateScreensDipCoordinates(Chromium'sscreen_winalgorithm) needs one coherent device-pixel layout. Scaling each screen's logical origin by its own factor doesn't produce one: displays that abut in logical space stop abutting when their scale factors differ,findAndRemoveTouchingScreensnever reaches them, and they keep a doubled origin and a doubled size.macOS and GTK already report logical coordinates against one shared origin, so a screen's DIP position can be read off rather than rebuilt. Both now feed a new unexported
ScreenManager.layoutDIPScreens, which resolves the primary, fills inSizeand thePhysical*bookkeeping, and positions nothing. Windows reports a coherent device-pixel layout natively and keeps usingLayoutScreens. iOS and Android also stay onLayoutScreens: each has a single display at the origin, where both paths agree.It is a separate method rather than a per-platform constant inside
LayoutScreensso that the device-pixel path stays exactly as it is for Windows, and each path's input contract is stated in one place.Visible effect before the fix: on a mixed-DPI setup,
Screen.Bounds/WorkAreafor the scaled display described a region no window is ever reported in, so asking which screen a window was on returned none.On GTK3 this also stops a scaled display from reporting its work-area insets halved (for example a 32px panel reported as 16px). GTK4 has no work-area API, so it is unaffected there.
No public API change.
Type of change
How Has This Been Tested?
LayoutScreens);GOOS=windows go vet ./pkg/application/passes.screen_linux.go. It has not been run on GTK hardware, and a confirmation from a GTK3 HiDPI user would be welcome.New pure-Go tests in
screenmanager_dip_test.go(no display needed):TestLayoutDIPScreensKeepsMixedDPICoordinates: six mixed-DPI arrangements, including the issue's 2x display above a 1x primary.TestLayoutDIPScreensFindsWindowOnSecondDisplay: a window on the scaled display is found within that display's bounds.TestLayoutDIPScreensCompletesBookkeeping:SizeandPhysical*fields.TestLayoutDIPScreensRejectsUnusableInputandTestLayoutDIPScreensDropsNilEntries.go test ./pkg/application/passes on macOS 27.0.1 (arm64, Go 1.26.3).Test Configuration
Built from source at
masterb6167d9 + this commit; macOS 27.0.1 arm64, Go 1.26.3.Checklist:
Summary by CodeRabbit