From 29f5429223fcb0a13a580195ac1c91d4fa522be3 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Thu, 23 May 2013 09:44:56 +0200 Subject: macosx_application: implement "Quit & remember position" Add a menu item to quit and save the current playback position using the code added with commit ce9a854. Fixes #85 --- osdep/macosx_application.m | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'osdep/macosx_application.m') diff --git a/osdep/macosx_application.m b/osdep/macosx_application.m index 7242403bc5..77c7779d49 100644 --- a/osdep/macosx_application.m +++ b/osdep/macosx_application.m @@ -86,6 +86,9 @@ static pthread_t playback_thread_id; action:@selector(hide:) keyEquivalent: @"h"]; [self menuItemWithParent:menu title:@"Quit mpv" action:@selector(stopPlayback) keyEquivalent: @"q"]; + [self menuItemWithParent:menu title:@"Quit mpv & remember position" + action:@selector(stopPlaybackAndRememberPosition) + keyEquivalent: @"Q"]; return [menu autorelease]; } @@ -120,13 +123,25 @@ static pthread_t playback_thread_id; - (void)stopPlayback { - if (app.keyFIFO) { - mplayer_put_key(app.keyFIFO, MP_KEY_CLOSE_WIN); + [self stop:"quit"]; +} + +- (void)stopPlaybackAndRememberPosition +{ + [self stop:"quit_watch_later"]; +} + +- (void)stop:(char *)cmd +{ + if (self.inputContext) { + mp_cmd_t *cmdt = mp_input_parse_cmd(bstr0(cmd), ""); + mp_input_queue_cmd(self.inputContext, cmdt); } else { terminate_cocoa_application(); } } + - (void)registerMenuItem:(NSMenuItem*)menuItem forKey:(MPMenuKey)key { [self.menuItems setObject:menuItem forKey:[NSNumber numberWithInt:key]]; @@ -295,12 +310,10 @@ void cocoa_stop_runloop(void) cocoa_post_fake_event(); } -void cocoa_set_state(struct input_ctx *input_context, - struct mp_fifo *key_fifo) +void cocoa_set_input_context(struct input_ctx *input_context) { [NSApp setDelegate:app]; - app.inputContext = input_context; - app.keyFIFO = key_fifo; + app.inputContext = input_context; } void cocoa_post_fake_event(void) -- cgit v1.2.3