Skip to content

Commit 7a3e19f

Browse files
committed
generalisations
1 parent e0014f8 commit 7a3e19f

File tree

1 file changed

+12
-52
lines changed

1 file changed

+12
-52
lines changed

video/out/mac_common.swift

Lines changed: 12 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -35,74 +35,29 @@ class MacCommon: Common {
3535
layer?.displaySyncEnabled = true
3636
}
3737

38-
startDisplayLink(vo)
39-
initLightSensor()
40-
addDisplayReconfigureObserver()
38+
initMisc(vo)
4139
}
4240
}
4341

4442
@objc func config(_ vo: UnsafeMutablePointer<vo>) -> Bool {
4543
mpv?.vo = vo
4644

4745
DispatchQueue.main.sync {
48-
NSApp.setActivationPolicy(.regular)
49-
setAppIcon()
46+
initApp()
47+
48+
let (mpv, _, wr) = getInitProperties(vo)
5049

51-
guard let mpv = mpv else {
52-
// TODO log helper refactor
53-
//log.sendWarning("Unexpected nil value in Control Callback")
54-
exit(1)
55-
}
5650
guard let layer = self.layer else {
57-
log.sendError("Something went wrong, no Video was initialized")
58-
exit(1)
59-
}
60-
guard let targetScreen = getScreenBy(id: Int(mpv.opts.screen_id)) ?? NSScreen.main else {
61-
log.sendError("Something went wrong, no Screen was found")
51+
log.sendError("Something went wrong, no MetalLayer was initialized")
6252
exit(1)
6353
}
6454

6555
print(mpv.vout.dwidth)
6656
print(mpv.vout.dheight)
6757

68-
let wr = getWindowGeometry(forScreen: targetScreen, videoOut: vo)
6958
if window == nil {
70-
view = EventsView(frame: wr, common: self)
71-
guard let view = self.view else {
72-
log.sendError("Something went wrong, no View was initialized")
73-
exit(1)
74-
}
75-
76-
window = Window(contentRect: wr, screen: targetScreen, view: view, common: self)
77-
guard let window = self.window else {
78-
log.sendError("Something went wrong, no Window was initialized")
79-
exit(1)
80-
}
81-
82-
view.layer = layer
83-
view.wantsLayer = true
84-
view.layerContentsPlacement = .scaleProportionallyToFit
85-
//view?.layerContentsRedrawPolicy = .duringViewResize
86-
87-
window.setOnTop(Bool(mpv.opts.ontop), Int(mpv.opts.ontop_level))
88-
window.keepAspect = Bool(mpv.opts.keepaspect_window)
89-
window.title = title
90-
window.border = Bool(mpv.opts.border)
91-
92-
titleBar = TitleBar(frame: wr, window: window, common: self)
93-
94-
let minimized = Bool(mpv.opts.window_minimized)
95-
window.isRestorable = false
96-
window.setMaximized(minimized ? false : Bool(mpv.opts.window_maximized))
97-
window.setMinimized(minimized)
98-
window.makeMain()
99-
window.makeKey()
100-
101-
if !minimized {
102-
window.orderFront(nil)
103-
}
104-
105-
NSApp.activate(ignoringOtherApps: true)
59+
initView(vo, layer)
60+
initWindow(vo)
10661
}
10762

10863
print(mpv.vout.dwidth)
@@ -125,6 +80,8 @@ class MacCommon: Common {
12580
window?.title = title
12681

12782

83+
84+
12885
//todo remove
12986
flagEvents(VO_EVENT_ICC_PROFILE_CHANGED)
13087

@@ -145,6 +102,9 @@ class MacCommon: Common {
145102

146103
print(layer.colorspace)
147104

105+
106+
107+
148108
if Bool(mpv.opts.fullscreen) {
149109
DispatchQueue.main.async { [weak self] in
150110
self?.window?.toggleFullScreen(nil)

0 commit comments

Comments
 (0)