mirror of
https://github.com/mpv-player/mpv.git
synced 2026-10-24 12:10:18 +08:00
cocoa: ignore first file open events from command line
similar to some of the code deleted in 685b8b7a but simpler
This commit is contained in:
@@ -61,6 +61,7 @@ Application *mpv_shared_app(void)
|
||||
|
||||
@implementation Application
|
||||
@synthesize menuItems = _menu_items;
|
||||
@synthesize openCount = _open_count;
|
||||
|
||||
- (void)sendEvent:(NSEvent *)event
|
||||
{
|
||||
@@ -231,6 +232,10 @@ Application *mpv_shared_app(void)
|
||||
|
||||
- (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames
|
||||
{
|
||||
if (mpv_shared_app().openCount > 0) {
|
||||
mpv_shared_app().openCount--;
|
||||
return;
|
||||
}
|
||||
SEL cmpsel = @selector(localizedStandardCompare:);
|
||||
NSArray *files = [filenames sortedArrayUsingSelector:cmpsel];
|
||||
[_eventsResponder handleFilesArray:files];
|
||||
@@ -371,6 +376,9 @@ int cocoa_main(mpv_main_fn mpv_main, int argc, char *argv[])
|
||||
macosx_redirect_output_to_logfile("mpv");
|
||||
init_cocoa_application(true);
|
||||
} else {
|
||||
for (int i = 1; i < argc; i++)
|
||||
if (argv[i][0] != '-')
|
||||
mpv_shared_app().openCount++;
|
||||
init_cocoa_application(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
@property(nonatomic, retain) NSMutableDictionary *menuItems;
|
||||
@property(nonatomic, retain) NSArray *files;
|
||||
@property(nonatomic, assign) size_t openCount;
|
||||
@end
|
||||
|
||||
Application *mpv_shared_app(void);
|
||||
|
||||
Reference in New Issue
Block a user