Skip to content

[v3, macOS] RelativePosition() and SetRelativePosition() use inconsistent X coordinate spaces #5408

@leaanthony

Description

@leaanthony

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't workingMacOSP2Medium priorityinvestigatingThe bug is being investigatedv3

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions