Run a virtual iPhone on an Apple Silicon Mac.
Swift
Duo: take a guest-side fold once two window reads agree
Jacky01c73ead3644
diff --git a/Research/Guest/iphone_duo_bringup.md b/Research/Guest/iphone_duo_bringup.mdindex 9158d5ac..2a0d2424 100644--- a/Research/Guest/iphone_duo_bringup.md+++ b/Research/Guest/iphone_duo_bringup.md@@ -5084,7 +5084,9 @@ until backboardd shows a new page: no change.Two related host-window effects: the window follows a fold it did not ask for(DeviceHub, a guest-side request) from `display.orientation`'s `fold_angle`,-which it now reads four times a second on a foldable guest (once before), so-the cover drawn in the window's open shape, sideways, lasts about 0.1 s-instead of about 0.5 s. A fold while the screen sleeps lights it, and the+which it now reads four times a second on a foldable guest (once before),+taking a fold once two reads agree: through the relay the hinge follows+DeviceHub's slider as it animates, and taking every read reshaped the window+at each step of a sweep. The cover drawn in the window's open shape,+sideways, now lasts a fraction of the half second it did. A fold while the screen sleeps lights it, and thepanel's first 0.2 s are its last frame from before sleep.diff --git a/VPhoneExecutable/VPhoneVirtualization/UI/UserInterface/VPhoneVirtualMachineWindowController.swift b/VPhoneExecutable/VPhoneVirtualization/UI/UserInterface/VPhoneVirtualMachineWindowController.swiftindex 2e78c8be..e8a83206 100644--- a/VPhoneExecutable/VPhoneVirtualization/UI/UserInterface/VPhoneVirtualMachineWindowController.swift+++ b/VPhoneExecutable/VPhoneVirtualization/UI/UserInterface/VPhoneVirtualMachineWindowController.swift@@ -286,11 +286,12 @@ class VPhoneVirtualMachineWindowController: NSObject, NSWindowDelegate {/// minimum larger than this compact physical-size baseline.private var minimumDuoPanelSize: CGSize?private var orientationPollInFlight = false+ private var lastPolledFoldAngle: Double?/// Asks vphoned for the interface orientation once a second (a foldable- /// guest four times a second). Guests- /// without `display.orientation` stay portrait. A read that overlaps a- /// rotation the menu started is dropped: it may predate the turn.+ /// guest four times a second). Guests without `display.orientation` stay+ /// portrait. A read that overlaps a rotation the menu started is dropped:+ /// it may predate the turn.private func pollOrientation() {guard !orientationPollInFlight,let control, control.isConnected, !control.isChangingOrientation,@@ -300,9 +301,12 @@ class VPhoneVirtualMachineWindowController: NSObject, NSWindowDelegate {Task {defer { orientationPollInFlight = false }guard let result = try? await control.call("display.orientation") else { return }- // A foldable guest reports where its last fold settled.+ // A foldable guest reports where its hinge is. DeviceHub's slider+ // moves it as it animates, so the window takes a fold once two+ // reads agree, rather than reshaping at each step of a sweep.if let foldAngle = (result["fold_angle"] as? NSNumber)?.doubleValue {- control.followGuestFold(angle: foldAngle)+ if foldAngle == lastPolledFoldAngle { control.followGuestFold(angle: foldAngle) }+ lastPolledFoldAngle = foldAngle}guard !control.isChangingOrientation,let degrees = (result["degrees"] as? NSNumber)?.intValue,