0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 03:52:22 +02:00

mac/apphub: move cocoa-cb into AppHub

This commit is contained in:
der richter 2024-03-26 21:30:46 +01:00
parent 1bc680d32a
commit 6debb22a0c
3 changed files with 9 additions and 21 deletions

View File

@ -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() {

View File

@ -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];

View File

@ -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