fix: preserve video aspect ratio while resizing queue window

This commit is contained in:
2026-10-18 02:18:38 +02:00
parent dd02383c0b
commit 8cd5db5375
4 changed files with 42 additions and 1 deletions
+18
View File
@@ -4,6 +4,7 @@ import QuartzCore
@MainActor
final class CompactWindowController: NSObject {
var onChange: (() -> Void)?
var normalVideoLayout: (() -> (aspect: Double, sidebarWidth: CGFloat)?)?
private(set) var isCompact = false
private(set) var isTransitioning = false
static let transitionDuration: TimeInterval = 0.25
@@ -211,6 +212,23 @@ final class CompactWindowController: NSObject {
let responds = MainActor.assumeIsolated { original?.responds(to: selector) ?? false }
return responds ? original : nil
}
func windowWillResize(_ sender: NSWindow, to proposedSize: NSSize) -> NSSize {
let proposed = original?.windowWillResize?(sender, to: proposedSize) ?? proposedSize
guard let owner, !owner.isCompact, !owner.isTransitioning,
!sender.styleMask.contains(.fullScreen),
let layout = owner.normalVideoLayout?(),
layout.aspect.isFinite, layout.aspect > 0 else { return proposed }
// The sidebar stays fixed-width; only the video area is aspect-locked.
let chrome = sender.frame.height - sender.contentRect(forFrameRect: sender.frame).height
let widthDriven = abs(proposed.width - sender.frame.width) >=
abs(proposed.height - sender.frame.height) * layout.aspect
let minimumHeight = max(sender.minSize.height - chrome,
(sender.minSize.width - layout.sidebarWidth) / layout.aspect)
let height = max(minimumHeight, widthDriven
? (proposed.width - layout.sidebarWidth) / layout.aspect
: proposed.height - chrome)
return NSSize(width: height * layout.aspect + layout.sidebarWidth, height: height + chrome)
}
func windowDidFailToEnterFullScreen(_ window: NSWindow) {
owner?.fullScreenFailed()