mirror of https://github.com/mpv-player/mpv
mac/window: cleanup unfsContentFrame usage and make it none optional
This commit is contained in:
parent
fc36e5d71e
commit
5178c5b7d1
|
@ -27,7 +27,7 @@ class Window: NSWindow, NSWindowDelegate {
|
||||||
var currentScreen: NSScreen?
|
var currentScreen: NSScreen?
|
||||||
var unfScreen: NSScreen?
|
var unfScreen: NSScreen?
|
||||||
|
|
||||||
var unfsContentFrame: NSRect?
|
var unfsContentFrame: NSRect = NSRect(x: 0, y: 0, width: 160, height: 90)
|
||||||
var isInFullscreen: Bool = false
|
var isInFullscreen: Bool = false
|
||||||
var isMoving: Bool = false
|
var isMoving: Bool = false
|
||||||
var previousStyleMask: NSWindow.StyleMask = [.titled, .closable, .miniaturizable, .resizable]
|
var previousStyleMask: NSWindow.StyleMask = [.titled, .closable, .miniaturizable, .resizable]
|
||||||
|
@ -35,7 +35,7 @@ class Window: NSWindow, NSWindowDelegate {
|
||||||
var isAnimating: Bool = false
|
var isAnimating: Bool = false
|
||||||
let animationLock: NSCondition = NSCondition()
|
let animationLock: NSCondition = NSCondition()
|
||||||
|
|
||||||
var unfsContentFramePixel: NSRect { get { return convertToBacking(unfsContentFrame ?? NSRect(x: 0, y: 0, width: 160, height: 90)) } }
|
var unfsContentFramePixel: NSRect { get { return convertToBacking(unfsContentFrame) } }
|
||||||
@objc var framePixel: NSRect { get { return convertToBacking(frame) } }
|
@objc var framePixel: NSRect { get { return convertToBacking(frame) } }
|
||||||
|
|
||||||
var keepAspect: Bool = true {
|
var keepAspect: Bool = true {
|
||||||
|
@ -45,7 +45,7 @@ class Window: NSWindow, NSWindowDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
if keepAspect {
|
if keepAspect {
|
||||||
contentAspectRatio = unfsContentFrame?.size ?? contentAspectRatio
|
contentAspectRatio = unfsContentFrame.size
|
||||||
} else {
|
} else {
|
||||||
resizeIncrements = NSSize(width: 1.0, height: 1.0)
|
resizeIncrements = NSSize(width: 1.0, height: 1.0)
|
||||||
}
|
}
|
||||||
|
@ -94,6 +94,7 @@ class Window: NSWindow, NSWindowDelegate {
|
||||||
collectionBehavior = .fullScreenPrimary
|
collectionBehavior = .fullScreenPrimary
|
||||||
ignoresMouseEvents = option.vo.cursor_passthrough
|
ignoresMouseEvents = option.vo.cursor_passthrough
|
||||||
delegate = self
|
delegate = self
|
||||||
|
unfsContentFrame = contentRect
|
||||||
|
|
||||||
if let cView = contentView {
|
if let cView = contentView {
|
||||||
cView.addSubview(view)
|
cView.addSubview(view)
|
||||||
|
@ -366,9 +367,7 @@ class Window: NSWindow, NSWindowDelegate {
|
||||||
|
|
||||||
super.setFrame(frameRect, display: flag)
|
super.setFrame(frameRect, display: flag)
|
||||||
|
|
||||||
if let size = unfsContentFrame?.size, keepAspect {
|
if keepAspect { contentAspectRatio = unfsContentFrame.size }
|
||||||
contentAspectRatio = size
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func centeredContentSize(for rect: NSRect, size sz: NSSize) -> NSRect {
|
func centeredContentSize(for rect: NSRect, size sz: NSSize) -> NSRect {
|
||||||
|
@ -389,10 +388,9 @@ class Window: NSWindow, NSWindowDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
func calculateWindowPosition(for tScreen: NSScreen, withoutBounds: Bool) -> NSRect {
|
func calculateWindowPosition(for tScreen: NSScreen, withoutBounds: Bool) -> NSRect {
|
||||||
guard let contentFrame = unfsContentFrame, let screen = unfScreen else {
|
guard let screen = unfScreen else { return frame }
|
||||||
return frame
|
|
||||||
}
|
var newFrame = frameRect(forContentRect: unfsContentFrame)
|
||||||
var newFrame = frameRect(forContentRect: contentFrame)
|
|
||||||
let targetFrame = tScreen.frame
|
let targetFrame = tScreen.frame
|
||||||
let targetVisibleFrame = tScreen.visibleFrame
|
let targetVisibleFrame = tScreen.visibleFrame
|
||||||
let unfsScreenFrame = screen.frame
|
let unfsScreenFrame = screen.frame
|
||||||
|
|
Loading…
Reference in New Issue