Added delay settings key

This commit is contained in:
Michael Starke
2019-06-17 11:23:39 +02:00
parent 4abdff79a5
commit 3ef2c01859
3 changed files with 13 additions and 0 deletions

View File

@@ -318,9 +318,20 @@ static MPAutotypeDaemon *_sharedInstance;
/* TODO - we might be able to get a notification to check if the app actually was activated instead of guessing a waiting time */
usleep(1 * NSEC_PER_MSEC);
}
useconds_t delay = 0;
if(nil != [NSUserDefaults.standardUserDefaults objectForKey:kMPSettingsKeyGlobalAutotypeDelay]) {
/* limit the delay to 1000 ms */
delay = (useconds_t)MIN([NSUserDefaults.standardUserDefaults integerForKey:kMPSettingsKeyGlobalAutotypeDelay], 1000);
}
for(MPAutotypeCommand *command in [MPAutotypeCommand commandsForContext:context]) {
/* dispatch commands to main thread since most of them translate key events which is disallowed on background thread */
dispatch_async(dispatch_get_main_queue(), ^{
if(delay > 0) {
usleep(delay * NSEC_PER_MSEC);
}
[command execute];
});
}

View File

@@ -69,6 +69,7 @@ APPKIT_EXTERN NSString *const kMPSettingsKeyAutotypeMatchURL; //
APPKIT_EXTERN NSString *const kMPSettingsKeyAutotypeMatchHost; // Autotype lookup includes host part of entry URL
APPKIT_EXTERN NSString *const kMPSettingsKeyAutotypeMatchTags; // Autotype lookup includes tags for entries
APPKIT_EXTERN NSString *const kMPSettingsKeyAutotypeHideAccessibiltyWarning; // Do not show an alert, when MacPass has no support for Autotype
APPKIT_EXTERN NSString *const kMPSettingsKeyGlobalAutotypeDelay; // A global delay in milliseconds for every autotype command to allow for workarounds for broken autotype on some applications (e.g. Steam)
/* Search */
APPKIT_EXTERN NSString *const kMPSettingsKeyEntrySearchFilterContext;

View File

@@ -60,6 +60,7 @@ NSString *const kMPSettingsKeyAutotypeMatchURL = @"Autoty
NSString *const kMPSettingsKeyAutotypeMatchHost = @"AutotypeMatchHost";
NSString *const kMPSettingsKeyAutotypeMatchTags = @"AutotypeMatchTags";
NSString *const kMPSettingsKeyAutotypeHideAccessibiltyWarning = @"AutotypeHideAccessibiltyWarning";
NSString *const kMPSettingsKeyGlobalAutotypeDelay = @"GlobalAutotypeDelay";
NSString *const kMPSettingsKeyEntrySearchFilterContext = @"EntrySearchFilterContext";