Restore window positions on visionOS

If I create several windows (using the openWindow @Environment wrapper), and the user moves them around on-screen, is there a way to automatically have the system restore them when the app is re-launched?

Hi @benfromchicago , you cannot control where these are placed, they are opened where the user is looking. The visionOS docs mention this: "In visionOS, the system places new windows directly in front of people, where they happen to be gazing at the moment the window opens. This helps to ensure that people become aware of newly opened windows."

https://developer.apple.com/documentation/visionos/positioning-and-sizing-windows

@benfromchicago , they are still reopened where the user is gazing. So yes, some of them may be overlapping. I ran some tests where I opened a few windows & repositioned them, looked in another direction entirely & went to the home screen and reopened the app. The opened windows appeared where I was looking (clustered together, mostly overlapping). I did not quit the app, I left it open and turned in another direction. Remember, the sensation of "quitting" the app is much different in visionOS since you close individual windows instead of just quitting an entire app.

This would be helpful. When calling the Swift openURL() method, Safari is opening at the origin (below the camera) instead of in front of the user.

If I open Safari via the home page, it opens in front of the user. Seems like a bug with Vision OS.

Wouldn’t it make sense to save windows’ positions relative to each other under a root hierarchy, rather than having them overlap upon re-launching the app? You could have the windows appear relative to the user’s gaze, with the local hierarchy preserved.

In other words, in the visionOS internals, save the cluster of windows under a root transform that saves the positions. When the user returns to the app, restore the windows relative to the user’s gaze, but use the saved hierarchy of windows to position them as they were before, just repositioned with respect to the user’s new initial viewpoint.

Restore window positions on visionOS
 
 
Q