summaryrefslogtreecommitdiffstats
path: root/video/out
diff options
context:
space:
mode:
Diffstat (limited to 'video/out')
-rw-r--r--video/out/cocoa_cb_common.swift3
-rw-r--r--video/out/mac/common.swift14
2 files changed, 14 insertions, 3 deletions
diff --git a/video/out/cocoa_cb_common.swift b/video/out/cocoa_cb_common.swift
index 6cea9a60c3..476b4820bc 100644
--- a/video/out/cocoa_cb_common.swift
+++ b/video/out/cocoa_cb_common.swift
@@ -73,8 +73,9 @@ class CocoaCB: Common {
}
func initBackend(_ vo: UnsafeMutablePointer<vo>) {
+ let previousActiveApp = getActiveApp()
initApp()
- initWindow(vo)
+ initWindow(vo, previousActiveApp)
updateICCProfile()
initWindowState()
diff --git a/video/out/mac/common.swift b/video/out/mac/common.swift
index fb52b80610..95a0113c80 100644
--- a/video/out/mac/common.swift
+++ b/video/out/mac/common.swift
@@ -82,7 +82,7 @@ class Common: NSObject {
setAppIcon()
}
- func initWindow(_ vo: UnsafeMutablePointer<vo>) {
+ func initWindow(_ vo: UnsafeMutablePointer<vo>, _ previousActiveApp: NSRunningApplication?) {
let (mpv, targetScreen, wr) = getInitProperties(vo)
guard let view = self.view else {
@@ -115,7 +115,12 @@ class Common: NSObject {
window.orderFront(nil)
}
- NSApp.activate(ignoringOtherApps: true)
+ NSApp.activate(ignoringOtherApps: mpv.opts.focus_on_open)
+
+ // workaround for macOS 10.15 to refocus the previous App
+ if (!mpv.opts.focus_on_open) {
+ previousActiveApp?.activate(options: .activateAllWindows)
+ }
}
func initView(_ vo: UnsafeMutablePointer<vo>, _ layer: CALayer) {
@@ -419,6 +424,11 @@ class Common: NSObject {
return (mpv, targetScreen, wr)
}
+ // call before initApp, because on macOS +10.15 it changes the active App
+ func getActiveApp() -> NSRunningApplication? {
+ return NSWorkspace.shared.runningApplications.first(where: {$0.isActive})
+ }
+
func flagEvents(_ ev: Int) {
eventsLock.lock()
events |= ev