summaryrefslogtreecommitdiffstats
path: root/osdep
diff options
context:
space:
mode:
authorAkemi <der.richter@gmx.de>2017-02-15 20:41:16 +0100
committerAkemi <der.richter@gmx.de>2017-02-16 16:36:34 +0100
commit05eb42f6e159d5fc2c485f766cfabbc1429b6a4d (patch)
tree521e4a1cdcd165a83b9b1697a367d4e2d2835258 /osdep
parentb304d89e36711d7e10ae04b29fa8b3f8aa3f0591 (diff)
downloadmpv-05eb42f6e159d5fc2c485f766cfabbc1429b6a4d.tar.bz2
mpv-05eb42f6e159d5fc2c485f766cfabbc1429b6a4d.tar.xz
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.
Diffstat (limited to 'osdep')
-rw-r--r--osdep/macosx_application.m14
1 files changed, 10 insertions, 4 deletions
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];
}