diff --git a/video/out/cocoa-cb/events_view.swift b/video/out/cocoa-cb/events_view.swift index 124a7a028d..296d447634 100644 --- a/video/out/cocoa-cb/events_view.swift +++ b/video/out/cocoa-cb/events_view.swift @@ -120,6 +120,7 @@ class EventsView: NSView { if mpv?.mouseEnabled() ?? true { cocoa_put_key_with_modifiers(SWIFT_KEY_MOUSE_ENTER, 0) } + cocoaCB.updateCursorVisibility() } override func mouseExited(with event: NSEvent) { @@ -127,6 +128,7 @@ class EventsView: NSView { cocoa_put_key_with_modifiers(SWIFT_KEY_MOUSE_LEAVE, 0) } cocoaCB.titleBar?.hide() + cocoaCB.setCursorVisiblility(true) } override func mouseMoved(with event: NSEvent) { diff --git a/video/out/cocoa-cb/window.swift b/video/out/cocoa-cb/window.swift index 2dbac9751d..ce7947cb90 100644 --- a/video/out/cocoa-cb/window.swift +++ b/video/out/cocoa-cb/window.swift @@ -183,7 +183,7 @@ class Window: NSWindow, NSWindowDelegate { func windowDidEnterFullScreen(_ notification: Notification) { isInFullscreen = true cocoaCB.mpv?.setConfigProperty(fullscreen: isInFullscreen) - cocoaCB.updateCusorVisibility() + cocoaCB.updateCursorVisibility() endAnimation(frame) cocoaCB.titleBar?.show() } @@ -517,12 +517,13 @@ class Window: NSWindow, NSWindowDelegate { } func windowDidBecomeKey(_ notification: Notification) { - cocoaCB.updateCusorVisibility() + cocoaCB.updateCursorVisibility() } func windowDidChangeOcclusionState(_ notification: Notification) { if occlusionState.contains(.visible) { cocoaCB.layer?.update(force: true) + cocoaCB.updateCursorVisibility() } } diff --git a/video/out/cocoa_cb_common.swift b/video/out/cocoa_cb_common.swift index 64cd013fae..a8be13c41f 100644 --- a/video/out/cocoa_cb_common.swift +++ b/video/out/cocoa_cb_common.swift @@ -28,7 +28,6 @@ class CocoaCB: NSObject { var layer: VideoLayer? var link: CVDisplayLink? - var cursorHidden: Bool = false var cursorVisibilityWanted: Bool = true @objc var isShuttingDown: Bool = false @@ -267,19 +266,12 @@ class CocoaCB: NSObject { &displaySleepAssertion) } - func updateCusorVisibility() { + func updateCursorVisibility() { setCursorVisiblility(cursorVisibilityWanted) } func setCursorVisiblility(_ visible: Bool) { - let visibility = visible ? true : !(view?.canHideCursor() ?? false) - if visibility && cursorHidden { - NSCursor.unhide() - cursorHidden = false; - } else if !visibility && !cursorHidden { - NSCursor.hide() - cursorHidden = true - } + NSCursor.setHiddenUntilMouseMoves(!visible && (view?.canHideCursor() ?? false)) } func updateICCProfile() {