fix: restore positive resize increments when clearing aspect lock

This commit is contained in:
2026-10-18 02:11:16 +02:00
parent 3e782aff31
commit dd02383c0b
5 changed files with 23 additions and 7 deletions
+8 -2
View File
@@ -20,6 +20,7 @@ final class CompactWindowController: NSObject {
let minSize: NSSize
let contentMinSize: NSSize
let aspectRatio: NSSize
let resizeIncrements: NSSize
let styleMask: NSWindow.StyleMask
let titleVisibility: NSWindow.TitleVisibility
let titlebarAppearsTransparent: Bool
@@ -34,6 +35,7 @@ final class CompactWindowController: NSObject {
minSize = window.minSize
contentMinSize = window.contentMinSize
aspectRatio = window.aspectRatio
resizeIncrements = window.resizeIncrements
styleMask = window.styleMask
titleVisibility = window.titleVisibility
titlebarAppearsTransparent = window.titlebarAppearsTransparent
@@ -310,7 +312,11 @@ final class CompactWindowController: NSObject {
window.minSize = snapshot.minSize
window.contentMinSize = snapshot.contentMinSize
window.setFrame(snapshot.frame, display: true)
window.aspectRatio = snapshot.aspectRatio
if snapshot.aspectRatio == .zero {
window.resizeIncrements = snapshot.resizeIncrements
} else {
window.aspectRatio = snapshot.aspectRatio
}
self.snapshot = nil
}
@@ -380,7 +386,7 @@ final class CompactWindowController: NSObject {
frame.origin.x = min(max(window.frame.minX, usable.minX), usable.maxX - frame.width)
frame.origin.y = min(max(window.frame.minY, usable.minY), usable.maxY - frame.height)
}
window.aspectRatio = .zero
window.resizeIncrements = NSSize(width: 1, height: 1)
animateFrame(frame, of: window, animated: animated) { [weak self, weak window] in
guard let self, let window else { return }
if Self.canFitAspect(aspect, available: usable.size) {
+10 -5
View File
@@ -36,7 +36,8 @@ final class PlayerModel: ObservableObject {
didSet {
guard showsQueue != oldValue, let window, !isFullScreen,
!isCompact, !compactWindow.isTransitioning else { return }
window.aspectRatio = .zero
// Setting aspectRatio to zero leaves AppKit's resize increments at zero.
window.resizeIncrements = NSSize(width: 1, height: 1)
var frame = window.frame
frame.size.width += showsQueue ? 260 : -260
if let screen = window.screen?.visibleFrame {
@@ -706,7 +707,7 @@ final class PlayerModel: ObservableObject {
youtubeHeight = nil
youtubeQuality = nil
needsVideoFit = false
window?.aspectRatio = .zero
window?.resizeIncrements = NSSize(width: 1, height: 1)
commandError = nil
isSeeking = false
window?.representedURL = nil
@@ -979,7 +980,7 @@ final class PlayerModel: ObservableObject {
}
needsVideoFit = false
guard state.has_video, aspect.isFinite, aspect > 0 else {
window.aspectRatio = .zero
window.resizeIncrements = NSSize(width: 1, height: 1)
return
}
let screen = (window.screen ?? NSScreen.main)?.visibleFrame ?? window.frame
@@ -988,10 +989,14 @@ final class PlayerModel: ObservableObject {
let size = NSSize(width: width + sidebarWidth, height: width / aspect)
// ponytail: extreme ratios retain letterboxing; compact controls if exact fitting is needed.
guard size.width >= window.minSize.width, size.height >= window.minSize.height else {
window.aspectRatio = .zero
window.resizeIncrements = NSSize(width: 1, height: 1)
return
}
window.aspectRatio = showsQueue ? .zero : NSSize(width: aspect, height: 1)
if showsQueue {
window.resizeIncrements = NSSize(width: 1, height: 1)
} else {
window.aspectRatio = NSSize(width: aspect, height: 1)
}
let frame = NSRect(
x: min(max(window.frame.midX - size.width / 2, screen.minX), screen.maxX - size.width),
y: min(max(window.frame.midY - size.height / 2, screen.minY), screen.maxY - size.height),