From 05eb42f6e159d5fc2c485f766cfabbc1429b6a4d Mon Sep 17 00:00:00 2001 From: Akemi Date: Wed, 15 Feb 2017 20:41:16 +0100 Subject: cocoa: gracefully quit from the Dock's context menu quitting mpv from the Dock's context menu leaves the shell in a bad state where you can't see your input any more and other weirdnesses. in a big refactor (afdc9c4) the method to handle this case was actually copied over but the the code to register the event itself was removed or forgotten by accident, leaving some lines of dead code. i re-added the event and slightly adjusted the function. the function was slightly changed so the head of it is consistent with our other events and it is associated with this commit and functionality in the future. --- osdep/macosx_application.m | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'osdep') diff --git a/osdep/macosx_application.m b/osdep/macosx_application.m index d31269279e..bd48398965 100644 --- a/osdep/macosx_application.m +++ b/osdep/macosx_application.m @@ -101,6 +101,8 @@ static void terminate_cocoa_application(void) NSAppleEventManager *em = [NSAppleEventManager sharedAppleEventManager]; [em removeEventHandlerForEventClass:kInternetEventClass andEventID:kAEGetURL]; + [em removeEventHandlerForEventClass:kCoreEventClass + andEventID:kAEQuitApplication]; [super dealloc]; } @@ -206,13 +208,17 @@ static void terminate_cocoa_application(void) return [item autorelease]; } -- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)theApp +- (void)applicationWillFinishLaunching:(NSNotification *)notification { - return NSTerminateNow; + NSAppleEventManager *em = [NSAppleEventManager sharedAppleEventManager]; + [em setEventHandler:self + andSelector:@selector(handleQuitEvent:withReplyEvent:) + forEventClass:kCoreEventClass + andEventID:kAEQuitApplication]; } -- (void)handleQuitEvent:(NSAppleEventDescriptor*)e - withReplyEvent:(NSAppleEventDescriptor*)r +- (void)handleQuitEvent:(NSAppleEventDescriptor *)event + withReplyEvent:(NSAppleEventDescriptor *)replyEvent { [self stopPlayback]; } -- cgit v1.2.3