mirror of https://github.com/mpv-player/mpv
mac/option: move option functionality from mpv helper to option helper
delete now empty mpv helper
This commit is contained in:
parent
283d0877c4
commit
dc5059d027
|
@ -1520,8 +1520,8 @@ if features['cocoa'] and features['swift']
|
|||
swift_sources += files('osdep/mac/libmpv_helper.swift',
|
||||
'osdep/mac/input_helper.swift',
|
||||
'osdep/mac/log_helper.swift',
|
||||
'osdep/mac/mpv_helper.swift',
|
||||
'osdep/mac/menu_bar.swift',
|
||||
'osdep/mac/option_helper.swift',
|
||||
'osdep/mac/precise_timer.swift',
|
||||
'osdep/mac/swift_compat.swift',
|
||||
'osdep/mac/swift_extensions.swift',
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
import Carbon.HIToolbox
|
||||
|
||||
class InputHelper: NSObject {
|
||||
var mpv: MPVHelper?
|
||||
var option: OptionHelper?
|
||||
var lock = NSCondition()
|
||||
private var input: OpaquePointer?
|
||||
|
||||
|
@ -62,10 +62,10 @@ class InputHelper: NSObject {
|
|||
.init(0, 0)
|
||||
]
|
||||
|
||||
@objc init(_ input: OpaquePointer? = nil, _ mpv: MPVHelper? = nil) {
|
||||
@objc init(_ input: OpaquePointer? = nil, _ option: OptionHelper? = nil) {
|
||||
super.init()
|
||||
self.input = input
|
||||
self.mpv = mpv
|
||||
self.option = option
|
||||
}
|
||||
|
||||
@objc func put(
|
||||
|
@ -232,11 +232,11 @@ class InputHelper: NSObject {
|
|||
@objc func open(files: [String]) {
|
||||
lock.withLock {
|
||||
guard let input = input else { return }
|
||||
if (mpv?.opts.drag_and_drop ?? -1) == -2 { return }
|
||||
if (option?.opts.drag_and_drop ?? -1) == -2 { return }
|
||||
|
||||
var action = NSEvent.modifierFlags.contains(.shift) ? DND_APPEND : DND_REPLACE
|
||||
if (mpv?.opts.drag_and_drop ?? -1) >= 0 {
|
||||
action = mp_dnd_action(UInt32(mpv?.opts.drag_and_drop ?? Int32(DND_REPLACE.rawValue)))
|
||||
if (option?.opts.drag_and_drop ?? -1) >= 0 {
|
||||
action = mp_dnd_action(UInt32(option?.opts.drag_and_drop ?? Int32(DND_REPLACE.rawValue)))
|
||||
}
|
||||
|
||||
let filesClean = files.map{ $0.hasPrefix("file:///.file/id=") ? (URL(string: $0)?.path ?? $0) : $0 }
|
||||
|
|
|
@ -19,7 +19,7 @@ import Cocoa
|
|||
|
||||
typealias swift_wakeup_cb_fn = (@convention(c) (UnsafeMutableRawPointer?) -> Void)?
|
||||
|
||||
class MPVHelper: NSObject {
|
||||
class OptionHelper: NSObject {
|
||||
var log: LogHelper
|
||||
var vo: UnsafeMutablePointer<vo>
|
||||
var optsCachePtr: UnsafeMutablePointer<m_config_cache>
|
|
@ -24,7 +24,7 @@ struct Timing {
|
|||
|
||||
class PreciseTimer {
|
||||
unowned var common: Common
|
||||
var mpv: MPVHelper? { get { return common.mpv } }
|
||||
var option: OptionHelper? { get { return common.option } }
|
||||
|
||||
let nanoPerSecond: Double = 1e+9
|
||||
let machToNano: Double = {
|
||||
|
|
|
@ -39,8 +39,8 @@ class CocoaCB: Common {
|
|||
}
|
||||
|
||||
func preinit(_ vo: UnsafeMutablePointer<vo>) {
|
||||
mpv = MPVHelper(vo, log)
|
||||
input = InputHelper(vo.pointee.input_ctx, mpv)
|
||||
option = OptionHelper(vo, log)
|
||||
input = InputHelper(vo.pointee.input_ctx, option)
|
||||
|
||||
if backendState == .uninitialized {
|
||||
backendState = .needsInit
|
||||
|
@ -58,18 +58,18 @@ class CocoaCB: Common {
|
|||
func uninit() {
|
||||
window?.orderOut(nil)
|
||||
window?.close()
|
||||
mpv = nil
|
||||
option = nil
|
||||
}
|
||||
|
||||
func reconfig(_ vo: UnsafeMutablePointer<vo>) {
|
||||
mpv?.vo = vo
|
||||
option?.vo = vo
|
||||
if backendState == .needsInit {
|
||||
DispatchQueue.main.sync { self.initBackend(vo) }
|
||||
} else if mpv?.opts.auto_window_resize ?? true {
|
||||
} else if option?.opts.auto_window_resize ?? true {
|
||||
DispatchQueue.main.async {
|
||||
self.updateWindowSize(vo)
|
||||
self.layer?.update(force: true)
|
||||
if self.mpv?.opts.focus_on ?? 1 == 2 {
|
||||
if self.option?.opts.focus_on ?? 1 == 2 {
|
||||
NSApp.activate(ignoringOtherApps: true)
|
||||
}
|
||||
}
|
||||
|
@ -204,7 +204,7 @@ class CocoaCB: Common {
|
|||
|
||||
func shutdown(_ destroy: Bool = false) {
|
||||
isShuttingDown = window?.isAnimating ?? false ||
|
||||
window?.isInFullscreen ?? false && mpv?.opts.native_fs ?? true
|
||||
window?.isInFullscreen ?? false && option?.opts.native_fs ?? true
|
||||
if window?.isInFullscreen ?? false && !(window?.isAnimating ?? false) {
|
||||
window?.close()
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ import Cocoa
|
|||
import IOKit.pwr_mgt
|
||||
|
||||
class Common: NSObject {
|
||||
var mpv: MPVHelper?
|
||||
var option: OptionHelper?
|
||||
var input: InputHelper?
|
||||
var log: LogHelper
|
||||
let queue: DispatchQueue = DispatchQueue(label: "io.mpv.queue")
|
||||
|
@ -52,8 +52,8 @@ class Common: NSObject {
|
|||
}
|
||||
|
||||
func initMisc(_ vo: UnsafeMutablePointer<vo>) {
|
||||
guard let mpv = mpv else {
|
||||
log.sendError("Something went wrong, no MPVHelper was initialized")
|
||||
guard let option = option else {
|
||||
log.sendError("Something went wrong, no OptionHelper was initialized")
|
||||
exit(1)
|
||||
}
|
||||
|
||||
|
@ -61,17 +61,17 @@ class Common: NSObject {
|
|||
initLightSensor()
|
||||
addDisplayReconfigureObserver()
|
||||
addAppNotifications()
|
||||
mpv.setMacOptionCallback(macOptsWakeupCallback, context: self)
|
||||
option.setMacOptionCallback(macOptsWakeupCallback, context: self)
|
||||
}
|
||||
|
||||
func initApp() {
|
||||
guard let mpv = mpv else {
|
||||
log.sendError("Something went wrong, no MPVHelper was initialized")
|
||||
guard let option = option else {
|
||||
log.sendError("Something went wrong, no OptionHelper was initialized")
|
||||
exit(1)
|
||||
}
|
||||
|
||||
var policy: NSApplication.ActivationPolicy = .regular
|
||||
switch mpv.macOpts.macos_app_activation_policy {
|
||||
switch option.macOpts.macos_app_activation_policy {
|
||||
case 0:
|
||||
policy = .regular
|
||||
case 1:
|
||||
|
@ -87,7 +87,7 @@ class Common: NSObject {
|
|||
}
|
||||
|
||||
func initWindow(_ vo: UnsafeMutablePointer<vo>, _ previousActiveApp: NSRunningApplication?) {
|
||||
let (mpv, targetScreen, wr) = getInitProperties(vo)
|
||||
let (option, targetScreen, wr) = getInitProperties(vo)
|
||||
|
||||
guard let view = self.view else {
|
||||
log.sendError("Something went wrong, no View was initialized")
|
||||
|
@ -100,16 +100,16 @@ class Common: NSObject {
|
|||
exit(1)
|
||||
}
|
||||
|
||||
window.setOnTop(Bool(mpv.opts.ontop), Int(mpv.opts.ontop_level))
|
||||
window.setOnAllWorkspaces(Bool(mpv.opts.all_workspaces))
|
||||
window.keepAspect = Bool(mpv.opts.keepaspect_window)
|
||||
window.setOnTop(Bool(option.opts.ontop), Int(option.opts.ontop_level))
|
||||
window.setOnAllWorkspaces(Bool(option.opts.all_workspaces))
|
||||
window.keepAspect = Bool(option.opts.keepaspect_window)
|
||||
window.title = title
|
||||
window.border = Bool(mpv.opts.border)
|
||||
window.border = Bool(option.opts.border)
|
||||
|
||||
titleBar = TitleBar(frame: wr, window: window, common: self)
|
||||
|
||||
let maximized = Bool(mpv.opts.window_maximized)
|
||||
let minimized = Bool(mpv.opts.window_minimized)
|
||||
let maximized = Bool(option.opts.window_maximized)
|
||||
let minimized = Bool(option.opts.window_minimized)
|
||||
window.isRestorable = false
|
||||
window.isReleasedWhenClosed = false
|
||||
window.setMaximized((minimized || !maximized) ? window.isZoomed : maximized)
|
||||
|
@ -123,10 +123,10 @@ class Common: NSObject {
|
|||
window.orderFront(nil)
|
||||
}
|
||||
|
||||
NSApp.activate(ignoringOtherApps: mpv.opts.focus_on >= 1)
|
||||
NSApp.activate(ignoringOtherApps: option.opts.focus_on >= 1)
|
||||
|
||||
// workaround for macOS 10.15 to refocus the previous App
|
||||
if mpv.opts.focus_on == 0 {
|
||||
if option.opts.focus_on == 0 {
|
||||
previousActiveApp?.activate()
|
||||
}
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ class Common: NSObject {
|
|||
}
|
||||
|
||||
func initWindowState() {
|
||||
if mpv?.opts.fullscreen ?? false {
|
||||
if option?.opts.fullscreen ?? false {
|
||||
DispatchQueue.main.async {
|
||||
self.window?.toggleFullScreen(nil)
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ class Common: NSObject {
|
|||
guard let screen = getTargetScreen(forFullscreen: false) ?? NSScreen.main,
|
||||
let link = self.link else
|
||||
{
|
||||
log.sendWarning("Couldn't start DisplayLink, no MPVHelper, Screen or DisplayLink available")
|
||||
log.sendWarning("Couldn't start DisplayLink, no OptionHelper, Screen or DisplayLink available")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -409,14 +409,14 @@ class Common: NSObject {
|
|||
}
|
||||
|
||||
func getTargetScreen(forFullscreen fs: Bool) -> NSScreen? {
|
||||
guard let mpv = mpv else {
|
||||
guard let option = option else {
|
||||
log.sendWarning("Unexpected nil value in getTargetScreen")
|
||||
return nil
|
||||
}
|
||||
|
||||
let screenID = fs ? mpv.opts.fsscreen_id : mpv.opts.screen_id
|
||||
let screenID = fs ? option.opts.fsscreen_id : option.opts.screen_id
|
||||
var name: String?
|
||||
if let screenName = fs ? mpv.opts.fsscreen_name : mpv.opts.screen_name {
|
||||
if let screenName = fs ? option.opts.fsscreen_name : option.opts.screen_name {
|
||||
name = String(cString: screenName)
|
||||
}
|
||||
return getScreenBy(id: Int(screenID)) ?? getScreenBy(name: name)
|
||||
|
@ -431,7 +431,7 @@ class Common: NSObject {
|
|||
func getWindowGeometry(forScreen screen: NSScreen,
|
||||
videoOut vo: UnsafeMutablePointer<vo>) -> NSRect {
|
||||
let r = screen.convertRectToBacking(screen.frame)
|
||||
let targetFrame = (mpv?.macOpts.macos_geometry_calculation ?? Int32(FRAME_VISIBLE)) == FRAME_VISIBLE
|
||||
let targetFrame = (option?.macOpts.macos_geometry_calculation ?? Int32(FRAME_VISIBLE)) == FRAME_VISIBLE
|
||||
? screen.visibleFrame : screen.frame
|
||||
let rv = screen.convertRectToBacking(targetFrame)
|
||||
|
||||
|
@ -458,9 +458,9 @@ class Common: NSObject {
|
|||
return screen.convertRectFromBacking(NSMakeRect(x, y, width, height))
|
||||
}
|
||||
|
||||
func getInitProperties(_ vo: UnsafeMutablePointer<vo>) -> (MPVHelper, NSScreen, NSRect) {
|
||||
guard let mpv = mpv else {
|
||||
log.sendError("Something went wrong, no MPVHelper was initialized")
|
||||
func getInitProperties(_ vo: UnsafeMutablePointer<vo>) -> (OptionHelper, NSScreen, NSRect) {
|
||||
guard let option = option else {
|
||||
log.sendError("Something went wrong, no OptionHelper was initialized")
|
||||
exit(1)
|
||||
}
|
||||
guard let targetScreen = getTargetScreen(forFullscreen: false) ?? NSScreen.main else {
|
||||
|
@ -470,7 +470,7 @@ class Common: NSObject {
|
|||
|
||||
let wr = getWindowGeometry(forScreen: targetScreen, videoOut: vo)
|
||||
|
||||
return (mpv, targetScreen, wr)
|
||||
return (option, targetScreen, wr)
|
||||
}
|
||||
|
||||
// call before initApp, because on macOS +10.15 it changes the active App
|
||||
|
@ -483,7 +483,7 @@ class Common: NSObject {
|
|||
events |= ev
|
||||
eventsLock.unlock()
|
||||
|
||||
guard let vout = mpv?.vo else {
|
||||
guard let vout = option?.vo else {
|
||||
log.sendWarning("vo nil in flagEvents")
|
||||
return
|
||||
}
|
||||
|
@ -515,7 +515,7 @@ class Common: NSObject {
|
|||
request: UInt32,
|
||||
data: UnsafeMutableRawPointer?) -> Int32
|
||||
{
|
||||
guard let mpv = mpv else {
|
||||
guard let option = option else {
|
||||
log.sendWarning("Unexpected nil value in Control Callback")
|
||||
return VO_FALSE
|
||||
}
|
||||
|
@ -526,45 +526,45 @@ class Common: NSObject {
|
|||
return VO_TRUE
|
||||
case VOCTRL_VO_OPTS_CHANGED:
|
||||
var opt: UnsafeMutableRawPointer?
|
||||
while mpv.nextChangedOption(property: &opt) {
|
||||
while option.nextChangedOption(property: &opt) {
|
||||
switch opt {
|
||||
case TypeHelper.toPointer(&mpv.optsPtr.pointee.border):
|
||||
case TypeHelper.toPointer(&option.optsPtr.pointee.border):
|
||||
DispatchQueue.main.async {
|
||||
self.window?.border = Bool(mpv.opts.border)
|
||||
self.window?.border = Bool(option.opts.border)
|
||||
}
|
||||
case TypeHelper.toPointer(&mpv.optsPtr.pointee.fullscreen):
|
||||
case TypeHelper.toPointer(&option.optsPtr.pointee.fullscreen):
|
||||
DispatchQueue.main.async {
|
||||
self.window?.toggleFullScreen(nil)
|
||||
}
|
||||
case TypeHelper.toPointer(&mpv.optsPtr.pointee.ontop): fallthrough
|
||||
case TypeHelper.toPointer(&mpv.optsPtr.pointee.ontop_level):
|
||||
case TypeHelper.toPointer(&option.optsPtr.pointee.ontop): fallthrough
|
||||
case TypeHelper.toPointer(&option.optsPtr.pointee.ontop_level):
|
||||
DispatchQueue.main.async {
|
||||
self.window?.setOnTop(Bool(mpv.opts.ontop), Int(mpv.opts.ontop_level))
|
||||
self.window?.setOnTop(Bool(option.opts.ontop), Int(option.opts.ontop_level))
|
||||
}
|
||||
case TypeHelper.toPointer(&mpv.optsPtr.pointee.all_workspaces):
|
||||
case TypeHelper.toPointer(&option.optsPtr.pointee.all_workspaces):
|
||||
DispatchQueue.main.async {
|
||||
self.window?.setOnAllWorkspaces(Bool(mpv.opts.all_workspaces))
|
||||
self.window?.setOnAllWorkspaces(Bool(option.opts.all_workspaces))
|
||||
}
|
||||
case TypeHelper.toPointer(&mpv.optsPtr.pointee.keepaspect_window):
|
||||
case TypeHelper.toPointer(&option.optsPtr.pointee.keepaspect_window):
|
||||
DispatchQueue.main.async {
|
||||
self.window?.keepAspect = Bool(mpv.opts.keepaspect_window)
|
||||
self.window?.keepAspect = Bool(option.opts.keepaspect_window)
|
||||
}
|
||||
case TypeHelper.toPointer(&mpv.optsPtr.pointee.window_minimized):
|
||||
case TypeHelper.toPointer(&option.optsPtr.pointee.window_minimized):
|
||||
DispatchQueue.main.async {
|
||||
self.window?.setMinimized(Bool(mpv.opts.window_minimized))
|
||||
self.window?.setMinimized(Bool(option.opts.window_minimized))
|
||||
}
|
||||
case TypeHelper.toPointer(&mpv.optsPtr.pointee.window_maximized):
|
||||
case TypeHelper.toPointer(&option.optsPtr.pointee.window_maximized):
|
||||
DispatchQueue.main.async {
|
||||
self.window?.setMaximized(Bool(mpv.opts.window_maximized))
|
||||
self.window?.setMaximized(Bool(option.opts.window_maximized))
|
||||
}
|
||||
case TypeHelper.toPointer(&mpv.optsPtr.pointee.cursor_passthrough):
|
||||
case TypeHelper.toPointer(&option.optsPtr.pointee.cursor_passthrough):
|
||||
DispatchQueue.main.async {
|
||||
self.window?.ignoresMouseEvents = mpv.opts.cursor_passthrough
|
||||
self.window?.ignoresMouseEvents = option.opts.cursor_passthrough
|
||||
}
|
||||
case TypeHelper.toPointer(&mpv.optsPtr.pointee.geometry): fallthrough
|
||||
case TypeHelper.toPointer(&mpv.optsPtr.pointee.autofit): fallthrough
|
||||
case TypeHelper.toPointer(&mpv.optsPtr.pointee.autofit_smaller): fallthrough
|
||||
case TypeHelper.toPointer(&mpv.optsPtr.pointee.autofit_larger):
|
||||
case TypeHelper.toPointer(&option.optsPtr.pointee.geometry): fallthrough
|
||||
case TypeHelper.toPointer(&option.optsPtr.pointee.autofit): fallthrough
|
||||
case TypeHelper.toPointer(&option.optsPtr.pointee.autofit_smaller): fallthrough
|
||||
case TypeHelper.toPointer(&option.optsPtr.pointee.autofit_larger):
|
||||
DispatchQueue.main.async {
|
||||
let (_, _, wr) = self.getInitProperties(vo)
|
||||
self.window?.updateFrame(wr)
|
||||
|
@ -630,7 +630,7 @@ class Common: NSObject {
|
|||
let sizeData = data!.assumingMemoryBound(to: Int32.self)
|
||||
let size = UnsafeMutableBufferPointer(start: sizeData, count: 2)
|
||||
var rect = window?.unfsContentFrame ?? NSRect(x: 0, y: 0, width: 1280, height: 720)
|
||||
if let screen = window?.currentScreen, !Bool(mpv.opts.hidpi_window_scale) {
|
||||
if let screen = window?.currentScreen, !Bool(option.opts.hidpi_window_scale) {
|
||||
rect = screen.convertRectToBacking(rect)
|
||||
}
|
||||
|
||||
|
@ -642,7 +642,7 @@ class Common: NSObject {
|
|||
let size = UnsafeBufferPointer(start: sizeData, count: 2)
|
||||
var rect = NSMakeRect(0, 0, CGFloat(size[0]), CGFloat(size[1]))
|
||||
DispatchQueue.main.async {
|
||||
if let screen = self.window?.currentScreen, !Bool(self.mpv?.opts.hidpi_window_scale ?? true) {
|
||||
if let screen = self.window?.currentScreen, !Bool(self.option?.opts.hidpi_window_scale ?? true) {
|
||||
rect = screen.convertRectFromBacking(rect)
|
||||
}
|
||||
self.window?.updateSize(rect.size)
|
||||
|
@ -692,20 +692,20 @@ class Common: NSObject {
|
|||
}
|
||||
|
||||
func macOptsUpdate() {
|
||||
guard let mpv = mpv else {
|
||||
guard let option = option else {
|
||||
log.sendWarning("Unexpected nil value in mac opts update")
|
||||
return
|
||||
}
|
||||
|
||||
var opt: UnsafeMutableRawPointer?
|
||||
while mpv.nextChangedMacOption(property: &opt) {
|
||||
while option.nextChangedMacOption(property: &opt) {
|
||||
switch opt {
|
||||
case TypeHelper.toPointer(&mpv.macOptsPtr.pointee.macos_title_bar_appearance):
|
||||
titleBar?.set(appearance: Int(mpv.macOpts.macos_title_bar_appearance))
|
||||
case TypeHelper.toPointer(&mpv.macOptsPtr.pointee.macos_title_bar_material):
|
||||
titleBar?.set(material: Int(mpv.macOpts.macos_title_bar_material))
|
||||
case TypeHelper.toPointer(&mpv.macOptsPtr.pointee.macos_title_bar_color):
|
||||
titleBar?.set(color: mpv.macOpts.macos_title_bar_color)
|
||||
case TypeHelper.toPointer(&option.macOptsPtr.pointee.macos_title_bar_appearance):
|
||||
titleBar?.set(appearance: Int(option.macOpts.macos_title_bar_appearance))
|
||||
case TypeHelper.toPointer(&option.macOptsPtr.pointee.macos_title_bar_material):
|
||||
titleBar?.set(material: Int(option.macOpts.macos_title_bar_material))
|
||||
case TypeHelper.toPointer(&option.macOptsPtr.pointee.macos_title_bar_color):
|
||||
titleBar?.set(color: option.macOpts.macos_title_bar_color)
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ import Cocoa
|
|||
|
||||
class TitleBar: NSVisualEffectView {
|
||||
unowned var common: Common
|
||||
var mpv: MPVHelper? { get { return common.mpv } }
|
||||
var option: OptionHelper? { get { return common.option } }
|
||||
|
||||
var systemBar: NSView? {
|
||||
get { return common.window?.standardWindowButton(.closeButton)?.superview }
|
||||
|
@ -64,9 +64,9 @@ class TitleBar: NSVisualEffectView {
|
|||
window.contentView?.addSubview(self, positioned: .above, relativeTo: nil)
|
||||
window.titlebarAppearsTransparent = true
|
||||
window.styleMask.insert(.fullSizeContentView)
|
||||
set(appearance: Int(mpv?.macOpts.macos_title_bar_appearance ?? 0))
|
||||
set(material: Int(mpv?.macOpts.macos_title_bar_material ?? 0))
|
||||
set(color: mpv?.macOpts.macos_title_bar_color ?? "#00000000")
|
||||
set(appearance: Int(option?.macOpts.macos_title_bar_appearance ?? 0))
|
||||
set(material: Int(option?.macOpts.macos_title_bar_material ?? 0))
|
||||
set(color: option?.macOpts.macos_title_bar_color ?? "#00000000")
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
|
|
|
@ -19,7 +19,7 @@ import Cocoa
|
|||
|
||||
class View: NSView, CALayerDelegate {
|
||||
unowned var common: Common
|
||||
var mpv: MPVHelper? { get { return common.mpv } }
|
||||
var option: OptionHelper? { get { return common.option } }
|
||||
var input: InputHelper? { get { return common.input } }
|
||||
|
||||
var tracker: NSTrackingArea?
|
||||
|
|
|
@ -19,7 +19,7 @@ import Cocoa
|
|||
|
||||
class Window: NSWindow, NSWindowDelegate {
|
||||
weak var common: Common! = nil
|
||||
var mpv: MPVHelper? { get { return common.mpv } }
|
||||
var option: OptionHelper? { get { return common.option } }
|
||||
var input: InputHelper? { get { return common.input } }
|
||||
|
||||
var targetScreen: NSScreen?
|
||||
|
@ -92,7 +92,7 @@ class Window: NSWindow, NSWindowDelegate {
|
|||
title = com.title
|
||||
minSize = NSMakeSize(160, 90)
|
||||
collectionBehavior = .fullScreenPrimary
|
||||
ignoresMouseEvents = mpv?.opts.cursor_passthrough ?? false
|
||||
ignoresMouseEvents = option?.opts.cursor_passthrough ?? false
|
||||
delegate = self
|
||||
|
||||
if let cView = contentView {
|
||||
|
@ -143,7 +143,7 @@ class Window: NSWindow, NSWindowDelegate {
|
|||
setFrame(frame, display: true)
|
||||
}
|
||||
|
||||
if Bool(mpv?.opts.native_fs ?? true) {
|
||||
if Bool(option?.opts.native_fs ?? true) {
|
||||
super.toggleFullScreen(sender)
|
||||
} else {
|
||||
if !isInFullscreen {
|
||||
|
@ -194,7 +194,7 @@ class Window: NSWindow, NSWindowDelegate {
|
|||
|
||||
func windowDidEnterFullScreen(_ notification: Notification) {
|
||||
isInFullscreen = true
|
||||
mpv?.setOption(fullscreen: isInFullscreen)
|
||||
option?.setOption(fullscreen: isInFullscreen)
|
||||
common.updateCursorVisibility()
|
||||
endAnimation(frame)
|
||||
common.titleBar?.show()
|
||||
|
@ -203,7 +203,7 @@ class Window: NSWindow, NSWindowDelegate {
|
|||
func windowDidExitFullScreen(_ notification: Notification) {
|
||||
guard let tScreen = targetScreen else { return }
|
||||
isInFullscreen = false
|
||||
mpv?.setOption(fullscreen: isInFullscreen)
|
||||
option?.setOption(fullscreen: isInFullscreen)
|
||||
endAnimation(calculateWindowPosition(for: tScreen, withoutBounds: targetScreen == screen))
|
||||
common.view?.layerContentsPlacement = .scaleProportionallyToFit
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ class Window: NSWindow, NSWindowDelegate {
|
|||
setFrame(targetFrame, display: true)
|
||||
endAnimation()
|
||||
isInFullscreen = true
|
||||
mpv?.setOption(fullscreen: isInFullscreen)
|
||||
option?.setOption(fullscreen: isInFullscreen)
|
||||
common.windowSetToFullScreen()
|
||||
}
|
||||
|
||||
|
@ -270,7 +270,7 @@ class Window: NSWindow, NSWindowDelegate {
|
|||
setFrame(newFrame, display: true)
|
||||
endAnimation()
|
||||
isInFullscreen = false
|
||||
mpv?.setOption(fullscreen: isInFullscreen)
|
||||
option?.setOption(fullscreen: isInFullscreen)
|
||||
common.windowSetToWindow()
|
||||
}
|
||||
|
||||
|
@ -283,7 +283,7 @@ class Window: NSWindow, NSWindowDelegate {
|
|||
}
|
||||
|
||||
func getFsAnimationDuration(_ def: Double) -> Double {
|
||||
let duration = mpv?.macOpts.macos_fs_animation_duration ?? -1
|
||||
let duration = option?.macOpts.macos_fs_animation_duration ?? -1
|
||||
if duration < 0 {
|
||||
return def
|
||||
} else {
|
||||
|
@ -542,7 +542,7 @@ class Window: NSWindow, NSWindowDelegate {
|
|||
|
||||
func windowDidEndLiveResize(_ notification: Notification) {
|
||||
common.windowDidEndLiveResize()
|
||||
mpv?.setOption(maximized: isZoomed)
|
||||
option?.setOption(maximized: isZoomed)
|
||||
|
||||
if let contentViewFrame = contentView?.frame,
|
||||
!isAnimating && !isInFullscreen
|
||||
|
@ -561,11 +561,11 @@ class Window: NSWindow, NSWindowDelegate {
|
|||
}
|
||||
|
||||
func windowDidMiniaturize(_ notification: Notification) {
|
||||
mpv?.setOption(minimized: true)
|
||||
option?.setOption(minimized: true)
|
||||
}
|
||||
|
||||
func windowDidDeminiaturize(_ notification: Notification) {
|
||||
mpv?.setOption(minimized: false)
|
||||
option?.setOption(minimized: false)
|
||||
}
|
||||
|
||||
func windowDidResignKey(_ notification: Notification) {
|
||||
|
@ -588,6 +588,6 @@ class Window: NSWindow, NSWindowDelegate {
|
|||
}
|
||||
|
||||
func windowDidMove(_ notification: Notification) {
|
||||
mpv?.setOption(maximized: isZoomed)
|
||||
option?.setOption(maximized: isZoomed)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,8 +27,8 @@ class MacCommon: Common {
|
|||
@objc init(_ vo: UnsafeMutablePointer<vo>) {
|
||||
let newlog = mp_log_new(vo, vo.pointee.log, "mac")
|
||||
super.init(newlog)
|
||||
mpv = MPVHelper(vo, log)
|
||||
input = InputHelper(vo.pointee.input_ctx, mpv)
|
||||
option = OptionHelper(vo, log)
|
||||
input = InputHelper(vo.pointee.input_ctx, option)
|
||||
timer = PreciseTimer(common: self)
|
||||
|
||||
DispatchQueue.main.sync {
|
||||
|
@ -38,7 +38,7 @@ class MacCommon: Common {
|
|||
}
|
||||
|
||||
@objc func config(_ vo: UnsafeMutablePointer<vo>) -> Bool {
|
||||
mpv?.vo = vo
|
||||
option?.vo = vo
|
||||
|
||||
DispatchQueue.main.sync {
|
||||
let previousActiveApp = getActiveApp()
|
||||
|
@ -58,12 +58,12 @@ class MacCommon: Common {
|
|||
}
|
||||
|
||||
if !NSEqualSizes(window?.unfsContentFramePixel.size ?? NSZeroSize, wr.size) &&
|
||||
mpv?.opts.auto_window_resize ?? true
|
||||
option?.opts.auto_window_resize ?? true
|
||||
{
|
||||
window?.updateSize(wr.size)
|
||||
}
|
||||
|
||||
if mpv?.opts.focus_on ?? 1 == 2 {
|
||||
if option?.opts.focus_on ?? 1 == 2 {
|
||||
NSApp.activate(ignoringOtherApps: true)
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ class MacCommon: Common {
|
|||
}
|
||||
|
||||
@objc func swapBuffer() {
|
||||
if mpv?.macOpts.macos_render_timer ?? Int32(RENDER_TIMER_CALLBACK) != RENDER_TIMER_SYSTEM {
|
||||
if option?.macOpts.macos_render_timer ?? Int32(RENDER_TIMER_CALLBACK) != RENDER_TIMER_SYSTEM {
|
||||
swapLock.lock()
|
||||
while(swapTime < 1) {
|
||||
swapLock.wait()
|
||||
|
@ -104,7 +104,7 @@ class MacCommon: Common {
|
|||
_ flagsIn: CVOptionFlags,
|
||||
_ flagsOut: UnsafeMutablePointer<CVOptionFlags>) -> CVReturn
|
||||
{
|
||||
let frameTimer = mpv?.macOpts.macos_render_timer ?? Int32(RENDER_TIMER_CALLBACK)
|
||||
let frameTimer = option?.macOpts.macos_render_timer ?? Int32(RENDER_TIMER_CALLBACK)
|
||||
let signalSwap = {
|
||||
self.swapLock.lock()
|
||||
self.swapTime += 1
|
||||
|
|
Loading…
Reference in New Issue