Merge pull request #25 from trunkmaster/master

Handle `-autolaunch YES` application argument (GUI part)
This commit is contained in:
Fred Kiefer 2019-04-03 08:38:41 +02:00 committed by GitHub
commit 7fa72c547e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 0 deletions

View file

@ -1,3 +1,14 @@
2019-04-03 Sergii Stoian <stoyan255@ukr.net>
* Source/NSApplication.m (activateIgnoringOtherApps:):
Optimize `-autolaunch YES` checking code.
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

@ -753,6 +753,8 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
*/
@implementation NSApplication
static BOOL _isAutolaunchChecked = NO;
/*
* Class methods
*/
@ -1259,6 +1261,21 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
*/
- (void) activateIgnoringOtherApps: (BOOL)flag
{
if (_isAutolaunchChecked == NO)
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *autolaunch = [defaults objectForKey: @"autolaunch"];
_isAutolaunchChecked = YES;
/* Application was executed with an argument '-autolaunch YES'.
Do not activate application on first call. */
if (autolaunch && [autolaunch isEqualToString: @"YES"])
{
return;
}
}
// TODO: Currently the flag is ignored
if (_app_is_active == NO)
{