Description
On macOS, RelativePosition() and SetRelativePosition() disagree about what the X coordinate means:
RelativePosition() returns the absolute X (NSScreen logical points, not screen-relative)
SetRelativePosition() treats X as screen-relative (relative to the current screen's left edge)
So w.SetRelativePosition(w.RelativePosition()) does not round-trip on any screen that is not at NSScreen x=0. The Y axis is correctly screen-relative on both sides.
This was flagged by @flofreud while reviewing the coordinate normalization in #5117 / #5304:
Also has a separate inconsistency: Get returns absolute X, Set treats X as screen-relative.
— #5117 (comment)
Expected Behavior
Both RelativePosition() and SetRelativePosition() should operate in the same space. Given the method name and the docstring ("position of the window relative to the screen WorkArea on which it is"), both should be screen-WorkArea-relative, Y-down, in logical points.
Suggested Fix
In pkg/application/webview_window_darwin.go, in the windowGetRelativePosition cgo function, subtract the current screen's frame.origin.x (or visibleFrame.origin.x to match the WorkArea wording) before returning so it mirrors what windowSetRelativePosition consumes.
Notes
Environment
- Wails v3 (
pkg/application/webview_window_darwin.go)
- macOS
Related
Description
On macOS,
RelativePosition()andSetRelativePosition()disagree about what the X coordinate means:RelativePosition()returns the absolute X (NSScreen logical points, not screen-relative)SetRelativePosition()treats X as screen-relative (relative to the current screen's left edge)So
w.SetRelativePosition(w.RelativePosition())does not round-trip on any screen that is not at NSScreenx=0. The Y axis is correctly screen-relative on both sides.This was flagged by @flofreud while reviewing the coordinate normalization in #5117 / #5304:
— #5117 (comment)
Expected Behavior
Both
RelativePosition()andSetRelativePosition()should operate in the same space. Given the method name and the docstring ("position of the window relative to the screen WorkArea on which it is"), both should be screen-WorkArea-relative, Y-down, in logical points.Suggested Fix
In
pkg/application/webview_window_darwin.go, in thewindowGetRelativePositioncgo function, subtract the current screen'sframe.origin.x(orvisibleFrame.origin.xto match the WorkArea wording) before returning so it mirrors whatwindowSetRelativePositionconsumes.Notes
frame.Environment
pkg/application/webview_window_darwin.go)Related