From ea088db19db316a0d924788d968fa567d447be48 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 19 Dec 2012 11:22:58 -0800 Subject: [PATCH] Open default path from applicationDidFinishLaunching This is called after openFiles and so the default path will open be opened if other explicit files were not opened such as by dropping onto the dock icon --- native/atom_application.h | 3 ++- native/atom_application.mm | 45 ++++++++++++++++++++++++++------------ 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/native/atom_application.h b/native/atom_application.h index 32ea81361..95350506e 100644 --- a/native/atom_application.h +++ b/native/atom_application.h @@ -6,6 +6,7 @@ class AtomCefClient; @interface AtomApplication : NSApplication { NSWindowController *_backgroundWindowController; NSDictionary *_arguments; + BOOL _filesOpened; BOOL handlingSendEvent_; } @@ -22,4 +23,4 @@ class AtomCefClient; @property (nonatomic, retain) NSDictionary *arguments; -@end \ No newline at end of file +@end diff --git a/native/atom_application.mm b/native/atom_application.mm index 2a10aff0f..949f59b7d 100644 --- a/native/atom_application.mm +++ b/native/atom_application.mm @@ -174,24 +174,31 @@ # pragma mark NSApplicationDelegate +- (BOOL)shouldOpenFiles { + if ([self.arguments objectForKey:@"benchmark"]) { + return NO; + } + if ([self.arguments objectForKey:@"test"]) { + return NO; + } + return YES; +} + - (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames { - for (int i = 0; i < [filenames count]; i++) { - NSString *path = [filenames objectAtIndex:i]; - path = [[self class] standardizePathToOpen:path withArguments:self.arguments]; - [self open:path]; + if ([self shouldOpenFiles]) { + for (int i = 0; i < [filenames count]; i++) { + NSString *path = [filenames objectAtIndex:i]; + path = [[self class] standardizePathToOpen:path withArguments:self.arguments]; + [self open:path]; + } + if ([filenames count] > 0) { + _filesOpened = YES; + } } } -- (void)applicationWillFinishLaunching:(NSNotification *)notification { - _backgroundWindowController = [[AtomWindowController alloc] initInBackground]; - - if ([self.arguments objectForKey:@"benchmark"]) { - [self runBenchmarksThenExit:true]; - } - else if ([self.arguments objectForKey:@"test"]) { - [self runSpecsThenExit:true]; - } - else { +- (void)applicationDidFinishLaunching:(NSNotification *)notification { + if (!_filesOpened && [self shouldOpenFiles]) { NSString *path = [self.arguments objectForKey:@"path"]; // Just a hack to open the Atom src by default when we run from xcode @@ -203,6 +210,16 @@ } } +- (void)applicationWillFinishLaunching:(NSNotification *)notification { + _backgroundWindowController = [[AtomWindowController alloc] initInBackground]; + if ([self.arguments objectForKey:@"benchmark"]) { + [self runBenchmarksThenExit:true]; + } + else if ([self.arguments objectForKey:@"test"]) { + [self runSpecsThenExit:true]; + } +} + - (void)applicationWillTerminate:(NSNotification *)notification { for (NSWindow *window in [self windows]) { [window performClose:self];