mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 13:10:59 +00:00
Optimize -autolaunch YES
checking code.
This commit is contained in:
parent
215eb89e27
commit
f8c955acf4
2 changed files with 19 additions and 14 deletions
|
@ -1,3 +1,8 @@
|
|||
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:
|
||||
|
|
|
@ -753,6 +753,8 @@ static NSSize scaledIconSizeForSize(NSSize imageSize)
|
|||
*/
|
||||
@implementation NSApplication
|
||||
|
||||
static BOOL _isAutolaunchChecked = NO;
|
||||
|
||||
/*
|
||||
* Class methods
|
||||
*/
|
||||
|
@ -1259,21 +1261,19 @@ 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:`. */
|
||||
if (autolaunch && [autolaunch isEqualToString: @"YES"])
|
||||
if (_isAutolaunchChecked == NO)
|
||||
{
|
||||
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;
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue