Skip to content

Run a virtual iPhone on an Apple Silicon Mac.

Swift

Key the VM window scene to the VM path

Lakr233d280caa9e185
diff --git a/VPhoneExecutable/VPhoneVirtualization/UI/UserInterface/VPhoneVirtualMachineWindowController.swift b/VPhoneExecutable/VPhoneVirtualization/UI/UserInterface/VPhoneVirtualMachineWindowController.swift
index 2b53d75f..f08bb493 100644
--- a/VPhoneExecutable/VPhoneVirtualization/UI/UserInterface/VPhoneVirtualMachineWindowController.swift
+++ b/VPhoneExecutable/VPhoneVirtualization/UI/UserInterface/VPhoneVirtualMachineWindowController.swift
@@ -25,6 +25,7 @@ class VPhoneVirtualMachineWindowController: NSObject, NSToolbarDelegate {
keySender: VPhoneVirtualMachineKeySender,
control: VPhoneGuestControl,
ecid: String?,
+ sceneIdentifier: String,
) {
self.control = control
self.ecid = ecid
@@ -57,13 +58,16 @@ class VPhoneVirtualMachineWindowController: NSObject, NSToolbarDelegate {
window.title = VPhoneLocalization.text("vphone — Starting…")
window.subtitle = makeSubtitle(ip: nil)
window.contentView = vmView
- if let ecid {
- if !window.setFrameAutosaveName("vphone-\(ecid)") {
- window.center()
- }
- } else {
+
+ // The scene belongs to the VM, not to the app: every VM directory keeps
+ // its own window frame, and a newly created VM opens centered instead
+ // of inheriting the last frame another VM saved.
+ let sceneName = "vphone-scene-\(sceneIdentifier)"
+ window.identifier = NSUserInterfaceItemIdentifier(sceneName)
+ if !window.setFrameUsingName(sceneName) {
window.center()
}
+ window.setFrameAutosaveName(sceneName)
// Toolbar with unified style for two-line title
let toolbar = NSToolbar(identifier: "vphone-toolbar")
diff --git a/VPhoneExecutable/VPhoneVirtualization/UI/VPhoneVirtualMachineAppDelegate.swift b/VPhoneExecutable/VPhoneVirtualization/UI/VPhoneVirtualMachineAppDelegate.swift
index c04e1b22..16f82bbc 100644
--- a/VPhoneExecutable/VPhoneVirtualization/UI/VPhoneVirtualMachineAppDelegate.swift
+++ b/VPhoneExecutable/VPhoneVirtualization/UI/VPhoneVirtualMachineAppDelegate.swift
@@ -118,6 +118,11 @@ class VPhoneVirtualMachineAppDelegate: NSObject, NSApplicationDelegate {
keySender: keySender,
control: control,
ecid: vm.ecidHex,
+ sceneIdentifier: options.configURL
+ .deletingLastPathComponent()
+ .standardizedFileURL
+ .resolvingSymlinksInPath()
+ .path,
)
windowController = wc