diff options
author | Akemi <der.richter@gmx.de> | 2018-03-05 02:11:25 +0100 |
---|---|---|
committer | Kevin Mitchell <kevmitch@gmail.com> | 2018-03-04 19:08:45 -0800 |
commit | 8bfeecbc6ff1c95682b908a7e4beb87dd83fb3b7 (patch) | |
tree | d7ea113b48d896437ab4e7c8f0135e3a05e8fade /video/out/cocoa-cb/window.swift | |
parent | 33cffdcbac354179756db732c03b87026f710e8e (diff) | |
download | mpv-8bfeecbc6ff1c95682b908a7e4beb87dd83fb3b7.tar.bz2 mpv-8bfeecbc6ff1c95682b908a7e4beb87dd83fb3b7.tar.xz |
cocoa-cb: change handling of window aspect ratio changes
i tried being smart and handle aspect ratio differences manually via
atomic drawing and resizing to aspect fitted frames. there were a few
issues with that. like unexpected visibility of certain System GUI
elements on entering fullscreen or visually dropped frames due to the
atomic drawing. now we rely on system mechanics to keep the proper
aspect ratio of our layer, the recommended way. as a side effect it also
fixes a segfault.
Fixes #5581
Diffstat (limited to 'video/out/cocoa-cb/window.swift')
-rw-r--r-- | video/out/cocoa-cb/window.swift | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/video/out/cocoa-cb/window.swift b/video/out/cocoa-cb/window.swift index b0877d6622..74b9dcd5f5 100644 --- a/video/out/cocoa-cb/window.swift +++ b/video/out/cocoa-cb/window.swift @@ -246,20 +246,18 @@ class Window: NSWindow, NSWindowDelegate { } func window(_ window: NSWindow, startCustomAnimationToEnterFullScreenWithDuration duration: TimeInterval) { - let cRect = contentRect(forFrameRect: frame) - var intermediateFrame = aspectFit(rect: cRect, in: targetScreen!.frame) - intermediateFrame = frameRect(forContentRect: intermediateFrame) + cocoaCB.view.layerContentsPlacement = .scaleProportionallyToFit hideTitleBar() - NSAnimationContext.runAnimationGroup({ (context) -> Void in context.duration = getFsAnimationDuration(duration - 0.05) - window.animator().setFrame(intermediateFrame, display: true) + window.animator().setFrame(targetScreen!.frame, display: true) }, completionHandler: { }) } func window(_ window: NSWindow, startCustomAnimationToExitFullScreenWithDuration duration: TimeInterval) { let newFrame = calculateWindowPosition(for: targetScreen!, withoutBounds: targetScreen == screen) let intermediateFrame = aspectFit(rect: newFrame, in: screen!.frame) + cocoaCB.view.layerContentsPlacement = .scaleProportionallyToFill hideTitleBar() setFrame(intermediateFrame, display: true) @@ -281,6 +279,7 @@ class Window: NSWindow, NSWindowDelegate { isInFullscreen = false cocoaCB.flagEvents(VO_EVENT_FULLSCREEN_STATE) endAnimation(calculateWindowPosition(for: targetScreen!, withoutBounds: targetScreen == screen)) + cocoaCB.view.layerContentsPlacement = .scaleProportionallyToFit } func windowDidFailToEnterFullScreen(_ window: NSWindow) { @@ -293,6 +292,7 @@ class Window: NSWindow, NSWindowDelegate { let newFrame = targetScreen!.frame setFrame(newFrame, display: true) endAnimation() + cocoaCB.view.layerContentsPlacement = .scaleProportionallyToFit } func endAnimation(_ newFrame: NSRect = NSZeroRect) { @@ -304,6 +304,7 @@ class Window: NSWindow, NSWindowDelegate { } isAnimating = false + cocoaCB.layer.neededFlips += 1 cocoaCB.isShuttingDown = false } @@ -385,21 +386,7 @@ class Window: NSWindow, NSWindowDelegate { override func setFrame(_ frameRect: NSRect, display flag: Bool) { let newFrame = !isAnimating && isInFullscreen ? targetScreen!.frame : frameRect - let aspectRatioDiff = fabs( (newFrame.width/newFrame.height) - - (frame.width/frame.height) ) - - let isNotUserLiveResize = isAnimating || !(!isAnimating && inLiveResize) - if aspectRatioDiff > 0.005 && isNotUserLiveResize { - cocoaCB.layer.drawLock.lock() - cocoaCB.layer.atomicDrawingStart() - } - super.setFrame(newFrame, display: flag) - cocoaCB.layer.neededFlips += 1 - - if aspectRatioDiff > 0.005 && isNotUserLiveResize { - cocoaCB.layer.drawLock.unlock() - } if keepAspect { contentAspectRatio = unfsContentFrame!.size |