From b35faa415fe450f36153e1238ba1cf7184b734d6 Mon Sep 17 00:00:00 2001 From: godly-devotion Date: Tue, 23 Apr 2024 14:13:52 -0400 Subject: [PATCH] fix: skip resizing window when opening file in full screen mode --- Front Row/Support/PlayEngine.swift | 8 +++++--- Front Row/Views/SeekSliderView.swift | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Front Row/Support/PlayEngine.swift b/Front Row/Support/PlayEngine.swift index 1eb1f66..9acf8b3 100644 --- a/Front Row/Support/PlayEngine.swift +++ b/Front Row/Support/PlayEngine.swift @@ -223,7 +223,7 @@ import SwiftUI .sink { [weak self] size in guard let self else { return } videoSize = size - fitToVideoSize() + fitToVideoSize(skipResize: WindowController.shared.isFullscreen) } .store(in: ¤tItemSubs) @@ -331,7 +331,7 @@ import SwiftUI item.step(byCount: byCount) } - func fitToVideoSize() { + func fitToVideoSize(skipResize: Bool = false) { guard let window = NSApp.windows.first else { return } guard videoSize != CGSize.zero else { /// reset aspect ratio setting @@ -356,7 +356,9 @@ import SwiftUI ) newFrame = NSRect(origin: newOrigin, size: newSize) } - window.setFrame(newFrame, display: true, animate: true) + if !skipResize { + window.setFrame(newFrame, display: true, animate: true) + } window.aspectRatio = videoSize } diff --git a/Front Row/Views/SeekSliderView.swift b/Front Row/Views/SeekSliderView.swift index a49432b..aa2eb93 100644 --- a/Front Row/Views/SeekSliderView.swift +++ b/Front Row/Views/SeekSliderView.swift @@ -47,7 +47,7 @@ struct SeekSliderView: NSViewRepresentable { let barRect = rect let path = NSBezierPath(roundedRect: barRect, xRadius: barRadius, yRadius: barRadius) - // draw left + /// draw left let pathLeftRect: NSRect = NSMakeRect( barRect.origin.x, barRect.origin.y, progress, barRect.height) NSBezierPath(rect: pathLeftRect).addClip() @@ -63,7 +63,7 @@ struct SeekSliderView: NSViewRepresentable { path.fill() NSGraphicsContext.restoreGraphicsState() - // draw right + /// draw right NSGraphicsContext.saveGraphicsState() let pathRight = NSMakeRect( barRect.origin.x + progress, barRect.origin.y, barRect.width - progress, @@ -93,7 +93,7 @@ struct SeekSliderView: NSViewRepresentable { if percentage.isNaN { percentage = 0.0 } - // The usable width of the bar is reduced by the width of the knob. + /// The usable width of the bar is reduced by the width of the knob. let effectiveBarWidth = barRect.width - knobWidth let pos = barRect.origin.x + CGFloat(percentage) * effectiveBarWidth let rect = super.knobRect(flipped: flipped)