Open macOS inline player sheet at correct size when video is loaded

The inline-sheet content declared only a minWidth/minHeight floor, so
.presentationSizing(.fitted) opened the sheet at 640x360 and
SheetWindowResizer corrected it a runloop tick later — a visible
small-then-resize flash when re-opening the sheet while a video plays.

Feed the already-computed aspect-derived size as the frame's ideal size
so .fitted opens the sheet at the correct size immediately when the video
dimensions are known; the resizer's first pass then no-ops on its guard.
The floor (no max) is kept so content still tracks later animated resizes.
This commit is contained in:
Arkadiusz Fal
2026-05-27 23:03:40 +02:00
parent 07fd5e2744
commit 6bc58f10b2

View File

@@ -95,11 +95,17 @@ struct ContentView: View {
)) {
let size = expandedSheetSize(appEnvironment: appEnvironment)
ExpandedPlayerSheet()
// Only a floor the content fills the sheet window so it tracks
// the window's animated resize with no gap. Do NOT pin an exact
// size here: a fixed frame snaps instantly while the window
// animates, exposing the window background as bars.
.frame(minWidth: 640, minHeight: 360)
// Floor keeps the content flexible so it tracks the window's
// animated resize with no gap do NOT pin an exact (max) size:
// a fixed frame snaps instantly while the window animates,
// exposing the window background as bars. The ideal size makes
// `.presentationSizing(.fitted)` open the sheet at the correct
// aspect immediately when the video size is already known (e.g.
// re-opening while playing), avoiding a small-then-resize flash.
.frame(
minWidth: 640, idealWidth: size.width,
minHeight: 360, idealHeight: size.height
)
.presentationSizing(.fitted)
// `.presentationSizing(.fitted)` only fits the sheet once, at
// presentation. Resize the backing window directly when the