Description
Position() and SetPosition() on macOS use inconsistent Y coordinate systems, causing window position drift when saving and restoring window state.
This appears to be a regression of #3478 which was fixed in #3479.
Environment
- Wails v3.0.0-alpha.48
- macOS 15.5 (Sequoia)
- Go 1.21.4
Root Cause
In pkg/application/webview_window_darwin.go:
windowGetPosition (lines 575-579) returns raw macOS coordinates:
void windowGetPosition(void* nsWindow, int* x, int* y) {
NSRect frame = [(WebviewWindow*)nsWindow frame];
*x = frame.origin.x;
*y = frame.origin.y; // ❌ Raw macOS Y (origin at screen BOTTOM)
}
windowSetPosition (lines 581-595) expects Y from TOP and converts:
void windowSetPosition(void* nsWindow, int x, int y) {
// ...
frame.origin.y = (screen.frame.size.height - frame.size.height) - (y / scale);
// Expects Y from TOP, converts to macOS bottom-origin
}
Workaround
Use RelativePosition() / SetRelativePosition() instead, which are consistently implemented.
To Reproduce
- Get window position with
Position()
- Close app, save the coordinates
- On next launch, restore with
SetPosition(x, y)
- Observe window has moved vertically
Example logs:
[WindowState] Restoring size: width=636, height=610
[WindowState] App launched, setting position: x=819, y=445
...
[WindowState] WindowClosing: Saving x=819, y=25, width=635, height=610
The Y coordinate changed from 445 to 25 without user moving the window.
Expected behaviour
windowGetPosition should apply the same coordinate conversion as windowGetRelativePosition (line 571):
y = screenFrame.size.height - frame.origin.y - frame.size.height;
This would make Position() return Y measured from the top of the screen, consistent with what SetPosition() expects.
Screenshots
No response
Attempted Fixes
Use RelativePosition() / SetRelativePosition() instead, which are consistently implemented.
System Details
wails3 doctor
Wails (v3.0.0-alpha.48) Wails Doctor
# System
┌──────────────────────────────────────────────────┐
| Name | MacOS |
| Version | 15.5 |
| ID | 24F74 |
| Branding | Sequoia |
| Platform | darwin |
| Architecture | arm64 |
| Apple Silicon | true |
| CPU | Apple M4 Max |
| CPU 1 | Apple M4 Max |
| CPU 2 | Apple M4 Max |
| GPU | 40 cores, Metal Support: Metal 3 |
| Memory | 64 GB |
└──────────────────────────────────────────────────┘
# Build Environment
┌─────────────────────────────────────────────────────────────────────────────────────────────────────┐
| Wails CLI | v3.0.0-alpha.48 |
| Go Version | go1.25.2 |
| -buildmode | exe |
| -compiler | gc |
| CGO_CFLAGS | |
| CGO_CPPFLAGS | |
| CGO_CXXFLAGS | |
| CGO_ENABLED | 1 |
| CGO_LDFLAGS | |
| DefaultGODEBUG | containermaxprocs=0,decoratemappings=0,tlssha1=1,updatemaxprocs=0,x509sha256skid=0 |
| GOARCH | arm64 |
| GOARM64 | v8.0 |
| GOOS | darwin |
└─────────────────────────────────────────────────────────────────────────────────────────────────────┘
# Dependencies
┌───────────────────────────────────────────────────────────────────────────────────┐
| Xcode cli tools | 2409 |
| npm | 11.3.0 |
| *NSIS | Not Installed. Install with `brew install makensis`. |
| docker | *Docker version 28.5.2, build ecc6942 (cross-compilation ready) |
| |
└───────────────────────────── * - Optional Dependency ─────────────────────────────┘
# Checking for issues
SUCCESS No issues found
# Diagnosis
SUCCESS Your system is ready for Wails development!
Need documentation? Run: wails3 docs
♥ If Wails is useful to you or your company, please consider sponsoring the project: wails3 sponsor
Additional context
No response
Description
Position()andSetPosition()on macOS use inconsistent Y coordinate systems, causing window position drift when saving and restoring window state.This appears to be a regression of #3478 which was fixed in #3479.
Environment
Root Cause
In
pkg/application/webview_window_darwin.go:windowGetPosition(lines 575-579) returns raw macOS coordinates:windowSetPosition(lines 581-595) expects Y from TOP and converts:Workaround
Use
RelativePosition()/SetRelativePosition()instead, which are consistently implemented.To Reproduce
Position()SetPosition(x, y)Example logs:
The Y coordinate changed from 445 to 25 without user moving the window.
Expected behaviour
windowGetPositionshould apply the same coordinate conversion aswindowGetRelativePosition(line 571):This would make
Position()return Y measured from the top of the screen, consistent with whatSetPosition()expects.Screenshots
No response
Attempted Fixes
Use
RelativePosition()/SetRelativePosition()instead, which are consistently implemented.System Details
Additional context
No response