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.
This commit is contained in:
Akemi 2017-02-15 20:41:16 +01:00
parent b304d89e36
commit 05eb42f6e1
1 changed files with 10 additions and 4 deletions

View File

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