Skip to content
Snippets Groups Projects
Commit 02e75fef authored by George Nachman's avatar George Nachman
Browse files

Fix a bug where hotkey windows appearing in a different display than the...

Fix a bug where hotkey windows appearing in a different display than the currently key window (in another app) would not receive focus and would forget which app was previously active. Issue 6353

The two key changes are
1. Add a method to activate the app with a completion block
2. Don't throw away the existing previous state when a non hotkey window becomes key during a rollin. The logic already existed for a rollout.
Here's what would happen:

rollInAnimated
  [NSApp activateIgnoringOtherApps:YES]
  rollInAnimatingInDirection:
(if there's no animation, the rollin finishes immediately)
App becomes active
A non-hotkey window becomes key

Now, here's what happens:

rollInAnimated
  [NSApp activateIgnoringOtherApps:YES]
App becomes active
A non-hotkey window becomes key, but it's ignored because there's a roll-in in progress
rollInAnimatingInDirection:
(if there's no animation, the rollin finishes immediately)
parent 8dca4b36
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -57,4 +57,6 @@
// Like orderedWindows, but only iTermWindow/iTermPanel objects wrapped in iTermScriptingWindow*s are returned.
- (NSArray<iTermScriptingWindow *> *)orderedScriptingWindows;
 
- (void)activateAppWithCompletion:(void (^)(void))completion;
@end
Loading
Loading
@@ -408,5 +408,26 @@
return [panels arrayByAddingObjectsFromArray:[self orderedWindows]];
}
 
- (void)activateAppWithCompletion:(void (^)(void))completion {
DLog(@"Activate with completion...");
if ([self isActive]) {
DLog(@"Application already active. Run completion block synchronously");
completion();
} else {
__block id observer;
DLog(@"Register an observer");
observer = [[NSNotificationCenter defaultCenter] addObserverForName:NSApplicationDidBecomeActiveNotification
object:nil
queue:NULL
usingBlock:^(NSNotification * _Nonnull note) {
DLog(@"Application did become active. Invoke completion block");
completion();
DLog(@"Application did become active completion block finished. Removing observer.");
[[NSNotificationCenter defaultCenter] removeObserver:observer];
}];
[self activateIgnoringOtherApps:YES];
}
}
@end
 
Loading
Loading
@@ -194,7 +194,10 @@ NSString *const TERMINAL_ARRANGEMENT_PROFILE_GUID = @"Hotkey Profile GUID";
BOOL anyWindowRollingOut = [[self profileHotKeys] anyWithBlock:^BOOL(iTermProfileHotKey *anObject) {
return [anObject rollingOut];
}];
if (!anyWindowRollingOut) {
BOOL anyWindowRollingIn = [[self profileHotKeys] anyWithBlock:^BOOL(iTermProfileHotKey *anObject) {
return [anObject rollingIn];
}];
if (!anyWindowRollingOut && !anyWindowRollingIn) {
// If there is previous state:
// Going from hotkey window to non-hotkey window. Forget the previous state because
// there's no need to ever return to it now. This happens when navigating explicitly from
Loading
Loading
Loading
Loading
@@ -3,6 +3,7 @@
#import "DebugLogging.h"
#import "ITAddressBookMgr.h"
#import "iTermAdvancedSettingsModel.h"
#import "iTermApplication.h"
#import "iTermCarbonHotKeyController.h"
#import "iTermController.h"
#import "iTermPreferences.h"
Loading
Loading
@@ -371,8 +372,16 @@ static NSString *const kArrangement = @"Arrangement";
if (self.hotkeyWindowType != iTermHotkeyWindowTypeFloatingPanel) {
DLog(@"Activate iTerm2 prior to animating hotkey window in");
_activationPending = YES;
[NSApp activateIgnoringOtherApps:YES];
[[iTermApplication sharedApplication] activateAppWithCompletion:^{
[self reallyRollInAnimated:animated];
}];
} else {
[self reallyRollInAnimated:animated];
}
}
- (void)reallyRollInAnimated:(BOOL)animated {
DLog(@"Consummating roll in");
[self.windowController.window makeKeyAndOrderFront:nil];
if (animated) {
switch (self.windowController.windowType) {
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment