From fa4ca16f6601eb51d64ae61bb5d4c018387cbadd Mon Sep 17 00:00:00 2001 From: der richter Date: Sun, 17 Dec 2023 17:52:15 +0100 Subject: [PATCH] mac: update geometry/autofit opts on runtime --- video/out/mac/common.swift | 8 ++++++++ video/out/mac/window.swift | 14 ++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/video/out/mac/common.swift b/video/out/mac/common.swift index be3e1b517d..83cac04e8e 100644 --- a/video/out/mac/common.swift +++ b/video/out/mac/common.swift @@ -553,6 +553,14 @@ class Common: NSObject { DispatchQueue.main.async { self.window?.setMaximized(Bool(mpv.opts.window_maximized)) } + case MPVHelper.getPointer(&mpv.optsPtr.pointee.geometry): fallthrough + case MPVHelper.getPointer(&mpv.optsPtr.pointee.autofit): fallthrough + case MPVHelper.getPointer(&mpv.optsPtr.pointee.autofit_smaller): fallthrough + case MPVHelper.getPointer(&mpv.optsPtr.pointee.autofit_larger): + DispatchQueue.main.async { + let (_, _, wr) = self.getInitProperties(vo) + self.window?.updateFrame(wr) + } default: break } diff --git a/video/out/mac/window.swift b/video/out/mac/window.swift index 7b1a858840..8002c43929 100644 --- a/video/out/mac/window.swift +++ b/video/out/mac/window.swift @@ -342,21 +342,19 @@ class Window: NSWindow, NSWindowDelegate { func updateFrame(_ rect: NSRect) { if rect != frame { - let cRect = frameRect(forContentRect: rect) unfsContentFrame = rect - setFrame(cRect, display: true) - common.windowDidUpdateFrame() + if !isInFullscreen { + let cRect = frameRect(forContentRect: rect) + setFrame(cRect, display: true) + common.windowDidUpdateFrame() + } } } func updateSize(_ size: NSSize) { if let currentSize = contentView?.frame.size, size != currentSize { let newContentFrame = centeredContentSize(for: frame, size: size) - if !isInFullscreen { - updateFrame(newContentFrame) - } else { - unfsContentFrame = newContentFrame - } + updateFrame(newContentFrame) } }