summaryrefslogtreecommitdiffstats
path: root/video/out/cocoa-cb/window.swift
diff options
context:
space:
mode:
authorder richter <der.richter@gmx.de>2019-09-29 18:35:12 +0200
committerder richter <der.richter@gmx.de>2019-10-06 13:29:48 +0200
commit6d0f0546ee851f4106438c5b92c8d1d152937ea7 (patch)
treef4efc2a603081fe75c19bea86c261d5320716c5b /video/out/cocoa-cb/window.swift
parent2b19a7c964b821945e3ea06cfa81c1c064f2504d (diff)
downloadmpv-6d0f0546ee851f4106438c5b92c8d1d152937ea7.tar.bz2
mpv-6d0f0546ee851f4106438c5b92c8d1d152937ea7.tar.xz
cocoa-cb: remove get_property_* usages and split up mpv helper
all the get_property_* usages were removed because in some circumstances they can lead to deadlocks. they were replaced by accessing the vo and mp_vo_opts structs directly, like on other vos. additionally the mpv helper was split into a mpv and libmpv helper, to differentiate between private and public APIs and for future changes like a macOS vulkan context for vo=gpu.
Diffstat (limited to 'video/out/cocoa-cb/window.swift')
-rw-r--r--video/out/cocoa-cb/window.swift48
1 files changed, 18 insertions, 30 deletions
diff --git a/video/out/cocoa-cb/window.swift b/video/out/cocoa-cb/window.swift
index 2f87711d22..1ac0e2bc78 100644
--- a/video/out/cocoa-cb/window.swift
+++ b/video/out/cocoa-cb/window.swift
@@ -20,7 +20,8 @@ import Cocoa
class Window: NSWindow, NSWindowDelegate {
weak var cocoaCB: CocoaCB! = nil
- var mpv: MPVHelper { get { return cocoaCB.mpv } }
+ var mpv: MPVHelper? { get { return cocoaCB.mpv } }
+ var libmpv: LibmpvHelper { get { return cocoaCB.libmpv } }
var targetScreen: NSScreen?
var previousScreen: NSScreen?
@@ -134,7 +135,7 @@ class Window: NSWindow, NSWindowDelegate {
setFrame(frame, display: true)
}
- if mpv.getBoolProperty("native-fs") {
+ if Bool(mpv?.opts.native_fs ?? 1) {
super.toggleFullScreen(sender)
} else {
if !isInFullscreen {
@@ -245,48 +246,35 @@ class Window: NSWindow, NSWindowDelegate {
cocoaCB.layer?.update()
}
- func getFsAnimationDuration(_ def: Double) -> Double{
- let duration = mpv.getStringProperty("macos-fs-animation-duration") ?? "default"
- if duration == "default" {
+ func getFsAnimationDuration(_ def: Double) -> Double {
+ let duration = libmpv.macOpts.macos_fs_animation_duration
+ if duration < 0 {
return def
} else {
- return (Double(duration) ?? 0.2)/1000
+ return Double(duration)/1000
}
}
- func setOnTop(_ state: Bool, _ ontopLevel: Any) {
- let stdLevel: NSWindow.Level = .normal
-
+ func setOnTop(_ state: Bool, _ ontopLevel: Int) {
if state {
- if ontopLevel is Int {
- switch ontopLevel as? Int {
- case .some(-1):
- level = .floating
- case .some(-2):
- level = .statusBar + 1
- default:
- level = NSWindow.Level(ontopLevel as? Int ?? stdLevel.rawValue)
- }
- } else {
- switch ontopLevel as? String {
- case .some("window"):
- level = .floating
- case .some("system"):
- level = .statusBar + 1
- default:
- level = NSWindow.Level(Int(ontopLevel as? String ?? "") ?? stdLevel.rawValue)
- }
+ switch ontopLevel {
+ case -1:
+ level = .floating
+ case -2:
+ level = .statusBar + 1
+ default:
+ level = NSWindow.Level(ontopLevel)
}
collectionBehavior.remove(.transient)
collectionBehavior.insert(.managed)
} else {
- level = stdLevel
+ level = .normal
}
}
func updateMovableBackground(_ pos: NSPoint) {
if !isInFullscreen {
- isMovableByWindowBackground = mpv.canBeDraggedAt(pos)
+ isMovableByWindowBackground = mpv?.canBeDraggedAt(pos) ?? true
} else {
isMovableByWindowBackground = false
}
@@ -448,7 +436,7 @@ class Window: NSWindow, NSWindowDelegate {
@objc func setDoubleWindowSize() { setWindowScale(2.0) }
func setWindowScale(_ scale: Double) {
- mpv.commandAsync(["osd-auto", "set", "window-scale", "\(scale)"])
+ mpv?.command("set window-scale \(scale)")
}
func windowDidChangeScreen(_ notification: Notification) {