summaryrefslogtreecommitdiffstats
path: root/osdep
diff options
context:
space:
mode:
authorder richter <der.richter@gmx.de>2024-03-26 21:30:46 +0100
committerder richter <der.richter@gmx.de>2024-03-29 14:20:40 +0100
commit6debb22a0cde5231ebed6df5013d426991f87a27 (patch)
treea89e6bae73b6d8048daffddb0c51b43745c8400e /osdep
parent1bc680d32a1ac1de6b1a47361f18a3733b9ffbda (diff)
downloadmpv-6debb22a0cde5231ebed6df5013d426991f87a27.tar.bz2
mpv-6debb22a0cde5231ebed6df5013d426991f87a27.tar.xz
mac/apphub: move cocoa-cb into AppHub
Diffstat (limited to 'osdep')
-rw-r--r--osdep/mac/app_hub.swift11
-rw-r--r--osdep/mac/application.m11
-rw-r--r--osdep/mac/application_objc.h8
3 files changed, 9 insertions, 21 deletions
diff --git a/osdep/mac/app_hub.swift b/osdep/mac/app_hub.swift
index 60854a3b91..fe5160cf51 100644
--- a/osdep/mac/app_hub.swift
+++ b/osdep/mac/app_hub.swift
@@ -28,6 +28,9 @@ class AppHub: NSObject {
#if HAVE_MACOS_TOUCHBAR
@objc var touchBar: TouchBar?
#endif
+#if HAVE_MACOS_COCOA_CB
+ var cocoaCb: CocoaCB?
+#endif
var isApplication: Bool { get { NSApp is Application } }
@@ -57,8 +60,12 @@ class AppHub: NSObject {
}
@objc func initCocoaCb() {
- guard let app = NSApp as? Application, let mpv = mpv else { return }
- DispatchQueue.main.sync { app.initCocoaCb(mpv) }
+#if HAVE_MACOS_COCOA_CB
+ if !isApplication { return }
+ DispatchQueue.main.sync {
+ self.cocoaCb = self.cocoaCb ?? CocoaCB(mpv_create_client(mpv, "cocoacb"))
+ }
+#endif
}
@objc func startRemote() {
diff --git a/osdep/mac/application.m b/osdep/mac/application.m
index 0f506b91ce..753b9bcfa4 100644
--- a/osdep/mac/application.m
+++ b/osdep/mac/application.m
@@ -59,7 +59,6 @@ static void terminate_cocoa_application(void)
@implementation Application
@synthesize openCount = _open_count;
-@synthesize cocoaCB = _cocoa_cb;
- (void)sendEvent:(NSEvent *)event
{
@@ -100,16 +99,6 @@ static void terminate_cocoa_application(void)
}
#endif
-- (void)initCocoaCb:(struct mpv_handle *)ctx
-{
-#if HAVE_MACOS_COCOA_CB
- if (!_cocoa_cb) {
- mpv_handle *mpv = mpv_create_client(ctx, "cocoacb");
- [NSApp setCocoaCB:[[CocoaCB alloc] init:mpv]];
- }
-#endif
-}
-
- (void)applicationWillFinishLaunching:(NSNotification *)notification
{
NSAppleEventManager *em = [NSAppleEventManager sharedAppleEventManager];
diff --git a/osdep/mac/application_objc.h b/osdep/mac/application_objc.h
index 4864e0d62b..b27d7d234f 100644
--- a/osdep/mac/application_objc.h
+++ b/osdep/mac/application_objc.h
@@ -18,14 +18,6 @@
#import <Cocoa/Cocoa.h>
#include "osdep/mac/application.h"
-@class CocoaCB;
-struct mpv_event;
-struct mpv_handle;
-
@interface Application : NSApplication
-
-- (void)initCocoaCb:(struct mpv_handle *)ctx;
-
@property(nonatomic, assign) size_t openCount;
-@property(nonatomic, retain) CocoaCB *cocoaCB;
@end