diff options
author | der richter <der.richter@gmx.de> | 2020-12-12 15:18:08 +0100 |
---|---|---|
committer | der richter <der.richter@gmx.de> | 2020-12-19 15:44:59 +0100 |
commit | 93d071dbd8fb8b9561e1830754c40f3de87cf3ca (patch) | |
tree | f8ea898b48957ef30f5be6e29751a3725df3ee3a | |
parent | 2bc88a2936115f7ab1c530fbe4ee1618ecbdcbf1 (diff) | |
download | mpv-93d071dbd8fb8b9561e1830754c40f3de87cf3ca.tar.bz2 mpv-93d071dbd8fb8b9561e1830754c40f3de87cf3ca.tar.xz |
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
-rw-r--r-- | video/out/mac/title_bar.swift | 4 | ||||
-rw-r--r-- | video/out/mac/window.swift | 20 |
2 files changed, 14 insertions, 10 deletions
diff --git a/video/out/mac/title_bar.swift b/video/out/mac/title_bar.swift index 623fe8f57d..e49c2bb99c 100644 --- a/video/out/mac/title_bar.swift +++ b/video/out/mac/title_bar.swift @@ -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: { diff --git a/video/out/mac/window.swift b/video/out/mac/window.swift index d692d0db91..a418f2ce75 100644 --- a/video/out/mac/window.swift +++ b/video/out/mac/window.swift @@ -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) { |