changeset 31758:0577595394f8

Make the Quit menu entry work.
author reimar
date Sun, 25 Jul 2010 17:06:41 +0000
parents 83423e6b288e
children a320b893f660
files libvo/vo_corevideo.m
diffstat 1 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libvo/vo_corevideo.m	Sun Jul 25 17:00:04 2010 +0000
+++ b/libvo/vo_corevideo.m	Sun Jul 25 17:06:41 2010 +0000
@@ -401,6 +401,15 @@
 			mpGLView = [[MPlayerOpenGLView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) pixelFormat:[MPlayerOpenGLView defaultPixelFormat]];
 			[mpGLView autorelease];
 		}
+		// Install an event handler so the Quit menu entry works
+		// The proper way using NSApp setDelegate: and
+		// applicationShouldTerminate: does not work,
+		// probably NSApplication never installs its handler.
+		[[NSAppleEventManager sharedAppleEventManager]
+			setEventHandler:mpGLView
+			andSelector:@selector(handleQuitEvent:withReplyEvent:)
+			forEventClass:kCoreEventClass
+			andEventID:kAEQuitApplication];
 
 		[mpGLView display];
 		[mpGLView preinit];
@@ -1040,4 +1049,9 @@
 	// KEY_CLOSE_WIN handler is disabled
 	return NO;
 }
+
+- (void)handleQuitEvent:(NSAppleEventDescriptor*)e withReplyEvent:(NSAppleEventDescriptor*)r
+{
+	mplayer_put_key(KEY_CLOSE_WIN);
+}
 @end