Skip to content

expose macOS's native window cascading API (cascadeTopLeft(from:)) #4762

@aaadotpm

Description

@aaadotpm

Is your feature request related to a problem? Please describe.

I have multiple windows in my app, and I would like to use macOSs default behaviour for positioning windows.

Describe the solution you'd like

Expose cascadeTopLeft(from:) so we can use it from window := app.Window.NewWithOptions(application.WebviewWindowOptions{}) or window.SetPosition() 🙏

Describe alternatives you've considered

This does the trick for now, setting the cascadeOffset to 32, seems to be about right for macOS Tahoe, but I suspect it's smaller for earlier versions of macOS.

// Apply cascade offset for subsequent windows
if windowCount > 0 {
  // Get current position (first window will be centered by OS)
  // Then offset based on window count
  offset := windowCount * cascadeOffset
  // Position relative to top-left, accounting for menubar
  window.SetRelativePosition(100+offset, 100+offset)
}
windowCount++

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions