fix: stabilize aspect locked queue window resizing

This commit is contained in:
2026-10-18 09:48:51 +02:00
parent 8cd5db5375
commit 640e23b004
3 changed files with 61 additions and 3 deletions
+35
View File
@@ -472,11 +472,46 @@ struct CompactWindowChecks {
}
}
static func continuousQueueResize() throws {
let aspect = 16.0 / 9.0
let sidebar: CGFloat = 260
let window = NSWindow(contentRect: NSRect(x: -10_000, y: -10_000, width: 1_160, height: 900 / aspect),
styleMask: [.titled, .resizable, .fullSizeContentView],
backing: .buffered, defer: false)
window.isReleasedWhenClosed = false
defer { window.close() }
let controller = CompactWindowController()
controller.normalVideoLayout = { (aspect, sidebar) }
controller.attach(window)
for horizontal in [true, false] {
let start = window.frame
let chrome = start.height - window.contentRect(forFrameRect: start).height
window.delegate?.windowWillStartLiveResize?(Notification(name: NSWindow.willStartLiveResizeNotification, object: window))
// AppKit proposes sizes from the pointer's drag origin. The delegate's
// correction of the other dimension must not feed back into axis selection.
for offset in [CGFloat(20), 21, 22, 23, 24, 23, 22, 21, 20, 0, -1, -2] {
let proposal = NSSize(width: start.width + (horizontal ? offset : 0),
height: start.height + (horizontal ? 0 : offset))
let size = window.delegate!.windowWillResize!(window, to: proposal)
try require(close(horizontal ? size.width : size.height,
horizontal ? proposal.width : proposal.height),
"continuous queue resize follows the dragged edge without snapping back")
try require(close((size.width - sidebar) / (size.height - chrome), aspect),
"continuous queue resize keeps the video aspect")
var frame = start
frame.size = size
window.setFrame(frame, display: false)
}
window.delegate?.windowDidEndLiveResize?(Notification(name: NSWindow.didEndLiveResizeNotification, object: window))
}
}
static func main() throws {
try geometry()
try windowBehavior()
try reducedMotion()
try rememberedSize()
try continuousQueueResize()
print("Compact window checks passed")
}
}