fix(darwin): make Position() and SetPosition() use consistent coordinate systems#4818
Conversation
…ate systems On macOS, windowGetPosition() was returning raw Cocoa coordinates (Y=0 at bottom of screen) while windowSetPosition() expected coordinates with Y=0 at the top of the screen. This caused window positions to drift when saving and restoring window state across application sessions. The fix updates windowGetPosition() to: 1. Convert Y coordinates to top-origin (matching windowSetPosition) 2. Apply DPI scale factor (matching windowSetPosition) This ensures Position() returns values that can be directly passed back to SetPosition() for consistent round-trip behavior. Fixes #4816 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. WalkthroughFix macOS window coordinate inconsistency: Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Possibly related PRs
Suggested labels
Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
v3/pkg/application/webview_window_darwin.go (1)
1434-1448: Consider updating the TODO comment about DPI scaling.The
bounds()function now callswindowGetPosition()which applies DPI scaling (returning pixels), butwindowGetSize()returns points without scaling. This creates an inconsistency whereXandYare in pixels butWidthandHeightare in points.While this is acknowledged by the TODO comment and is out of scope for this PR, you might want to update the TODO to be more specific about this mixed-unit issue to help guide future work.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
v3/pkg/application/webview_window_darwin.go(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
- GitHub Check: Run Go Tests v3 (windows-latest, 1.24)
- GitHub Check: Run Go Tests v3 (ubuntu-latest, 1.24)
- GitHub Check: Run Go Tests v3 (macos-latest, 1.24)
- GitHub Check: semgrep/ci
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: Analyze (go)
- GitHub Check: Cloudflare Pages
🔇 Additional comments (1)
v3/pkg/application/webview_window_darwin.go (1)
574-587: LGTM! Coordinate system fix correctly implemented.The implementation correctly addresses the inconsistency by:
- Applying DPI scaling via
backingScaleFactorto both X and Y coordinates- Converting Y from macOS native bottom-origin to top-origin coordinates using
(screenFrame.size.height - frame.origin.y - frame.size.height)The transformations are mathematically inverse to those in
windowSetPosition(), ensuring proper round-trip behavior when saving and restoring window positions.
|
…ate systems On macOS, windowGetPosition() was returning raw Cocoa coordinates (Y=0 at bottom of screen) while windowSetPosition() expected coordinates with Y=0 at the top of the screen. This caused window positions to drift when saving and restoring window state across application sessions. The fix updates windowGetPosition() to: 1. Convert Y coordinates to top-origin (matching windowSetPosition) 2. Apply DPI scale factor (matching windowSetPosition) This ensures Position() returns values that can be directly passed back to SetPosition() for consistent round-trip behavior. Fixes #4816 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
|
|
…ate systems (wailsapp#4818) * fix(darwin): make Position() and SetPosition() use consistent coordinate systems On macOS, windowGetPosition() was returning raw Cocoa coordinates (Y=0 at bottom of screen) while windowSetPosition() expected coordinates with Y=0 at the top of the screen. This caused window positions to drift when saving and restoring window state across application sessions. The fix updates windowGetPosition() to: 1. Convert Y coordinates to top-origin (matching windowSetPosition) 2. Apply DPI scale factor (matching windowSetPosition) This ensures Position() returns values that can be directly passed back to SetPosition() for consistent round-trip behavior. Fixes wailsapp#4816 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix(darwin): make Position() and SetPosition() use consistent coordinate systems On macOS, windowGetPosition() was returning raw Cocoa coordinates (Y=0 at bottom of screen) while windowSetPosition() expected coordinates with Y=0 at the top of the screen. This caused window positions to drift when saving and restoring window state across application sessions. The fix updates windowGetPosition() to: 1. Convert Y coordinates to top-origin (matching windowSetPosition) 2. Apply DPI scale factor (matching windowSetPosition) This ensures Position() returns values that can be directly passed back to SetPosition() for consistent round-trip behavior. Fixes wailsapp#4816 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>



Summary
Position()andSetPosition()on macOSwindowGetPosition()now converts Y coordinates to top-origin (matchingwindowSetPosition())windowGetPosition()now applies DPI scale factor (matchingwindowSetPosition())This ensures window positions can be saved and restored correctly across application sessions.
Test plan
Position()values can be passed directly toSetPosition()for consistent round-trip behaviorFixes #4816
🤖 Generated with Claude Code
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.