Do not activate application on first run of -activateIgnoringOtherApps: if commandline argument -autolaunch YES was specified.

This commit is contained in:
Sergii Stoian 2019-04-02 19:45:14 +03:00
parent c0e4a4286c
commit 2071f6acdd
2 changed files with 24 additions and 0 deletions

View file

@ -1,3 +1,9 @@
2019-04-02 Sergii Stoian <stoyan255@gmail.com>
* Source/NSApplication.m:
(activateIgnoringOtherApps:) Do not activate application on first run
if commandline argument `-autolaunch YES` was specified.
2019-03-27 Sergii Stoian <stoyan255@gmail.com>
* Headers/AppKit/NSWindow.h:

View file

@ -1259,6 +1259,24 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
*/
- (void) activateIgnoringOtherApps: (BOOL)flag
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *autolaunch = [defaults objectForKey: @"autolaunch"];
/* Application was executed with argument '-autolaunch YES'. Set argument
* value to "NO" for future calls to `activateIgnoringOtherApps:`. */
NSLog(@"autolaunch = %@", autolaunch);
if (autolaunch && [autolaunch isEqualToString: @"YES"])
{
NSMutableDictionary *args;
args = [[defaults volatileDomainForName: NSArgumentDomain] mutableCopy];
[defaults removeVolatileDomainForName: NSArgumentDomain];
[args setObject: @"NO" forKey: @"autolaunch"];
[defaults setVolatileDomain: [NSDictionary dictionaryWithDictionary: args]
forName: NSArgumentDomain];
[args release];
return;
}
// TODO: Currently the flag is ignored
if (_app_is_active == NO)
{