mirror of
https://github.com/mpv-player/mpv
synced 2025-03-25 04:38:01 +00:00
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
This commit is contained in:
parent
60a7f3b8bc
commit
29f5429223
@ -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
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user