mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-21 17:49:34 +00:00
Re-hide MacPass if it was shown only for autotype candidate selection (fixes #964)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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 );
|
||||
|
||||
Reference in New Issue
Block a user