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:
der richter 2020-12-12 15:18:08 +01:00
parent 2bc88a2936
commit 93d071dbd8
2 changed files with 14 additions and 10 deletions

View File

@ -151,7 +151,7 @@ class TitleBar: NSVisualEffectView {
}
}
@objc func hide() {
@objc func hide(_ duration: TimeInterval = 0.20) {
guard let window = common.window else { return }
if window.isInFullscreen && !window.isAnimating {
alphaValue = 0
@ -159,7 +159,7 @@ class TitleBar: NSVisualEffectView {
return
}
NSAnimationContext.runAnimationGroup({ (context) -> Void in
context.duration = 0.20
context.duration = duration
systemBar?.animator().alphaValue = 0
animator().alphaValue = 0
}, completionHandler: {

View File

@ -163,22 +163,26 @@ class Window: NSWindow, NSWindowDelegate {
NSAnimationContext.runAnimationGroup({ (context) -> Void in
context.duration = getFsAnimationDuration(duration - 0.05)
window.animator().setFrame(tScreen.frame, display: true)
}, completionHandler: { })
}, completionHandler: nil)
}
func window(_ window: NSWindow, startCustomAnimationToExitFullScreenWithDuration duration: TimeInterval) {
guard let tScreen = targetScreen, let currentScreen = screen else { return }
let newFrame = calculateWindowPosition(for: tScreen, withoutBounds: tScreen == screen)
let intermediateFrame = aspectFit(rect: newFrame, in: currentScreen.frame)
common.view?.layerContentsPlacement = .scaleProportionallyToFill
common.titleBar?.hide()
styleMask.remove(.fullScreen)
setFrame(intermediateFrame, display: true)
common.titleBar?.hide(0.0)
NSAnimationContext.runAnimationGroup({ (context) -> Void in
context.duration = getFsAnimationDuration(duration - 0.05)
window.animator().setFrame(newFrame, display: true)
}, completionHandler: { })
context.duration = 0.0
common.view?.layerContentsPlacement = .scaleProportionallyToFill
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) {