mac: update geometry/autofit opts on runtime

This commit is contained in:
der richter 2023-12-17 17:52:15 +01:00
parent e832f4969f
commit fa4ca16f66
2 changed files with 14 additions and 8 deletions

View File

@ -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
}

View File

@ -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)
}
}