mirror of https://github.com/mpv-player/mpv
mac: fix a window positioning bug when exiting fullscreen
when exiting fullscreen we set the window frame to a aspect fit frame of the fullscreen frame to prevent aspect ration problems when animating. though that intermediate frame was set too early and before the system knew we already exited the fullscreen. because of that the frame we set could not be properly set and its origin was defaulted to the bottom left corner for exactly one display refresh and only after that the wanted frame was set. this led to a (dark) grey area on the right or top depending on the aspect ratio difference of the screen and video. to prevent this set the intermediate frame in the animation group to make it sync with the system's fullscreen behaviour. Fixes #8371
This commit is contained in:
parent
2bc88a2936
commit
93d071dbd8
|
@ -151,7 +151,7 @@ class TitleBar: NSVisualEffectView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func hide() {
|
@objc func hide(_ duration: TimeInterval = 0.20) {
|
||||||
guard let window = common.window else { return }
|
guard let window = common.window else { return }
|
||||||
if window.isInFullscreen && !window.isAnimating {
|
if window.isInFullscreen && !window.isAnimating {
|
||||||
alphaValue = 0
|
alphaValue = 0
|
||||||
|
@ -159,7 +159,7 @@ class TitleBar: NSVisualEffectView {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
NSAnimationContext.runAnimationGroup({ (context) -> Void in
|
NSAnimationContext.runAnimationGroup({ (context) -> Void in
|
||||||
context.duration = 0.20
|
context.duration = duration
|
||||||
systemBar?.animator().alphaValue = 0
|
systemBar?.animator().alphaValue = 0
|
||||||
animator().alphaValue = 0
|
animator().alphaValue = 0
|
||||||
}, completionHandler: {
|
}, completionHandler: {
|
||||||
|
|
|
@ -163,22 +163,26 @@ class Window: NSWindow, NSWindowDelegate {
|
||||||
NSAnimationContext.runAnimationGroup({ (context) -> Void in
|
NSAnimationContext.runAnimationGroup({ (context) -> Void in
|
||||||
context.duration = getFsAnimationDuration(duration - 0.05)
|
context.duration = getFsAnimationDuration(duration - 0.05)
|
||||||
window.animator().setFrame(tScreen.frame, display: true)
|
window.animator().setFrame(tScreen.frame, display: true)
|
||||||
}, completionHandler: { })
|
}, completionHandler: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func window(_ window: NSWindow, startCustomAnimationToExitFullScreenWithDuration duration: TimeInterval) {
|
func window(_ window: NSWindow, startCustomAnimationToExitFullScreenWithDuration duration: TimeInterval) {
|
||||||
guard let tScreen = targetScreen, let currentScreen = screen else { return }
|
guard let tScreen = targetScreen, let currentScreen = screen else { return }
|
||||||
let newFrame = calculateWindowPosition(for: tScreen, withoutBounds: tScreen == screen)
|
let newFrame = calculateWindowPosition(for: tScreen, withoutBounds: tScreen == screen)
|
||||||
let intermediateFrame = aspectFit(rect: newFrame, in: currentScreen.frame)
|
let intermediateFrame = aspectFit(rect: newFrame, in: currentScreen.frame)
|
||||||
common.view?.layerContentsPlacement = .scaleProportionallyToFill
|
common.titleBar?.hide(0.0)
|
||||||
common.titleBar?.hide()
|
|
||||||
styleMask.remove(.fullScreen)
|
|
||||||
setFrame(intermediateFrame, display: true)
|
|
||||||
|
|
||||||
NSAnimationContext.runAnimationGroup({ (context) -> Void in
|
NSAnimationContext.runAnimationGroup({ (context) -> Void in
|
||||||
context.duration = getFsAnimationDuration(duration - 0.05)
|
context.duration = 0.0
|
||||||
window.animator().setFrame(newFrame, display: true)
|
common.view?.layerContentsPlacement = .scaleProportionallyToFill
|
||||||
}, completionHandler: { })
|
window.animator().setFrame(intermediateFrame, display: true)
|
||||||
|
}, completionHandler: {
|
||||||
|
NSAnimationContext.runAnimationGroup({ (context) -> Void in
|
||||||
|
context.duration = self.getFsAnimationDuration(duration - 0.05)
|
||||||
|
self.styleMask.remove(.fullScreen)
|
||||||
|
window.animator().setFrame(newFrame, display: true)
|
||||||
|
}, completionHandler: nil)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func windowDidEnterFullScreen(_ notification: Notification) {
|
func windowDidEnterFullScreen(_ notification: Notification) {
|
||||||
|
|
Loading…
Reference in New Issue