cocoa-cb: initial implementation via opengl-cb API
this is meant to replace the old and not properly working vo_gpu/opengl
cocoa backend in the future. the problems are various shortcomings of
Apple's opengl implementation and buggy behaviour in certain
circumstances that couldn't be properly worked around. there are also
certain regressions on newer macOS versions from 10.11 onwards.
- awful opengl performance with a none layer backed context
- huge amount of dropped frames with an early context flush
- flickering of system elements like the dock or volume indicator
- double buffering not properly working with a none layer backed context
- bad performance in fullscreen because of system optimisations
all the problems were caused by using a normal opengl context, that
seems somewhat abandoned by apple, and are fixed by using a layer backed
opengl context instead. problems that couldn't be fixed could be
properly worked around.
this has all features our old backend has sans the wid embedding,
the possibility to disable the automatic GPU switching and taking
screenshots of the window content. the first was deemed unnecessary by
me for now, since i just use the libmpv API that others can use anyway.
second is technically not possible atm because we have to pre-allocate
our opengl context at a time the config isn't read yet, so we can't get
the needed property. third one is a bit tricky because of deadlocking
and it needed to be in sync, hopefully i can work around that in the
future.
this also has at least one additional feature or eye-candy. a properly
working fullscreen animation with the native fs. also since this is a
direct port of the old backend of the parts that could be used, though
with adaptions and improvements, this looks a lot cleaner and easier to
understand.
some credit goes to @pigoz for the initial swift build support which
i could improve upon.
Fixes: #5478, #5393, #5152, #5151, #4615, #4476, #3978, #3746, #3739,
#2392, #2217
2018-02-12 11:28:19 +00:00
|
|
|
/*
|
|
|
|
* This file is part of mpv.
|
|
|
|
*
|
|
|
|
* mpv is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* mpv is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import Cocoa
|
|
|
|
|
2018-10-20 19:19:16 +00:00
|
|
|
class CustomTtitleBar: NSVisualEffectView {
|
|
|
|
|
|
|
|
// catch these events so they are not propagated to the underlying view
|
|
|
|
override func mouseDown(with event: NSEvent) { }
|
|
|
|
|
|
|
|
override func mouseUp(with event: NSEvent) {
|
|
|
|
if event.clickCount > 1 {
|
|
|
|
let def = UserDefaults.standard
|
|
|
|
var action = def.string(forKey: "AppleActionOnDoubleClick")
|
|
|
|
|
|
|
|
// macOS 10.10 and earlier
|
|
|
|
if action == nil {
|
|
|
|
action = def.bool(forKey: "AppleMiniaturizeOnDoubleClick") == true ?
|
|
|
|
"Minimize" : "Maximize"
|
|
|
|
}
|
|
|
|
|
|
|
|
if action == "Minimize" {
|
|
|
|
window!.miniaturize(self)
|
|
|
|
} else if action == "Maximize" {
|
|
|
|
window!.zoom(self)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
cocoa-cb: initial implementation via opengl-cb API
this is meant to replace the old and not properly working vo_gpu/opengl
cocoa backend in the future. the problems are various shortcomings of
Apple's opengl implementation and buggy behaviour in certain
circumstances that couldn't be properly worked around. there are also
certain regressions on newer macOS versions from 10.11 onwards.
- awful opengl performance with a none layer backed context
- huge amount of dropped frames with an early context flush
- flickering of system elements like the dock or volume indicator
- double buffering not properly working with a none layer backed context
- bad performance in fullscreen because of system optimisations
all the problems were caused by using a normal opengl context, that
seems somewhat abandoned by apple, and are fixed by using a layer backed
opengl context instead. problems that couldn't be fixed could be
properly worked around.
this has all features our old backend has sans the wid embedding,
the possibility to disable the automatic GPU switching and taking
screenshots of the window content. the first was deemed unnecessary by
me for now, since i just use the libmpv API that others can use anyway.
second is technically not possible atm because we have to pre-allocate
our opengl context at a time the config isn't read yet, so we can't get
the needed property. third one is a bit tricky because of deadlocking
and it needed to be in sync, hopefully i can work around that in the
future.
this also has at least one additional feature or eye-candy. a properly
working fullscreen animation with the native fs. also since this is a
direct port of the old backend of the parts that could be used, though
with adaptions and improvements, this looks a lot cleaner and easier to
understand.
some credit goes to @pigoz for the initial swift build support which
i could improve upon.
Fixes: #5478, #5393, #5152, #5151, #4615, #4476, #3978, #3746, #3739,
#2392, #2217
2018-02-12 11:28:19 +00:00
|
|
|
class Window: NSWindow, NSWindowDelegate {
|
|
|
|
|
|
|
|
weak var cocoaCB: CocoaCB! = nil
|
|
|
|
var mpv: MPVHelper! {
|
|
|
|
get { return cocoaCB == nil ? nil : cocoaCB.mpv }
|
|
|
|
}
|
|
|
|
|
|
|
|
var targetScreen: NSScreen?
|
|
|
|
var previousScreen: NSScreen?
|
|
|
|
var currentScreen: NSScreen?
|
|
|
|
var unfScreen: NSScreen?
|
|
|
|
|
|
|
|
var unfsContentFrame: NSRect?
|
|
|
|
var isInFullscreen: Bool = false
|
|
|
|
var isAnimating: Bool = false
|
|
|
|
var isMoving: Bool = false
|
|
|
|
var forceTargetScreen: Bool = false
|
|
|
|
|
|
|
|
var keepAspect: Bool = true {
|
|
|
|
didSet {
|
|
|
|
if !isInFullscreen {
|
|
|
|
unfsContentFrame = convertToScreen(contentView!.frame)
|
|
|
|
}
|
|
|
|
|
|
|
|
if keepAspect {
|
|
|
|
contentAspectRatio = unfsContentFrame!.size
|
|
|
|
} else {
|
|
|
|
resizeIncrements = NSSize(width: 1.0, height: 1.0)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-16 12:07:15 +00:00
|
|
|
var border: Bool = true {
|
|
|
|
didSet { if !border { hideTitleBar() } }
|
|
|
|
}
|
|
|
|
|
|
|
|
var titleBarEffect: NSVisualEffectView?
|
|
|
|
var titleBar: NSView {
|
|
|
|
get { return (standardWindowButton(.closeButton)?.superview)! }
|
|
|
|
}
|
|
|
|
var titleBarHeight: CGFloat {
|
|
|
|
get { return NSWindow.frameRect(forContentRect: CGRect.zero, styleMask: .titled).size.height }
|
|
|
|
}
|
|
|
|
var titleButtons: [NSButton] {
|
2018-03-01 19:21:14 +00:00
|
|
|
get { return ([.closeButton, .miniaturizeButton, .zoomButton] as [NSWindowButton]).flatMap { standardWindowButton($0) } }
|
2018-02-16 12:07:15 +00:00
|
|
|
}
|
|
|
|
|
cocoa-cb: initial implementation via opengl-cb API
this is meant to replace the old and not properly working vo_gpu/opengl
cocoa backend in the future. the problems are various shortcomings of
Apple's opengl implementation and buggy behaviour in certain
circumstances that couldn't be properly worked around. there are also
certain regressions on newer macOS versions from 10.11 onwards.
- awful opengl performance with a none layer backed context
- huge amount of dropped frames with an early context flush
- flickering of system elements like the dock or volume indicator
- double buffering not properly working with a none layer backed context
- bad performance in fullscreen because of system optimisations
all the problems were caused by using a normal opengl context, that
seems somewhat abandoned by apple, and are fixed by using a layer backed
opengl context instead. problems that couldn't be fixed could be
properly worked around.
this has all features our old backend has sans the wid embedding,
the possibility to disable the automatic GPU switching and taking
screenshots of the window content. the first was deemed unnecessary by
me for now, since i just use the libmpv API that others can use anyway.
second is technically not possible atm because we have to pre-allocate
our opengl context at a time the config isn't read yet, so we can't get
the needed property. third one is a bit tricky because of deadlocking
and it needed to be in sync, hopefully i can work around that in the
future.
this also has at least one additional feature or eye-candy. a properly
working fullscreen animation with the native fs. also since this is a
direct port of the old backend of the parts that could be used, though
with adaptions and improvements, this looks a lot cleaner and easier to
understand.
some credit goes to @pigoz for the initial swift build support which
i could improve upon.
Fixes: #5478, #5393, #5152, #5151, #4615, #4476, #3978, #3746, #3739,
#2392, #2217
2018-02-12 11:28:19 +00:00
|
|
|
override var canBecomeKey: Bool { return true }
|
|
|
|
override var canBecomeMain: Bool { return true }
|
|
|
|
|
|
|
|
override var styleMask: NSWindowStyleMask {
|
|
|
|
get { return super.styleMask }
|
|
|
|
set {
|
|
|
|
let responder = firstResponder
|
|
|
|
let windowTitle = title
|
|
|
|
super.styleMask = newValue
|
|
|
|
makeFirstResponder(responder)
|
|
|
|
title = windowTitle
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-06 15:04:40 +00:00
|
|
|
convenience init(contentRect: NSRect, screen: NSScreen?, view: NSView, cocoaCB ccb: CocoaCB) {
|
|
|
|
self.init(contentRect: contentRect,
|
|
|
|
styleMask: [.titled, .closable, .miniaturizable, .resizable],
|
cocoa-cb: initial implementation via opengl-cb API
this is meant to replace the old and not properly working vo_gpu/opengl
cocoa backend in the future. the problems are various shortcomings of
Apple's opengl implementation and buggy behaviour in certain
circumstances that couldn't be properly worked around. there are also
certain regressions on newer macOS versions from 10.11 onwards.
- awful opengl performance with a none layer backed context
- huge amount of dropped frames with an early context flush
- flickering of system elements like the dock or volume indicator
- double buffering not properly working with a none layer backed context
- bad performance in fullscreen because of system optimisations
all the problems were caused by using a normal opengl context, that
seems somewhat abandoned by apple, and are fixed by using a layer backed
opengl context instead. problems that couldn't be fixed could be
properly worked around.
this has all features our old backend has sans the wid embedding,
the possibility to disable the automatic GPU switching and taking
screenshots of the window content. the first was deemed unnecessary by
me for now, since i just use the libmpv API that others can use anyway.
second is technically not possible atm because we have to pre-allocate
our opengl context at a time the config isn't read yet, so we can't get
the needed property. third one is a bit tricky because of deadlocking
and it needed to be in sync, hopefully i can work around that in the
future.
this also has at least one additional feature or eye-candy. a properly
working fullscreen animation with the native fs. also since this is a
direct port of the old backend of the parts that could be used, though
with adaptions and improvements, this looks a lot cleaner and easier to
understand.
some credit goes to @pigoz for the initial swift build support which
i could improve upon.
Fixes: #5478, #5393, #5152, #5151, #4615, #4476, #3978, #3746, #3739,
#2392, #2217
2018-02-12 11:28:19 +00:00
|
|
|
backing: .buffered, defer: false, screen: screen)
|
|
|
|
cocoaCB = ccb
|
2018-06-06 15:04:40 +00:00
|
|
|
title = cocoaCB.title
|
cocoa-cb: initial implementation via opengl-cb API
this is meant to replace the old and not properly working vo_gpu/opengl
cocoa backend in the future. the problems are various shortcomings of
Apple's opengl implementation and buggy behaviour in certain
circumstances that couldn't be properly worked around. there are also
certain regressions on newer macOS versions from 10.11 onwards.
- awful opengl performance with a none layer backed context
- huge amount of dropped frames with an early context flush
- flickering of system elements like the dock or volume indicator
- double buffering not properly working with a none layer backed context
- bad performance in fullscreen because of system optimisations
all the problems were caused by using a normal opengl context, that
seems somewhat abandoned by apple, and are fixed by using a layer backed
opengl context instead. problems that couldn't be fixed could be
properly worked around.
this has all features our old backend has sans the wid embedding,
the possibility to disable the automatic GPU switching and taking
screenshots of the window content. the first was deemed unnecessary by
me for now, since i just use the libmpv API that others can use anyway.
second is technically not possible atm because we have to pre-allocate
our opengl context at a time the config isn't read yet, so we can't get
the needed property. third one is a bit tricky because of deadlocking
and it needed to be in sync, hopefully i can work around that in the
future.
this also has at least one additional feature or eye-candy. a properly
working fullscreen animation with the native fs. also since this is a
direct port of the old backend of the parts that could be used, though
with adaptions and improvements, this looks a lot cleaner and easier to
understand.
some credit goes to @pigoz for the initial swift build support which
i could improve upon.
Fixes: #5478, #5393, #5152, #5151, #4615, #4476, #3978, #3746, #3739,
#2392, #2217
2018-02-12 11:28:19 +00:00
|
|
|
minSize = NSMakeSize(160, 90)
|
|
|
|
collectionBehavior = .fullScreenPrimary
|
|
|
|
delegate = self
|
2018-06-06 15:04:40 +00:00
|
|
|
contentView!.addSubview(view)
|
|
|
|
view.frame = contentView!.frame
|
cocoa-cb: initial implementation via opengl-cb API
this is meant to replace the old and not properly working vo_gpu/opengl
cocoa backend in the future. the problems are various shortcomings of
Apple's opengl implementation and buggy behaviour in certain
circumstances that couldn't be properly worked around. there are also
certain regressions on newer macOS versions from 10.11 onwards.
- awful opengl performance with a none layer backed context
- huge amount of dropped frames with an early context flush
- flickering of system elements like the dock or volume indicator
- double buffering not properly working with a none layer backed context
- bad performance in fullscreen because of system optimisations
all the problems were caused by using a normal opengl context, that
seems somewhat abandoned by apple, and are fixed by using a layer backed
opengl context instead. problems that couldn't be fixed could be
properly worked around.
this has all features our old backend has sans the wid embedding,
the possibility to disable the automatic GPU switching and taking
screenshots of the window content. the first was deemed unnecessary by
me for now, since i just use the libmpv API that others can use anyway.
second is technically not possible atm because we have to pre-allocate
our opengl context at a time the config isn't read yet, so we can't get
the needed property. third one is a bit tricky because of deadlocking
and it needed to be in sync, hopefully i can work around that in the
future.
this also has at least one additional feature or eye-candy. a properly
working fullscreen animation with the native fs. also since this is a
direct port of the old backend of the parts that could be used, though
with adaptions and improvements, this looks a lot cleaner and easier to
understand.
some credit goes to @pigoz for the initial swift build support which
i could improve upon.
Fixes: #5478, #5393, #5152, #5151, #4615, #4476, #3978, #3746, #3739,
#2392, #2217
2018-02-12 11:28:19 +00:00
|
|
|
|
|
|
|
unfsContentFrame = convertToScreen(contentView!.frame)
|
|
|
|
targetScreen = screen!
|
|
|
|
currentScreen = screen!
|
|
|
|
unfScreen = screen!
|
2018-06-06 15:04:40 +00:00
|
|
|
initTitleBar()
|
cocoa-cb: initial implementation via opengl-cb API
this is meant to replace the old and not properly working vo_gpu/opengl
cocoa backend in the future. the problems are various shortcomings of
Apple's opengl implementation and buggy behaviour in certain
circumstances that couldn't be properly worked around. there are also
certain regressions on newer macOS versions from 10.11 onwards.
- awful opengl performance with a none layer backed context
- huge amount of dropped frames with an early context flush
- flickering of system elements like the dock or volume indicator
- double buffering not properly working with a none layer backed context
- bad performance in fullscreen because of system optimisations
all the problems were caused by using a normal opengl context, that
seems somewhat abandoned by apple, and are fixed by using a layer backed
opengl context instead. problems that couldn't be fixed could be
properly worked around.
this has all features our old backend has sans the wid embedding,
the possibility to disable the automatic GPU switching and taking
screenshots of the window content. the first was deemed unnecessary by
me for now, since i just use the libmpv API that others can use anyway.
second is technically not possible atm because we have to pre-allocate
our opengl context at a time the config isn't read yet, so we can't get
the needed property. third one is a bit tricky because of deadlocking
and it needed to be in sync, hopefully i can work around that in the
future.
this also has at least one additional feature or eye-candy. a properly
working fullscreen animation with the native fs. also since this is a
direct port of the old backend of the parts that could be used, though
with adaptions and improvements, this looks a lot cleaner and easier to
understand.
some credit goes to @pigoz for the initial swift build support which
i could improve upon.
Fixes: #5478, #5393, #5152, #5151, #4615, #4476, #3978, #3746, #3739,
#2392, #2217
2018-02-12 11:28:19 +00:00
|
|
|
|
|
|
|
if let app = NSApp as? Application {
|
|
|
|
app.menuBar.register(#selector(setHalfWindowSize), for: MPM_H_SIZE)
|
|
|
|
app.menuBar.register(#selector(setNormalWindowSize), for: MPM_N_SIZE)
|
|
|
|
app.menuBar.register(#selector(setDoubleWindowSize), for: MPM_D_SIZE)
|
|
|
|
app.menuBar.register(#selector(performMiniaturize(_:)), for: MPM_MINIMIZE)
|
|
|
|
app.menuBar.register(#selector(performZoom(_:)), for: MPM_ZOOM)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-16 12:07:15 +00:00
|
|
|
func initTitleBar() {
|
|
|
|
var f = contentView!.bounds
|
|
|
|
f.origin.y = f.size.height - titleBarHeight
|
|
|
|
f.size.height = titleBarHeight
|
|
|
|
|
|
|
|
styleMask.insert(.fullSizeContentView)
|
|
|
|
titleBar.alphaValue = 0
|
|
|
|
titlebarAppearsTransparent = true
|
2018-10-20 19:19:16 +00:00
|
|
|
titleBarEffect = CustomTtitleBar(frame: f)
|
2018-02-16 12:07:15 +00:00
|
|
|
titleBarEffect!.alphaValue = 0
|
|
|
|
titleBarEffect!.blendingMode = .withinWindow
|
|
|
|
titleBarEffect!.autoresizingMask = [.viewWidthSizable, .viewMinYMargin]
|
|
|
|
|
2018-06-06 15:04:40 +00:00
|
|
|
setTitleBarStyle(Int(mpv.macOpts!.macos_title_bar_style))
|
2018-02-16 12:07:15 +00:00
|
|
|
contentView!.addSubview(titleBarEffect!, positioned: .above, relativeTo: nil)
|
|
|
|
}
|
|
|
|
|
2018-06-06 15:04:40 +00:00
|
|
|
func setTitleBarStyle(_ style: Any) {
|
|
|
|
var effect: String
|
|
|
|
|
|
|
|
if style is Int {
|
|
|
|
switch style as! Int {
|
|
|
|
case 4:
|
|
|
|
effect = "auto"
|
|
|
|
case 3:
|
|
|
|
effect = "mediumlight"
|
|
|
|
case 2:
|
|
|
|
effect = "light"
|
|
|
|
case 1:
|
|
|
|
effect = "ultradark"
|
|
|
|
case 0: fallthrough
|
|
|
|
default:
|
|
|
|
effect = "dark"
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
effect = style as! String
|
|
|
|
}
|
|
|
|
|
2018-02-16 12:07:15 +00:00
|
|
|
if effect == "auto" {
|
|
|
|
let systemStyle = UserDefaults.standard.string(forKey: "AppleInterfaceStyle")
|
|
|
|
effect = systemStyle == nil ? "mediumlight" : "ultradark"
|
|
|
|
}
|
|
|
|
|
|
|
|
switch effect {
|
|
|
|
case "mediumlight":
|
|
|
|
appearance = NSAppearance(named: NSAppearanceNameVibrantLight)
|
|
|
|
titleBarEffect!.material = .titlebar
|
|
|
|
titleBarEffect!.state = .followsWindowActiveState
|
|
|
|
case "light":
|
|
|
|
appearance = NSAppearance(named: NSAppearanceNameVibrantLight)
|
|
|
|
titleBarEffect!.material = .light
|
|
|
|
titleBarEffect!.state = .active
|
|
|
|
case "ultradark":
|
|
|
|
appearance = NSAppearance(named: NSAppearanceNameVibrantDark)
|
|
|
|
titleBarEffect!.material = .titlebar
|
|
|
|
titleBarEffect!.state = .followsWindowActiveState
|
|
|
|
case "dark": fallthrough
|
|
|
|
default:
|
|
|
|
appearance = NSAppearance(named: NSAppearanceNameVibrantDark)
|
|
|
|
titleBarEffect!.material = .dark
|
|
|
|
titleBarEffect!.state = .active
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func showTitleBar() {
|
2018-03-13 20:14:27 +00:00
|
|
|
if titleBarEffect == nil || (!border && !isInFullscreen) { return }
|
2018-02-16 12:07:15 +00:00
|
|
|
let loc = cocoaCB.view.convert(mouseLocationOutsideOfEventStream, from: nil)
|
|
|
|
|
|
|
|
titleButtons.forEach { $0.isHidden = false }
|
|
|
|
NSAnimationContext.runAnimationGroup({ (context) -> Void in
|
|
|
|
context.duration = 0.20
|
|
|
|
titleBar.animator().alphaValue = 1
|
|
|
|
if !isInFullscreen && !isAnimating {
|
|
|
|
titleBarEffect!.animator().alphaValue = 1
|
2018-10-20 19:19:16 +00:00
|
|
|
titleBarEffect!.isHidden = false
|
2018-02-16 12:07:15 +00:00
|
|
|
}
|
|
|
|
}, completionHandler: nil )
|
|
|
|
|
|
|
|
if loc.y > titleBarHeight {
|
|
|
|
hideTitleBarDelayed()
|
|
|
|
} else {
|
|
|
|
NSObject.cancelPreviousPerformRequests(withTarget: self, selector: #selector(hideTitleBar), object: nil)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func hideTitleBar() {
|
2018-03-13 20:14:27 +00:00
|
|
|
if titleBarEffect == nil { return }
|
2018-02-16 12:07:15 +00:00
|
|
|
if isInFullscreen && !isAnimating {
|
|
|
|
titleBarEffect!.alphaValue = 0
|
2018-10-20 19:19:16 +00:00
|
|
|
titleBarEffect!.isHidden = true
|
2018-02-16 12:07:15 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
NSAnimationContext.runAnimationGroup({ (context) -> Void in
|
|
|
|
context.duration = 0.20
|
|
|
|
titleBar.animator().alphaValue = 0
|
|
|
|
titleBarEffect!.animator().alphaValue = 0
|
|
|
|
}, completionHandler: {
|
|
|
|
self.titleButtons.forEach { $0.isHidden = true }
|
2018-10-20 19:19:16 +00:00
|
|
|
self.titleBarEffect!.isHidden = true
|
2018-02-16 12:07:15 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func hideTitleBarDelayed() {
|
|
|
|
NSObject.cancelPreviousPerformRequests(withTarget: self,
|
|
|
|
selector: #selector(hideTitleBar),
|
|
|
|
object: nil)
|
|
|
|
perform(#selector(hideTitleBar), with: nil, afterDelay: 0.5)
|
|
|
|
}
|
|
|
|
|
cocoa-cb: initial implementation via opengl-cb API
this is meant to replace the old and not properly working vo_gpu/opengl
cocoa backend in the future. the problems are various shortcomings of
Apple's opengl implementation and buggy behaviour in certain
circumstances that couldn't be properly worked around. there are also
certain regressions on newer macOS versions from 10.11 onwards.
- awful opengl performance with a none layer backed context
- huge amount of dropped frames with an early context flush
- flickering of system elements like the dock or volume indicator
- double buffering not properly working with a none layer backed context
- bad performance in fullscreen because of system optimisations
all the problems were caused by using a normal opengl context, that
seems somewhat abandoned by apple, and are fixed by using a layer backed
opengl context instead. problems that couldn't be fixed could be
properly worked around.
this has all features our old backend has sans the wid embedding,
the possibility to disable the automatic GPU switching and taking
screenshots of the window content. the first was deemed unnecessary by
me for now, since i just use the libmpv API that others can use anyway.
second is technically not possible atm because we have to pre-allocate
our opengl context at a time the config isn't read yet, so we can't get
the needed property. third one is a bit tricky because of deadlocking
and it needed to be in sync, hopefully i can work around that in the
future.
this also has at least one additional feature or eye-candy. a properly
working fullscreen animation with the native fs. also since this is a
direct port of the old backend of the parts that could be used, though
with adaptions and improvements, this looks a lot cleaner and easier to
understand.
some credit goes to @pigoz for the initial swift build support which
i could improve upon.
Fixes: #5478, #5393, #5152, #5151, #4615, #4476, #3978, #3746, #3739,
#2392, #2217
2018-02-12 11:28:19 +00:00
|
|
|
override func toggleFullScreen(_ sender: Any?) {
|
|
|
|
if isAnimating {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
isAnimating = true
|
|
|
|
|
|
|
|
targetScreen = cocoaCB.getTargetScreen(forFullscreen: !isInFullscreen)
|
|
|
|
if targetScreen == nil && previousScreen == nil {
|
|
|
|
targetScreen = screen
|
|
|
|
} else if targetScreen == nil {
|
|
|
|
targetScreen = previousScreen
|
|
|
|
previousScreen = nil
|
|
|
|
} else {
|
|
|
|
previousScreen = screen
|
|
|
|
}
|
|
|
|
|
|
|
|
if !isInFullscreen {
|
|
|
|
unfsContentFrame = convertToScreen(contentView!.frame)
|
|
|
|
unfScreen = screen
|
|
|
|
}
|
|
|
|
// move window to target screen when going to fullscreen
|
|
|
|
if !isInFullscreen && (targetScreen != screen) {
|
|
|
|
let frame = calculateWindowPosition(for: targetScreen!, withoutBounds: false)
|
|
|
|
setFrame(frame, display: true)
|
|
|
|
}
|
|
|
|
|
|
|
|
if mpv.getBoolProperty("native-fs") {
|
|
|
|
super.toggleFullScreen(sender)
|
|
|
|
} else {
|
|
|
|
if !isInFullscreen {
|
|
|
|
setToFullScreen()
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
setToWindow()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func customWindowsToEnterFullScreen(for window: NSWindow) -> [NSWindow]? {
|
|
|
|
return [window]
|
|
|
|
}
|
|
|
|
|
|
|
|
func customWindowsToExitFullScreen(for window: NSWindow) -> [NSWindow]? {
|
|
|
|
return [window]
|
|
|
|
}
|
|
|
|
|
|
|
|
func window(_ window: NSWindow, startCustomAnimationToEnterFullScreenWithDuration duration: TimeInterval) {
|
2018-03-05 01:11:25 +00:00
|
|
|
cocoaCB.view.layerContentsPlacement = .scaleProportionallyToFit
|
2018-02-16 12:07:15 +00:00
|
|
|
hideTitleBar()
|
cocoa-cb: initial implementation via opengl-cb API
this is meant to replace the old and not properly working vo_gpu/opengl
cocoa backend in the future. the problems are various shortcomings of
Apple's opengl implementation and buggy behaviour in certain
circumstances that couldn't be properly worked around. there are also
certain regressions on newer macOS versions from 10.11 onwards.
- awful opengl performance with a none layer backed context
- huge amount of dropped frames with an early context flush
- flickering of system elements like the dock or volume indicator
- double buffering not properly working with a none layer backed context
- bad performance in fullscreen because of system optimisations
all the problems were caused by using a normal opengl context, that
seems somewhat abandoned by apple, and are fixed by using a layer backed
opengl context instead. problems that couldn't be fixed could be
properly worked around.
this has all features our old backend has sans the wid embedding,
the possibility to disable the automatic GPU switching and taking
screenshots of the window content. the first was deemed unnecessary by
me for now, since i just use the libmpv API that others can use anyway.
second is technically not possible atm because we have to pre-allocate
our opengl context at a time the config isn't read yet, so we can't get
the needed property. third one is a bit tricky because of deadlocking
and it needed to be in sync, hopefully i can work around that in the
future.
this also has at least one additional feature or eye-candy. a properly
working fullscreen animation with the native fs. also since this is a
direct port of the old backend of the parts that could be used, though
with adaptions and improvements, this looks a lot cleaner and easier to
understand.
some credit goes to @pigoz for the initial swift build support which
i could improve upon.
Fixes: #5478, #5393, #5152, #5151, #4615, #4476, #3978, #3746, #3739,
#2392, #2217
2018-02-12 11:28:19 +00:00
|
|
|
NSAnimationContext.runAnimationGroup({ (context) -> Void in
|
2018-02-27 23:46:16 +00:00
|
|
|
context.duration = getFsAnimationDuration(duration - 0.05)
|
2018-03-05 01:11:25 +00:00
|
|
|
window.animator().setFrame(targetScreen!.frame, display: true)
|
cocoa-cb: initial implementation via opengl-cb API
this is meant to replace the old and not properly working vo_gpu/opengl
cocoa backend in the future. the problems are various shortcomings of
Apple's opengl implementation and buggy behaviour in certain
circumstances that couldn't be properly worked around. there are also
certain regressions on newer macOS versions from 10.11 onwards.
- awful opengl performance with a none layer backed context
- huge amount of dropped frames with an early context flush
- flickering of system elements like the dock or volume indicator
- double buffering not properly working with a none layer backed context
- bad performance in fullscreen because of system optimisations
all the problems were caused by using a normal opengl context, that
seems somewhat abandoned by apple, and are fixed by using a layer backed
opengl context instead. problems that couldn't be fixed could be
properly worked around.
this has all features our old backend has sans the wid embedding,
the possibility to disable the automatic GPU switching and taking
screenshots of the window content. the first was deemed unnecessary by
me for now, since i just use the libmpv API that others can use anyway.
second is technically not possible atm because we have to pre-allocate
our opengl context at a time the config isn't read yet, so we can't get
the needed property. third one is a bit tricky because of deadlocking
and it needed to be in sync, hopefully i can work around that in the
future.
this also has at least one additional feature or eye-candy. a properly
working fullscreen animation with the native fs. also since this is a
direct port of the old backend of the parts that could be used, though
with adaptions and improvements, this looks a lot cleaner and easier to
understand.
some credit goes to @pigoz for the initial swift build support which
i could improve upon.
Fixes: #5478, #5393, #5152, #5151, #4615, #4476, #3978, #3746, #3739,
#2392, #2217
2018-02-12 11:28:19 +00:00
|
|
|
}, completionHandler: { })
|
|
|
|
}
|
|
|
|
|
|
|
|
func window(_ window: NSWindow, startCustomAnimationToExitFullScreenWithDuration duration: TimeInterval) {
|
|
|
|
let newFrame = calculateWindowPosition(for: targetScreen!, withoutBounds: targetScreen == screen)
|
|
|
|
let intermediateFrame = aspectFit(rect: newFrame, in: screen!.frame)
|
2018-03-05 01:11:25 +00:00
|
|
|
cocoaCB.view.layerContentsPlacement = .scaleProportionallyToFill
|
2018-02-16 12:07:15 +00:00
|
|
|
hideTitleBar()
|
2019-01-19 10:43:31 +00:00
|
|
|
styleMask.remove(.fullScreen)
|
cocoa-cb: initial implementation via opengl-cb API
this is meant to replace the old and not properly working vo_gpu/opengl
cocoa backend in the future. the problems are various shortcomings of
Apple's opengl implementation and buggy behaviour in certain
circumstances that couldn't be properly worked around. there are also
certain regressions on newer macOS versions from 10.11 onwards.
- awful opengl performance with a none layer backed context
- huge amount of dropped frames with an early context flush
- flickering of system elements like the dock or volume indicator
- double buffering not properly working with a none layer backed context
- bad performance in fullscreen because of system optimisations
all the problems were caused by using a normal opengl context, that
seems somewhat abandoned by apple, and are fixed by using a layer backed
opengl context instead. problems that couldn't be fixed could be
properly worked around.
this has all features our old backend has sans the wid embedding,
the possibility to disable the automatic GPU switching and taking
screenshots of the window content. the first was deemed unnecessary by
me for now, since i just use the libmpv API that others can use anyway.
second is technically not possible atm because we have to pre-allocate
our opengl context at a time the config isn't read yet, so we can't get
the needed property. third one is a bit tricky because of deadlocking
and it needed to be in sync, hopefully i can work around that in the
future.
this also has at least one additional feature or eye-candy. a properly
working fullscreen animation with the native fs. also since this is a
direct port of the old backend of the parts that could be used, though
with adaptions and improvements, this looks a lot cleaner and easier to
understand.
some credit goes to @pigoz for the initial swift build support which
i could improve upon.
Fixes: #5478, #5393, #5152, #5151, #4615, #4476, #3978, #3746, #3739,
#2392, #2217
2018-02-12 11:28:19 +00:00
|
|
|
setFrame(intermediateFrame, display: true)
|
|
|
|
|
|
|
|
NSAnimationContext.runAnimationGroup({ (context) -> Void in
|
2018-02-27 23:46:16 +00:00
|
|
|
context.duration = getFsAnimationDuration(duration - 0.05)
|
cocoa-cb: initial implementation via opengl-cb API
this is meant to replace the old and not properly working vo_gpu/opengl
cocoa backend in the future. the problems are various shortcomings of
Apple's opengl implementation and buggy behaviour in certain
circumstances that couldn't be properly worked around. there are also
certain regressions on newer macOS versions from 10.11 onwards.
- awful opengl performance with a none layer backed context
- huge amount of dropped frames with an early context flush
- flickering of system elements like the dock or volume indicator
- double buffering not properly working with a none layer backed context
- bad performance in fullscreen because of system optimisations
all the problems were caused by using a normal opengl context, that
seems somewhat abandoned by apple, and are fixed by using a layer backed
opengl context instead. problems that couldn't be fixed could be
properly worked around.
this has all features our old backend has sans the wid embedding,
the possibility to disable the automatic GPU switching and taking
screenshots of the window content. the first was deemed unnecessary by
me for now, since i just use the libmpv API that others can use anyway.
second is technically not possible atm because we have to pre-allocate
our opengl context at a time the config isn't read yet, so we can't get
the needed property. third one is a bit tricky because of deadlocking
and it needed to be in sync, hopefully i can work around that in the
future.
this also has at least one additional feature or eye-candy. a properly
working fullscreen animation with the native fs. also since this is a
direct port of the old backend of the parts that could be used, though
with adaptions and improvements, this looks a lot cleaner and easier to
understand.
some credit goes to @pigoz for the initial swift build support which
i could improve upon.
Fixes: #5478, #5393, #5152, #5151, #4615, #4476, #3978, #3746, #3739,
#2392, #2217
2018-02-12 11:28:19 +00:00
|
|
|
window.animator().setFrame(newFrame, display: true)
|
|
|
|
}, completionHandler: { })
|
|
|
|
}
|
|
|
|
|
|
|
|
func windowDidEnterFullScreen(_ notification: Notification) {
|
|
|
|
isInFullscreen = true
|
|
|
|
cocoaCB.flagEvents(VO_EVENT_FULLSCREEN_STATE)
|
|
|
|
cocoaCB.updateCusorVisibility()
|
2018-02-22 22:56:49 +00:00
|
|
|
endAnimation(frame)
|
2018-02-16 12:07:15 +00:00
|
|
|
showTitleBar()
|
cocoa-cb: initial implementation via opengl-cb API
this is meant to replace the old and not properly working vo_gpu/opengl
cocoa backend in the future. the problems are various shortcomings of
Apple's opengl implementation and buggy behaviour in certain
circumstances that couldn't be properly worked around. there are also
certain regressions on newer macOS versions from 10.11 onwards.
- awful opengl performance with a none layer backed context
- huge amount of dropped frames with an early context flush
- flickering of system elements like the dock or volume indicator
- double buffering not properly working with a none layer backed context
- bad performance in fullscreen because of system optimisations
all the problems were caused by using a normal opengl context, that
seems somewhat abandoned by apple, and are fixed by using a layer backed
opengl context instead. problems that couldn't be fixed could be
properly worked around.
this has all features our old backend has sans the wid embedding,
the possibility to disable the automatic GPU switching and taking
screenshots of the window content. the first was deemed unnecessary by
me for now, since i just use the libmpv API that others can use anyway.
second is technically not possible atm because we have to pre-allocate
our opengl context at a time the config isn't read yet, so we can't get
the needed property. third one is a bit tricky because of deadlocking
and it needed to be in sync, hopefully i can work around that in the
future.
this also has at least one additional feature or eye-candy. a properly
working fullscreen animation with the native fs. also since this is a
direct port of the old backend of the parts that could be used, though
with adaptions and improvements, this looks a lot cleaner and easier to
understand.
some credit goes to @pigoz for the initial swift build support which
i could improve upon.
Fixes: #5478, #5393, #5152, #5151, #4615, #4476, #3978, #3746, #3739,
#2392, #2217
2018-02-12 11:28:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func windowDidExitFullScreen(_ notification: Notification) {
|
|
|
|
isInFullscreen = false
|
|
|
|
cocoaCB.flagEvents(VO_EVENT_FULLSCREEN_STATE)
|
2018-02-22 22:56:49 +00:00
|
|
|
endAnimation(calculateWindowPosition(for: targetScreen!, withoutBounds: targetScreen == screen))
|
2018-03-05 01:11:25 +00:00
|
|
|
cocoaCB.view.layerContentsPlacement = .scaleProportionallyToFit
|
cocoa-cb: initial implementation via opengl-cb API
this is meant to replace the old and not properly working vo_gpu/opengl
cocoa backend in the future. the problems are various shortcomings of
Apple's opengl implementation and buggy behaviour in certain
circumstances that couldn't be properly worked around. there are also
certain regressions on newer macOS versions from 10.11 onwards.
- awful opengl performance with a none layer backed context
- huge amount of dropped frames with an early context flush
- flickering of system elements like the dock or volume indicator
- double buffering not properly working with a none layer backed context
- bad performance in fullscreen because of system optimisations
all the problems were caused by using a normal opengl context, that
seems somewhat abandoned by apple, and are fixed by using a layer backed
opengl context instead. problems that couldn't be fixed could be
properly worked around.
this has all features our old backend has sans the wid embedding,
the possibility to disable the automatic GPU switching and taking
screenshots of the window content. the first was deemed unnecessary by
me for now, since i just use the libmpv API that others can use anyway.
second is technically not possible atm because we have to pre-allocate
our opengl context at a time the config isn't read yet, so we can't get
the needed property. third one is a bit tricky because of deadlocking
and it needed to be in sync, hopefully i can work around that in the
future.
this also has at least one additional feature or eye-candy. a properly
working fullscreen animation with the native fs. also since this is a
direct port of the old backend of the parts that could be used, though
with adaptions and improvements, this looks a lot cleaner and easier to
understand.
some credit goes to @pigoz for the initial swift build support which
i could improve upon.
Fixes: #5478, #5393, #5152, #5151, #4615, #4476, #3978, #3746, #3739,
#2392, #2217
2018-02-12 11:28:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func windowDidFailToEnterFullScreen(_ window: NSWindow) {
|
|
|
|
let newFrame = calculateWindowPosition(for: targetScreen!, withoutBounds: targetScreen == screen)
|
|
|
|
setFrame(newFrame, display: true)
|
|
|
|
endAnimation()
|
|
|
|
}
|
|
|
|
|
|
|
|
func windowDidFailToExitFullScreen(_ window: NSWindow) {
|
|
|
|
let newFrame = targetScreen!.frame
|
|
|
|
setFrame(newFrame, display: true)
|
|
|
|
endAnimation()
|
2018-03-05 01:11:25 +00:00
|
|
|
cocoaCB.view.layerContentsPlacement = .scaleProportionallyToFit
|
cocoa-cb: initial implementation via opengl-cb API
this is meant to replace the old and not properly working vo_gpu/opengl
cocoa backend in the future. the problems are various shortcomings of
Apple's opengl implementation and buggy behaviour in certain
circumstances that couldn't be properly worked around. there are also
certain regressions on newer macOS versions from 10.11 onwards.
- awful opengl performance with a none layer backed context
- huge amount of dropped frames with an early context flush
- flickering of system elements like the dock or volume indicator
- double buffering not properly working with a none layer backed context
- bad performance in fullscreen because of system optimisations
all the problems were caused by using a normal opengl context, that
seems somewhat abandoned by apple, and are fixed by using a layer backed
opengl context instead. problems that couldn't be fixed could be
properly worked around.
this has all features our old backend has sans the wid embedding,
the possibility to disable the automatic GPU switching and taking
screenshots of the window content. the first was deemed unnecessary by
me for now, since i just use the libmpv API that others can use anyway.
second is technically not possible atm because we have to pre-allocate
our opengl context at a time the config isn't read yet, so we can't get
the needed property. third one is a bit tricky because of deadlocking
and it needed to be in sync, hopefully i can work around that in the
future.
this also has at least one additional feature or eye-candy. a properly
working fullscreen animation with the native fs. also since this is a
direct port of the old backend of the parts that could be used, though
with adaptions and improvements, this looks a lot cleaner and easier to
understand.
some credit goes to @pigoz for the initial swift build support which
i could improve upon.
Fixes: #5478, #5393, #5152, #5151, #4615, #4476, #3978, #3746, #3739,
#2392, #2217
2018-02-12 11:28:19 +00:00
|
|
|
}
|
|
|
|
|
2018-02-22 22:56:49 +00:00
|
|
|
func endAnimation(_ newFrame: NSRect = NSZeroRect) {
|
2018-06-15 10:49:09 +00:00
|
|
|
if !NSEqualRects(newFrame, NSZeroRect) && isAnimating {
|
2018-02-22 22:56:49 +00:00
|
|
|
NSAnimationContext.runAnimationGroup({ (context) -> Void in
|
|
|
|
context.duration = 0.01
|
|
|
|
self.animator().setFrame(newFrame, display: true)
|
|
|
|
}, completionHandler: nil )
|
|
|
|
}
|
|
|
|
|
cocoa-cb: initial implementation via opengl-cb API
this is meant to replace the old and not properly working vo_gpu/opengl
cocoa backend in the future. the problems are various shortcomings of
Apple's opengl implementation and buggy behaviour in certain
circumstances that couldn't be properly worked around. there are also
certain regressions on newer macOS versions from 10.11 onwards.
- awful opengl performance with a none layer backed context
- huge amount of dropped frames with an early context flush
- flickering of system elements like the dock or volume indicator
- double buffering not properly working with a none layer backed context
- bad performance in fullscreen because of system optimisations
all the problems were caused by using a normal opengl context, that
seems somewhat abandoned by apple, and are fixed by using a layer backed
opengl context instead. problems that couldn't be fixed could be
properly worked around.
this has all features our old backend has sans the wid embedding,
the possibility to disable the automatic GPU switching and taking
screenshots of the window content. the first was deemed unnecessary by
me for now, since i just use the libmpv API that others can use anyway.
second is technically not possible atm because we have to pre-allocate
our opengl context at a time the config isn't read yet, so we can't get
the needed property. third one is a bit tricky because of deadlocking
and it needed to be in sync, hopefully i can work around that in the
future.
this also has at least one additional feature or eye-candy. a properly
working fullscreen animation with the native fs. also since this is a
direct port of the old backend of the parts that could be used, though
with adaptions and improvements, this looks a lot cleaner and easier to
understand.
some credit goes to @pigoz for the initial swift build support which
i could improve upon.
Fixes: #5478, #5393, #5152, #5151, #4615, #4476, #3978, #3746, #3739,
#2392, #2217
2018-02-12 11:28:19 +00:00
|
|
|
isAnimating = false
|
2018-03-21 20:09:05 +00:00
|
|
|
cocoaCB.layer.update()
|
2018-03-16 12:52:15 +00:00
|
|
|
cocoaCB.checkShutdown()
|
cocoa-cb: initial implementation via opengl-cb API
this is meant to replace the old and not properly working vo_gpu/opengl
cocoa backend in the future. the problems are various shortcomings of
Apple's opengl implementation and buggy behaviour in certain
circumstances that couldn't be properly worked around. there are also
certain regressions on newer macOS versions from 10.11 onwards.
- awful opengl performance with a none layer backed context
- huge amount of dropped frames with an early context flush
- flickering of system elements like the dock or volume indicator
- double buffering not properly working with a none layer backed context
- bad performance in fullscreen because of system optimisations
all the problems were caused by using a normal opengl context, that
seems somewhat abandoned by apple, and are fixed by using a layer backed
opengl context instead. problems that couldn't be fixed could be
properly worked around.
this has all features our old backend has sans the wid embedding,
the possibility to disable the automatic GPU switching and taking
screenshots of the window content. the first was deemed unnecessary by
me for now, since i just use the libmpv API that others can use anyway.
second is technically not possible atm because we have to pre-allocate
our opengl context at a time the config isn't read yet, so we can't get
the needed property. third one is a bit tricky because of deadlocking
and it needed to be in sync, hopefully i can work around that in the
future.
this also has at least one additional feature or eye-candy. a properly
working fullscreen animation with the native fs. also since this is a
direct port of the old backend of the parts that could be used, though
with adaptions and improvements, this looks a lot cleaner and easier to
understand.
some credit goes to @pigoz for the initial swift build support which
i could improve upon.
Fixes: #5478, #5393, #5152, #5151, #4615, #4476, #3978, #3746, #3739,
#2392, #2217
2018-02-12 11:28:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func setToFullScreen() {
|
|
|
|
styleMask.insert(.fullScreen)
|
|
|
|
NSApp.presentationOptions = [.autoHideMenuBar, .autoHideDock]
|
|
|
|
setFrame(targetScreen!.frame, display: true)
|
|
|
|
endAnimation()
|
|
|
|
isInFullscreen = true
|
|
|
|
cocoaCB.flagEvents(VO_EVENT_FULLSCREEN_STATE)
|
2018-03-21 20:09:05 +00:00
|
|
|
cocoaCB.layer.update()
|
cocoa-cb: initial implementation via opengl-cb API
this is meant to replace the old and not properly working vo_gpu/opengl
cocoa backend in the future. the problems are various shortcomings of
Apple's opengl implementation and buggy behaviour in certain
circumstances that couldn't be properly worked around. there are also
certain regressions on newer macOS versions from 10.11 onwards.
- awful opengl performance with a none layer backed context
- huge amount of dropped frames with an early context flush
- flickering of system elements like the dock or volume indicator
- double buffering not properly working with a none layer backed context
- bad performance in fullscreen because of system optimisations
all the problems were caused by using a normal opengl context, that
seems somewhat abandoned by apple, and are fixed by using a layer backed
opengl context instead. problems that couldn't be fixed could be
properly worked around.
this has all features our old backend has sans the wid embedding,
the possibility to disable the automatic GPU switching and taking
screenshots of the window content. the first was deemed unnecessary by
me for now, since i just use the libmpv API that others can use anyway.
second is technically not possible atm because we have to pre-allocate
our opengl context at a time the config isn't read yet, so we can't get
the needed property. third one is a bit tricky because of deadlocking
and it needed to be in sync, hopefully i can work around that in the
future.
this also has at least one additional feature or eye-candy. a properly
working fullscreen animation with the native fs. also since this is a
direct port of the old backend of the parts that could be used, though
with adaptions and improvements, this looks a lot cleaner and easier to
understand.
some credit goes to @pigoz for the initial swift build support which
i could improve upon.
Fixes: #5478, #5393, #5152, #5151, #4615, #4476, #3978, #3746, #3739,
#2392, #2217
2018-02-12 11:28:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func setToWindow() {
|
|
|
|
let newFrame = calculateWindowPosition(for: targetScreen!, withoutBounds: targetScreen == screen)
|
|
|
|
NSApp.presentationOptions = []
|
|
|
|
setFrame(newFrame, display: true)
|
|
|
|
styleMask.remove(.fullScreen)
|
|
|
|
endAnimation()
|
|
|
|
isInFullscreen = false
|
|
|
|
cocoaCB.flagEvents(VO_EVENT_FULLSCREEN_STATE)
|
2018-03-21 20:09:05 +00:00
|
|
|
cocoaCB.layer.update()
|
cocoa-cb: initial implementation via opengl-cb API
this is meant to replace the old and not properly working vo_gpu/opengl
cocoa backend in the future. the problems are various shortcomings of
Apple's opengl implementation and buggy behaviour in certain
circumstances that couldn't be properly worked around. there are also
certain regressions on newer macOS versions from 10.11 onwards.
- awful opengl performance with a none layer backed context
- huge amount of dropped frames with an early context flush
- flickering of system elements like the dock or volume indicator
- double buffering not properly working with a none layer backed context
- bad performance in fullscreen because of system optimisations
all the problems were caused by using a normal opengl context, that
seems somewhat abandoned by apple, and are fixed by using a layer backed
opengl context instead. problems that couldn't be fixed could be
properly worked around.
this has all features our old backend has sans the wid embedding,
the possibility to disable the automatic GPU switching and taking
screenshots of the window content. the first was deemed unnecessary by
me for now, since i just use the libmpv API that others can use anyway.
second is technically not possible atm because we have to pre-allocate
our opengl context at a time the config isn't read yet, so we can't get
the needed property. third one is a bit tricky because of deadlocking
and it needed to be in sync, hopefully i can work around that in the
future.
this also has at least one additional feature or eye-candy. a properly
working fullscreen animation with the native fs. also since this is a
direct port of the old backend of the parts that could be used, though
with adaptions and improvements, this looks a lot cleaner and easier to
understand.
some credit goes to @pigoz for the initial swift build support which
i could improve upon.
Fixes: #5478, #5393, #5152, #5151, #4615, #4476, #3978, #3746, #3739,
#2392, #2217
2018-02-12 11:28:19 +00:00
|
|
|
}
|
|
|
|
|
2018-02-27 23:46:16 +00:00
|
|
|
func getFsAnimationDuration(_ def: Double) -> Double{
|
|
|
|
let duration = mpv.getStringProperty("macos-fs-animation-duration") ?? "default"
|
|
|
|
if duration == "default" {
|
|
|
|
return def
|
|
|
|
} else {
|
|
|
|
return Double(duration)!/1000
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-06 15:04:40 +00:00
|
|
|
func setOnTop(_ state: Bool, _ ontopLevel: Any) {
|
cocoa-cb: initial implementation via opengl-cb API
this is meant to replace the old and not properly working vo_gpu/opengl
cocoa backend in the future. the problems are various shortcomings of
Apple's opengl implementation and buggy behaviour in certain
circumstances that couldn't be properly worked around. there are also
certain regressions on newer macOS versions from 10.11 onwards.
- awful opengl performance with a none layer backed context
- huge amount of dropped frames with an early context flush
- flickering of system elements like the dock or volume indicator
- double buffering not properly working with a none layer backed context
- bad performance in fullscreen because of system optimisations
all the problems were caused by using a normal opengl context, that
seems somewhat abandoned by apple, and are fixed by using a layer backed
opengl context instead. problems that couldn't be fixed could be
properly worked around.
this has all features our old backend has sans the wid embedding,
the possibility to disable the automatic GPU switching and taking
screenshots of the window content. the first was deemed unnecessary by
me for now, since i just use the libmpv API that others can use anyway.
second is technically not possible atm because we have to pre-allocate
our opengl context at a time the config isn't read yet, so we can't get
the needed property. third one is a bit tricky because of deadlocking
and it needed to be in sync, hopefully i can work around that in the
future.
this also has at least one additional feature or eye-candy. a properly
working fullscreen animation with the native fs. also since this is a
direct port of the old backend of the parts that could be used, though
with adaptions and improvements, this looks a lot cleaner and easier to
understand.
some credit goes to @pigoz for the initial swift build support which
i could improve upon.
Fixes: #5478, #5393, #5152, #5151, #4615, #4476, #3978, #3746, #3739,
#2392, #2217
2018-02-12 11:28:19 +00:00
|
|
|
if state {
|
2018-06-06 15:04:40 +00:00
|
|
|
if ontopLevel is Int {
|
|
|
|
switch ontopLevel as! Int {
|
|
|
|
case -1:
|
|
|
|
level = Int(CGWindowLevelForKey(.floatingWindow))
|
|
|
|
case -2:
|
|
|
|
level = Int(CGWindowLevelForKey(.statusWindow))+1
|
|
|
|
default:
|
|
|
|
level = ontopLevel as! Int
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
switch ontopLevel as! String {
|
|
|
|
case "window":
|
|
|
|
level = Int(CGWindowLevelForKey(.floatingWindow))
|
|
|
|
case "system":
|
|
|
|
level = Int(CGWindowLevelForKey(.statusWindow))+1
|
|
|
|
default:
|
|
|
|
level = Int(ontopLevel as! String)!
|
|
|
|
}
|
cocoa-cb: initial implementation via opengl-cb API
this is meant to replace the old and not properly working vo_gpu/opengl
cocoa backend in the future. the problems are various shortcomings of
Apple's opengl implementation and buggy behaviour in certain
circumstances that couldn't be properly worked around. there are also
certain regressions on newer macOS versions from 10.11 onwards.
- awful opengl performance with a none layer backed context
- huge amount of dropped frames with an early context flush
- flickering of system elements like the dock or volume indicator
- double buffering not properly working with a none layer backed context
- bad performance in fullscreen because of system optimisations
all the problems were caused by using a normal opengl context, that
seems somewhat abandoned by apple, and are fixed by using a layer backed
opengl context instead. problems that couldn't be fixed could be
properly worked around.
this has all features our old backend has sans the wid embedding,
the possibility to disable the automatic GPU switching and taking
screenshots of the window content. the first was deemed unnecessary by
me for now, since i just use the libmpv API that others can use anyway.
second is technically not possible atm because we have to pre-allocate
our opengl context at a time the config isn't read yet, so we can't get
the needed property. third one is a bit tricky because of deadlocking
and it needed to be in sync, hopefully i can work around that in the
future.
this also has at least one additional feature or eye-candy. a properly
working fullscreen animation with the native fs. also since this is a
direct port of the old backend of the parts that could be used, though
with adaptions and improvements, this looks a lot cleaner and easier to
understand.
some credit goes to @pigoz for the initial swift build support which
i could improve upon.
Fixes: #5478, #5393, #5152, #5151, #4615, #4476, #3978, #3746, #3739,
#2392, #2217
2018-02-12 11:28:19 +00:00
|
|
|
}
|
|
|
|
collectionBehavior.remove(.transient)
|
|
|
|
collectionBehavior.insert(.managed)
|
|
|
|
} else {
|
|
|
|
level = Int(CGWindowLevelForKey(.normalWindow))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func updateMovableBackground(_ pos: NSPoint) {
|
|
|
|
if !isInFullscreen {
|
|
|
|
isMovableByWindowBackground = mpv.canBeDraggedAt(pos)
|
|
|
|
} else {
|
|
|
|
isMovableByWindowBackground = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func updateFrame(_ rect: NSRect) {
|
|
|
|
if rect != frame {
|
|
|
|
let cRect = frameRect(forContentRect: rect)
|
|
|
|
unfsContentFrame = rect
|
2018-03-02 18:27:37 +00:00
|
|
|
setFrame(cRect, display: true)
|
cocoa-cb: initial implementation via opengl-cb API
this is meant to replace the old and not properly working vo_gpu/opengl
cocoa backend in the future. the problems are various shortcomings of
Apple's opengl implementation and buggy behaviour in certain
circumstances that couldn't be properly worked around. there are also
certain regressions on newer macOS versions from 10.11 onwards.
- awful opengl performance with a none layer backed context
- huge amount of dropped frames with an early context flush
- flickering of system elements like the dock or volume indicator
- double buffering not properly working with a none layer backed context
- bad performance in fullscreen because of system optimisations
all the problems were caused by using a normal opengl context, that
seems somewhat abandoned by apple, and are fixed by using a layer backed
opengl context instead. problems that couldn't be fixed could be
properly worked around.
this has all features our old backend has sans the wid embedding,
the possibility to disable the automatic GPU switching and taking
screenshots of the window content. the first was deemed unnecessary by
me for now, since i just use the libmpv API that others can use anyway.
second is technically not possible atm because we have to pre-allocate
our opengl context at a time the config isn't read yet, so we can't get
the needed property. third one is a bit tricky because of deadlocking
and it needed to be in sync, hopefully i can work around that in the
future.
this also has at least one additional feature or eye-candy. a properly
working fullscreen animation with the native fs. also since this is a
direct port of the old backend of the parts that could be used, though
with adaptions and improvements, this looks a lot cleaner and easier to
understand.
some credit goes to @pigoz for the initial swift build support which
i could improve upon.
Fixes: #5478, #5393, #5152, #5151, #4615, #4476, #3978, #3746, #3739,
#2392, #2217
2018-02-12 11:28:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func updateSize(_ size: NSSize) {
|
|
|
|
if size != contentView!.frame.size {
|
|
|
|
let newContentFrame = centeredContentSize(for: frame, size: size)
|
|
|
|
if !isInFullscreen {
|
|
|
|
updateFrame(newContentFrame)
|
|
|
|
} else {
|
|
|
|
unfsContentFrame = newContentFrame
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
override func setFrame(_ frameRect: NSRect, display flag: Bool) {
|
2019-01-19 10:43:31 +00:00
|
|
|
super.setFrame(frameRect, display: flag)
|
2018-02-22 22:56:49 +00:00
|
|
|
|
cocoa-cb: initial implementation via opengl-cb API
this is meant to replace the old and not properly working vo_gpu/opengl
cocoa backend in the future. the problems are various shortcomings of
Apple's opengl implementation and buggy behaviour in certain
circumstances that couldn't be properly worked around. there are also
certain regressions on newer macOS versions from 10.11 onwards.
- awful opengl performance with a none layer backed context
- huge amount of dropped frames with an early context flush
- flickering of system elements like the dock or volume indicator
- double buffering not properly working with a none layer backed context
- bad performance in fullscreen because of system optimisations
all the problems were caused by using a normal opengl context, that
seems somewhat abandoned by apple, and are fixed by using a layer backed
opengl context instead. problems that couldn't be fixed could be
properly worked around.
this has all features our old backend has sans the wid embedding,
the possibility to disable the automatic GPU switching and taking
screenshots of the window content. the first was deemed unnecessary by
me for now, since i just use the libmpv API that others can use anyway.
second is technically not possible atm because we have to pre-allocate
our opengl context at a time the config isn't read yet, so we can't get
the needed property. third one is a bit tricky because of deadlocking
and it needed to be in sync, hopefully i can work around that in the
future.
this also has at least one additional feature or eye-candy. a properly
working fullscreen animation with the native fs. also since this is a
direct port of the old backend of the parts that could be used, though
with adaptions and improvements, this looks a lot cleaner and easier to
understand.
some credit goes to @pigoz for the initial swift build support which
i could improve upon.
Fixes: #5478, #5393, #5152, #5151, #4615, #4476, #3978, #3746, #3739,
#2392, #2217
2018-02-12 11:28:19 +00:00
|
|
|
if keepAspect {
|
|
|
|
contentAspectRatio = unfsContentFrame!.size
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func centeredContentSize(for rect: NSRect, size sz: NSSize) -> NSRect {
|
|
|
|
let cRect = contentRect(forFrameRect: rect)
|
|
|
|
let dx = (cRect.size.width - sz.width) / 2
|
|
|
|
let dy = (cRect.size.height - sz.height) / 2
|
|
|
|
return NSInsetRect(cRect, dx, dy)
|
|
|
|
}
|
|
|
|
|
|
|
|
func aspectFit(rect r: NSRect, in rTarget: NSRect) -> NSRect {
|
|
|
|
var s = rTarget.width / r.width;
|
|
|
|
if r.height*s > rTarget.height {
|
|
|
|
s = rTarget.height / r.height
|
|
|
|
}
|
|
|
|
let w = r.width * s
|
|
|
|
let h = r.height * s
|
|
|
|
return NSRect(x: rTarget.midX - w/2, y: rTarget.midY - h/2, width: w, height: h)
|
|
|
|
}
|
|
|
|
|
|
|
|
func calculateWindowPosition(for tScreen: NSScreen, withoutBounds: Bool) -> NSRect {
|
|
|
|
var newFrame = frameRect(forContentRect: unfsContentFrame!)
|
|
|
|
let targetFrame = tScreen.frame
|
|
|
|
let targetVisibleFrame = tScreen.visibleFrame
|
|
|
|
let unfsScreenFrame = unfScreen!.frame
|
|
|
|
let visibleWindow = NSIntersectionRect(unfsScreenFrame, newFrame)
|
|
|
|
|
|
|
|
// calculate visible area of every side
|
|
|
|
let left = newFrame.origin.x - unfsScreenFrame.origin.x
|
|
|
|
let right = unfsScreenFrame.size.width -
|
|
|
|
(newFrame.origin.x - unfsScreenFrame.origin.x + newFrame.size.width)
|
|
|
|
let bottom = newFrame.origin.y - unfsScreenFrame.origin.y
|
|
|
|
let top = unfsScreenFrame.size.height -
|
|
|
|
(newFrame.origin.y - unfsScreenFrame.origin.y + newFrame.size.height)
|
|
|
|
|
|
|
|
// normalize visible areas, decide which one to take horizontal/vertical
|
|
|
|
var xPer = (unfsScreenFrame.size.width - visibleWindow.size.width)
|
|
|
|
var yPer = (unfsScreenFrame.size.height - visibleWindow.size.height)
|
|
|
|
if xPer != 0 { xPer = (left >= 0 || right < 0 ? left : right) / xPer }
|
|
|
|
if yPer != 0 { yPer = (bottom >= 0 || top < 0 ? bottom : top) / yPer }
|
|
|
|
|
|
|
|
// calculate visible area for every side for target screen
|
|
|
|
let xNewLeft = targetFrame.origin.x +
|
|
|
|
(targetFrame.size.width - visibleWindow.size.width) * xPer
|
|
|
|
let xNewRight = targetFrame.origin.x + targetFrame.size.width -
|
|
|
|
(targetFrame.size.width - visibleWindow.size.width) * xPer - newFrame.size.width
|
|
|
|
let yNewBottom = targetFrame.origin.y +
|
|
|
|
(targetFrame.size.height - visibleWindow.size.height) * yPer
|
|
|
|
let yNewTop = targetFrame.origin.y + targetFrame.size.height -
|
|
|
|
(targetFrame.size.height - visibleWindow.size.height) * yPer - newFrame.size.height
|
|
|
|
|
|
|
|
// calculate new coordinates, decide which one to take horizontal/vertical
|
|
|
|
newFrame.origin.x = left >= 0 || right < 0 ? xNewLeft : xNewRight
|
|
|
|
newFrame.origin.y = bottom >= 0 || top < 0 ? yNewBottom : yNewTop
|
|
|
|
|
|
|
|
// don't place new window on top of a visible menubar
|
|
|
|
let topMar = targetFrame.size.height -
|
|
|
|
(newFrame.origin.y - targetFrame.origin.y + newFrame.size.height)
|
|
|
|
let menuBarHeight = targetFrame.size.height -
|
|
|
|
(targetVisibleFrame.size.height + targetVisibleFrame.origin.y)
|
|
|
|
if topMar < menuBarHeight {
|
|
|
|
newFrame.origin.y -= top - menuBarHeight
|
|
|
|
}
|
|
|
|
|
|
|
|
if withoutBounds {
|
|
|
|
return newFrame
|
|
|
|
}
|
|
|
|
|
|
|
|
// screen bounds right and left
|
|
|
|
if newFrame.origin.x + newFrame.size.width > targetFrame.origin.x + targetFrame.size.width {
|
|
|
|
newFrame.origin.x = targetFrame.origin.x + targetFrame.size.width - newFrame.size.width
|
|
|
|
}
|
|
|
|
if newFrame.origin.x < targetFrame.origin.x {
|
|
|
|
newFrame.origin.x = targetFrame.origin.x
|
|
|
|
}
|
|
|
|
|
|
|
|
// screen bounds top and bottom
|
|
|
|
if newFrame.origin.y + newFrame.size.height > targetFrame.origin.y + targetFrame.size.height {
|
|
|
|
newFrame.origin.y = targetFrame.origin.y + targetFrame.size.height - newFrame.size.height
|
|
|
|
}
|
|
|
|
if newFrame.origin.y < targetFrame.origin.y {
|
|
|
|
newFrame.origin.y = targetFrame.origin.y
|
|
|
|
}
|
|
|
|
return newFrame
|
|
|
|
}
|
|
|
|
|
|
|
|
override func constrainFrameRect(_ frameRect: NSRect, to tScreen: NSScreen?) -> NSRect {
|
|
|
|
if (isAnimating && !isInFullscreen) || (!isAnimating && isInFullscreen) {
|
|
|
|
return frameRect
|
|
|
|
}
|
|
|
|
|
|
|
|
var nf: NSRect = frameRect
|
|
|
|
let ts: NSScreen = tScreen ?? screen ?? NSScreen.main()!
|
|
|
|
let of: NSRect = frame
|
|
|
|
let vf: NSRect = (isAnimating ? targetScreen! : ts).visibleFrame
|
|
|
|
let ncf: NSRect = contentRect(forFrameRect: nf)
|
|
|
|
|
|
|
|
// screen bounds top and bottom
|
|
|
|
if NSMaxY(nf) > NSMaxY(vf) {
|
|
|
|
nf.origin.y = NSMaxY(vf) - NSHeight(nf)
|
|
|
|
}
|
|
|
|
if NSMaxY(ncf) < NSMinY(vf) {
|
|
|
|
nf.origin.y = NSMinY(vf) + NSMinY(ncf) - NSMaxY(ncf)
|
|
|
|
}
|
|
|
|
|
|
|
|
// screen bounds right and left
|
|
|
|
if NSMinX(nf) > NSMaxX(vf) {
|
|
|
|
nf.origin.x = NSMaxX(vf) - NSWidth(nf)
|
|
|
|
}
|
|
|
|
if NSMaxX(nf) < NSMinX(vf) {
|
|
|
|
nf.origin.x = NSMinX(vf)
|
|
|
|
}
|
|
|
|
|
|
|
|
if NSHeight(nf) < NSHeight(vf) && NSHeight(of) > NSHeight(vf) && !isInFullscreen {
|
|
|
|
// If the window height is smaller than the visible frame, but it was
|
|
|
|
// bigger previously recenter the smaller window vertically. This is
|
|
|
|
// needed to counter the 'snap to top' behaviour.
|
|
|
|
nf.origin.y = (NSHeight(vf) - NSHeight(nf)) / 2
|
|
|
|
}
|
|
|
|
return nf
|
|
|
|
}
|
|
|
|
|
|
|
|
func setNormalWindowSize() { setWindowScale(1.0) }
|
|
|
|
func setHalfWindowSize() { setWindowScale(0.5) }
|
|
|
|
func setDoubleWindowSize() { setWindowScale(2.0) }
|
|
|
|
|
|
|
|
func setWindowScale(_ scale: Double) {
|
|
|
|
mpv.commandAsync(["osd-auto", "set", "window-scale", "\(scale)"])
|
|
|
|
}
|
|
|
|
|
|
|
|
func windowDidChangeScreen(_ notification: Notification) {
|
|
|
|
if screen == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if !isAnimating && (currentScreen != screen) {
|
|
|
|
previousScreen = screen
|
|
|
|
}
|
|
|
|
if currentScreen != screen {
|
|
|
|
cocoaCB.updateDisplaylink()
|
|
|
|
}
|
|
|
|
currentScreen = screen
|
|
|
|
}
|
|
|
|
|
|
|
|
func windowDidChangeScreenProfile(_ notification: Notification) {
|
|
|
|
cocoaCB.layer.needsICCUpdate = true
|
|
|
|
}
|
|
|
|
|
|
|
|
func windowDidChangeBackingProperties(_ notification: Notification) {
|
|
|
|
cocoaCB.layer.contentsScale = backingScaleFactor
|
|
|
|
}
|
|
|
|
|
|
|
|
func windowWillStartLiveResize(_ notification: Notification) {
|
|
|
|
cocoaCB.layer.inLiveResize = true
|
|
|
|
}
|
|
|
|
|
|
|
|
func windowDidEndLiveResize(_ notification: Notification) {
|
|
|
|
cocoaCB.layer.inLiveResize = false
|
|
|
|
}
|
|
|
|
|
|
|
|
func windowShouldClose(_ sender: Any) -> Bool {
|
|
|
|
cocoa_put_key(SWIFT_KEY_CLOSE_WIN)
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2019-02-11 18:26:04 +00:00
|
|
|
func windowDidMiniaturize(_ notification: Notification) {
|
|
|
|
cocoaCB.flagEvents(VO_EVENT_WIN_STATE)
|
|
|
|
}
|
|
|
|
|
|
|
|
func windowDidDeminiaturize(_ notification: Notification) {
|
|
|
|
cocoaCB.flagEvents(VO_EVENT_WIN_STATE)
|
|
|
|
}
|
|
|
|
|
cocoa-cb: initial implementation via opengl-cb API
this is meant to replace the old and not properly working vo_gpu/opengl
cocoa backend in the future. the problems are various shortcomings of
Apple's opengl implementation and buggy behaviour in certain
circumstances that couldn't be properly worked around. there are also
certain regressions on newer macOS versions from 10.11 onwards.
- awful opengl performance with a none layer backed context
- huge amount of dropped frames with an early context flush
- flickering of system elements like the dock or volume indicator
- double buffering not properly working with a none layer backed context
- bad performance in fullscreen because of system optimisations
all the problems were caused by using a normal opengl context, that
seems somewhat abandoned by apple, and are fixed by using a layer backed
opengl context instead. problems that couldn't be fixed could be
properly worked around.
this has all features our old backend has sans the wid embedding,
the possibility to disable the automatic GPU switching and taking
screenshots of the window content. the first was deemed unnecessary by
me for now, since i just use the libmpv API that others can use anyway.
second is technically not possible atm because we have to pre-allocate
our opengl context at a time the config isn't read yet, so we can't get
the needed property. third one is a bit tricky because of deadlocking
and it needed to be in sync, hopefully i can work around that in the
future.
this also has at least one additional feature or eye-candy. a properly
working fullscreen animation with the native fs. also since this is a
direct port of the old backend of the parts that could be used, though
with adaptions and improvements, this looks a lot cleaner and easier to
understand.
some credit goes to @pigoz for the initial swift build support which
i could improve upon.
Fixes: #5478, #5393, #5152, #5151, #4615, #4476, #3978, #3746, #3739,
#2392, #2217
2018-02-12 11:28:19 +00:00
|
|
|
func windowDidResignKey(_ notification: Notification) {
|
|
|
|
cocoaCB.setCursorVisiblility(true)
|
|
|
|
}
|
|
|
|
|
|
|
|
func windowDidBecomeKey(_ notification: Notification) {
|
|
|
|
cocoaCB.updateCusorVisibility()
|
|
|
|
}
|
|
|
|
|
2018-06-12 00:48:31 +00:00
|
|
|
func windowDidChangeOcclusionState(_ notification: Notification) {
|
|
|
|
if occlusionState.contains(.visible) {
|
|
|
|
cocoaCB.layer.update(force: true)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
cocoa-cb: initial implementation via opengl-cb API
this is meant to replace the old and not properly working vo_gpu/opengl
cocoa backend in the future. the problems are various shortcomings of
Apple's opengl implementation and buggy behaviour in certain
circumstances that couldn't be properly worked around. there are also
certain regressions on newer macOS versions from 10.11 onwards.
- awful opengl performance with a none layer backed context
- huge amount of dropped frames with an early context flush
- flickering of system elements like the dock or volume indicator
- double buffering not properly working with a none layer backed context
- bad performance in fullscreen because of system optimisations
all the problems were caused by using a normal opengl context, that
seems somewhat abandoned by apple, and are fixed by using a layer backed
opengl context instead. problems that couldn't be fixed could be
properly worked around.
this has all features our old backend has sans the wid embedding,
the possibility to disable the automatic GPU switching and taking
screenshots of the window content. the first was deemed unnecessary by
me for now, since i just use the libmpv API that others can use anyway.
second is technically not possible atm because we have to pre-allocate
our opengl context at a time the config isn't read yet, so we can't get
the needed property. third one is a bit tricky because of deadlocking
and it needed to be in sync, hopefully i can work around that in the
future.
this also has at least one additional feature or eye-candy. a properly
working fullscreen animation with the native fs. also since this is a
direct port of the old backend of the parts that could be used, though
with adaptions and improvements, this looks a lot cleaner and easier to
understand.
some credit goes to @pigoz for the initial swift build support which
i could improve upon.
Fixes: #5478, #5393, #5152, #5151, #4615, #4476, #3978, #3746, #3739,
#2392, #2217
2018-02-12 11:28:19 +00:00
|
|
|
func windowWillMove(_ notification: Notification) {
|
|
|
|
isMoving = true
|
|
|
|
}
|
|
|
|
}
|