diff options
author | der richter <der.richter@gmx.de> | 2020-07-25 17:29:47 +0200 |
---|---|---|
committer | der richter <der.richter@gmx.de> | 2023-10-14 18:39:56 +0200 |
commit | bc66de2834dcf69d4d05163350a219d2fbc47a56 (patch) | |
tree | b373ea810293db0dfa81659f55166c4c65326778 | |
parent | fd46070490c0178e9880dd89284c8861549a01d3 (diff) | |
download | mpv-bc66de2834dcf69d4d05163350a219d2fbc47a56.tar.bz2 mpv-bc66de2834dcf69d4d05163350a219d2fbc47a56.tar.xz |
mac: add a window animation lock to wait for animations to finish
add an animation lock to the window to prevent the window from closing
while animating. if this is done while the fs animation is running the
dock will stay hidden. this is not used yet, because it's unnecessary
for cocoa-cb but will be for new vo backends.
-rw-r--r-- | video/out/mac/window.swift | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/video/out/mac/window.swift b/video/out/mac/window.swift index 755d4d397f..7b1a858840 100644 --- a/video/out/mac/window.swift +++ b/video/out/mac/window.swift @@ -28,10 +28,12 @@ class Window: NSWindow, NSWindowDelegate { var unfsContentFrame: NSRect? var isInFullscreen: Bool = false - var isAnimating: Bool = false var isMoving: Bool = false var previousStyleMask: NSWindow.StyleMask = [.titled, .closable, .miniaturizable, .resizable] + var isAnimating: Bool = false + let animationLock: NSCondition = NSCondition() + var unfsContentFramePixel: NSRect { get { return convertToBacking(unfsContentFrame ?? NSRect(x: 0, y: 0, width: 160, height: 90)) } } var framePixel: NSRect { get { return convertToBacking(frame) } } @@ -115,7 +117,9 @@ class Window: NSWindow, NSWindowDelegate { return } + animationLock.lock() isAnimating = true + animationLock.unlock() targetScreen = common.getTargetScreen(forFullscreen: !isInFullscreen) if targetScreen == nil && previousScreen == nil { @@ -224,7 +228,10 @@ class Window: NSWindow, NSWindowDelegate { }, completionHandler: nil ) } + animationLock.lock() isAnimating = false + animationLock.signal() + animationLock.unlock() common.windowDidEndAnimation() } @@ -265,6 +272,14 @@ class Window: NSWindow, NSWindowDelegate { common.windowSetToWindow() } + func waitForAnimation() { + animationLock.lock() + while(isAnimating){ + animationLock.wait() + } + animationLock.unlock() + } + func getFsAnimationDuration(_ def: Double) -> Double { let duration = mpv?.macOpts.macos_fs_animation_duration ?? -1 if duration < 0 { |