Re-hide MacPass if it was shown only for autotype candidate selection (fixes #964)

This commit is contained in:
Michael Starke
2020-01-13 13:46:24 +01:00
parent e6bb9ad191
commit 626bb35f80
3 changed files with 24 additions and 11 deletions

View File

@@ -22,13 +22,17 @@
#import <Cocoa/Cocoa.h>
NS_ASSUME_NONNULL_BEGIN
@interface MPAutotypeCandidateSelectionViewController : NSViewController
@property (copy) NSArray *candidates;
@property (copy) NSString *windowTitle;
@property (nonatomic, copy, nullable) void (^completionHandler)(void);
- (IBAction)selectAutotypeContext:(id)sender;
- (IBAction)cancelSelection:(id)sender;
@end
NS_ASSUME_NONNULL_END

View File

@@ -80,6 +80,9 @@
- (void)selectAutotypeContext:(id)sender {
NSInteger selectedRow = self.contextTableView.selectedRow;
if(selectedRow >= 0 && selectedRow < self.candidates.count) {
if(self.completionHandler) {
self.completionHandler();
}
[MPAutotypeDaemon.defaultDaemon selectAutotypeCandiate:self.candidates[selectedRow]];
}
else {
@@ -88,7 +91,10 @@
}
- (void)cancelSelection:(id)sender {
[[MPAutotypeDaemon defaultDaemon] cancelAutotypeCandidateSelection];
if(self.completionHandler) {
self.completionHandler();
}
[MPAutotypeDaemon.defaultDaemon cancelAutotypeCandidateSelection];
}

View File

@@ -258,13 +258,11 @@ static MPAutotypeDaemon *_sharedInstance;
[autotypeCandidates addObjectsFromArray:contexts];
}
}
NSUInteger candidates = autotypeCandidates.count;
if(candidates == 0) {
return nil;
}
if(candidates == 1 ) {
if(autotypeCandidates.count <= 1) {
return autotypeCandidates.lastObject;
}
[self _presentCandiadates:autotypeCandidates forWindowTitle:windowTitle];
return nil; // Nothing to do, we get called back by the window
}
@@ -340,9 +338,9 @@ static MPAutotypeDaemon *_sharedInstance;
if(zIndex < minZIndex) {
minZIndex = zIndex;
infoDict = @{
kMPWindowTitleKey: windowTitle,
kMPProcessIdentifierKey : processId
};
kMPWindowTitleKey: windowTitle,
kMPProcessIdentifierKey : processId
};
}
}
}
@@ -363,6 +361,11 @@ static MPAutotypeDaemon *_sharedInstance;
MPAutotypeCandidateSelectionViewController *vc = [[MPAutotypeCandidateSelectionViewController alloc] init];
vc.candidates = candidates;
vc.windowTitle = windowTitle;
if(NSRunningApplication.currentApplication.isHidden) {
vc.completionHandler = ^{
[NSRunningApplication.currentApplication hide];
};
}
self.matchSelectionWindow.collectionBehavior |= (NSWindowCollectionBehaviorFullScreenAuxiliary |
NSWindowCollectionBehaviorMoveToActiveSpace |
NSWindowCollectionBehaviorTransient );