summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorder richter <der.richter@gmx.de>2021-02-23 15:26:39 +0100
committerder richter <der.richter@gmx.de>2021-02-27 13:12:46 +0100
commitd1be8bb6063cc6f7a066b99dd348c34f81cc7f0a (patch)
tree29ebce562d3bc3e4f87bc6507f47df6c5bf43f85
parentc2868bdd393a82026a9aa50993fef1983f3c8b33 (diff)
downloadmpv-d1be8bb6063cc6f7a066b99dd348c34f81cc7f0a.tar.bz2
mpv-d1be8bb6063cc6f7a066b99dd348c34f81cc7f0a.tar.xz
mac: fix traditional fullscreen on macOS 11
the fullscreen style mask is not supported on macOS 11 anymore outside of the native fullscreen animation. this can lead to a none working fs or in the worst case a crash. to fix this we will simulate a fullscreen window with a borderless window with the size of the whole screen, though only on macOS 11. Fixes #8490
-rw-r--r--video/out/cocoa_cb_common.swift4
-rw-r--r--video/out/mac/window.swift20
2 files changed, 20 insertions, 4 deletions
diff --git a/video/out/cocoa_cb_common.swift b/video/out/cocoa_cb_common.swift
index 8dd76f4bc5..dd0738f7e3 100644
--- a/video/out/cocoa_cb_common.swift
+++ b/video/out/cocoa_cb_common.swift
@@ -132,11 +132,11 @@ class CocoaCB: Common {
}
override func windowSetToFullScreen() {
- layer?.update()
+ layer?.update(force: true)
}
override func windowSetToWindow() {
- layer?.update()
+ layer?.update(force: true)
}
override func windowDidUpdateFrame() {
diff --git a/video/out/mac/window.swift b/video/out/mac/window.swift
index 251bc4050d..8b6c5f0518 100644
--- a/video/out/mac/window.swift
+++ b/video/out/mac/window.swift
@@ -30,6 +30,7 @@ class Window: NSWindow, NSWindowDelegate {
var isInFullscreen: Bool = false
var isAnimating: Bool = false
var isMoving: Bool = false
+ var previousStyleMask: NSWindow.StyleMask = [.titled, .closable, .miniaturizable, .resizable]
var unfsContentFramePixel: NSRect { get { return convertToBacking(unfsContentFrame ?? NSRect(x: 0, y: 0, width: 160, height: 90)) } }
var framePixel: NSRect { get { return convertToBacking(frame) } }
@@ -60,6 +61,7 @@ class Window: NSWindow, NSWindowDelegate {
set {
let responder = firstResponder
let windowTitle = title
+ previousStyleMask = super.styleMask
super.styleMask = newValue
makeFirstResponder(responder)
title = windowTitle
@@ -228,7 +230,14 @@ class Window: NSWindow, NSWindowDelegate {
func setToFullScreen() {
guard let targetFrame = targetScreen?.frame else { return }
- styleMask.insert(.fullScreen)
+
+ if #available(macOS 11.0, *) {
+ styleMask = .borderless
+ common.titleBar?.hide(0.0)
+ } else {
+ styleMask.insert(.fullScreen)
+ }
+
NSApp.presentationOptions = [.autoHideMenuBar, .autoHideDock]
setFrame(targetFrame, display: true)
endAnimation()
@@ -239,10 +248,17 @@ class Window: NSWindow, NSWindowDelegate {
func setToWindow() {
guard let tScreen = targetScreen else { return }
+
+ if #available(macOS 11.0, *) {
+ styleMask = previousStyleMask
+ common.titleBar?.hide(0.0)
+ } else {
+ styleMask.remove(.fullScreen)
+ }
+
let newFrame = calculateWindowPosition(for: tScreen, withoutBounds: targetScreen == screen)
NSApp.presentationOptions = []
setFrame(newFrame, display: true)
- styleMask.remove(.fullScreen)
endAnimation()
isInFullscreen = false
mpv?.setOption(fullscreen: isInFullscreen)