diff --git a/core/mplayer.c b/core/mplayer.c index 0281270d5f..c0415093e2 100644 --- a/core/mplayer.c +++ b/core/mplayer.c @@ -3969,7 +3969,7 @@ static void init_input(struct MPContext *mpctx) stream_set_interrupt_callback(mp_input_check_interrupt, mpctx->input); #ifdef CONFIG_COCOA - cocoa_set_state(mpctx->input, mpctx->key_fifo); + cocoa_set_input_context(mpctx->input); #endif } diff --git a/osdep/macosx_application.h b/osdep/macosx_application.h index b0f7944512..13a63bc50f 100644 --- a/osdep/macosx_application.h +++ b/osdep/macosx_application.h @@ -49,7 +49,7 @@ void cocoa_run_runloop(void); void cocoa_stop_runloop(void); void cocoa_post_fake_event(void); -void cocoa_set_state(struct input_ctx *input_context, struct mp_fifo *key_fifo); +void cocoa_set_input_context(struct input_ctx *input_context); void macosx_finder_args_preinit(int *argc, char ***argv); 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)