summaryrefslogtreecommitdiffstats
path: root/video/out/cocoa-cb/events_view.swift
diff options
context:
space:
mode:
authorder richter <der.richter@gmx.de>2019-09-29 18:35:12 +0200
committerder richter <der.richter@gmx.de>2019-10-06 13:29:48 +0200
commit6d0f0546ee851f4106438c5b92c8d1d152937ea7 (patch)
treef4efc2a603081fe75c19bea86c261d5320716c5b /video/out/cocoa-cb/events_view.swift
parent2b19a7c964b821945e3ea06cfa81c1c064f2504d (diff)
downloadmpv-6d0f0546ee851f4106438c5b92c8d1d152937ea7.tar.bz2
mpv-6d0f0546ee851f4106438c5b92c8d1d152937ea7.tar.xz
cocoa-cb: remove get_property_* usages and split up mpv helper
all the get_property_* usages were removed because in some circumstances they can lead to deadlocks. they were replaced by accessing the vo and mp_vo_opts structs directly, like on other vos. additionally the mpv helper was split into a mpv and libmpv helper, to differentiate between private and public APIs and for future changes like a macOS vulkan context for vo=gpu.
Diffstat (limited to 'video/out/cocoa-cb/events_view.swift')
-rw-r--r--video/out/cocoa-cb/events_view.swift31
1 files changed, 15 insertions, 16 deletions
diff --git a/video/out/cocoa-cb/events_view.swift b/video/out/cocoa-cb/events_view.swift
index 59441d9793..31533bbb98 100644
--- a/video/out/cocoa-cb/events_view.swift
+++ b/video/out/cocoa-cb/events_view.swift
@@ -19,8 +19,8 @@ import Cocoa
class EventsView: NSView {
- weak var cocoaCB: CocoaCB!
- var mpv: MPVHelper { get { return cocoaCB.mpv } }
+ unowned var cocoaCB: CocoaCB
+ var mpv: MPVHelper? { get { return cocoaCB.mpv } }
var tracker: NSTrackingArea?
var hasMouseDown: Bool = false
@@ -117,64 +117,64 @@ class EventsView: NSView {
}
override func mouseEntered(with event: NSEvent) {
- if mpv.getBoolProperty("input-cursor") {
+ if mpv?.mouseEnabled() ?? true {
cocoa_put_key_with_modifiers(SWIFT_KEY_MOUSE_ENTER, 0)
}
}
override func mouseExited(with event: NSEvent) {
- if mpv.getBoolProperty("input-cursor") {
+ if mpv?.mouseEnabled() ?? true {
cocoa_put_key_with_modifiers(SWIFT_KEY_MOUSE_LEAVE, 0)
}
cocoaCB.titleBar?.hide()
}
override func mouseMoved(with event: NSEvent) {
- if mpv.getBoolProperty("input-cursor") {
+ if mpv?.mouseEnabled() ?? true {
signalMouseMovement(event)
}
cocoaCB.titleBar?.show()
}
override func mouseDragged(with event: NSEvent) {
- if mpv.getBoolProperty("input-cursor") {
+ if mpv?.mouseEnabled() ?? true {
signalMouseMovement(event)
}
}
override func mouseDown(with event: NSEvent) {
- if mpv.getBoolProperty("input-cursor") {
+ if mpv?.mouseEnabled() ?? true {
signalMouseDown(event)
}
}
override func mouseUp(with event: NSEvent) {
- if mpv.getBoolProperty("input-cursor") {
+ if mpv?.mouseEnabled() ?? true {
signalMouseUp(event)
}
cocoaCB.window?.isMoving = false
}
override func rightMouseDown(with event: NSEvent) {
- if mpv.getBoolProperty("input-cursor") {
+ if mpv?.mouseEnabled() ?? true {
signalMouseDown(event)
}
}
override func rightMouseUp(with event: NSEvent) {
- if mpv.getBoolProperty("input-cursor") {
+ if mpv?.mouseEnabled() ?? true {
signalMouseUp(event)
}
}
override func otherMouseDown(with event: NSEvent) {
- if mpv.getBoolProperty("input-cursor") {
+ if mpv?.mouseEnabled() ?? true {
signalMouseDown(event)
}
}
override func otherMouseUp(with event: NSEvent) {
- if mpv.getBoolProperty("input-cursor") {
+ if mpv?.mouseEnabled() ?? true {
signalMouseUp(event)
}
}
@@ -203,7 +203,7 @@ class EventsView: NSView {
cocoaCB.window?.updateMovableBackground(point)
if !(cocoaCB.window?.isMoving ?? false) {
- mpv.setMousePosition(point)
+ mpv?.setMousePosition(point)
}
}
@@ -219,11 +219,11 @@ class EventsView: NSView {
cmd = delta > 0 ? SWIFT_WHEEL_RIGHT : SWIFT_WHEEL_LEFT;
}
- mpv.putAxis(cmd, delta: abs(delta))
+ mpv?.putAxis(cmd, delta: abs(delta))
}
override func scrollWheel(with event: NSEvent) {
- if !mpv.getBoolProperty("input-cursor") {
+ if !(mpv?.mouseEnabled() ?? true) {
return
}
@@ -246,7 +246,6 @@ class EventsView: NSView {
}
func containsMouseLocation() -> Bool {
- if cocoaCB == nil { return false }
var topMargin: CGFloat = 0.0
let menuBarHeight = NSApp.mainMenu?.menuBarHeight ?? 23.0