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

[Focuse follows mouse] If the mouse has not moved between when the app...

[Focuse follows mouse] If the mouse has not moved between when the app resigned active and when the app becomes active again do not make the window under the cursor key.
parent e45273d1
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -306,7 +306,11 @@ static const int kDragThreshold = 3;
selector:@selector(imageDidLoad:)
name:iTermImageDidLoad
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationDidResignActive:)
name:NSApplicationDidResignActiveNotification
object:nil];
_semanticHistoryController = [[iTermSemanticHistoryController alloc] init];
_semanticHistoryController.delegate = self;
_semanticHistoryDragged = NO;
Loading
Loading
@@ -504,10 +508,12 @@ static const int kDragThreshold = 3;
}
 
- (void)refuseFirstResponderAtCurrentMouseLocation {
DLog(@"set refuse location");
_mouseLocationToRefuseFirstResponderAt = [NSEvent mouseLocation];
}
 
- (void)resetMouseLocationToRefuseFirstResponderAt {
DLog(@"reset refuse location from\n%@", [NSThread callStackSymbols]);
_mouseLocationToRefuseFirstResponderAt = NSMakePoint(DBL_MAX, DBL_MAX);
}
 
Loading
Loading
@@ -1853,7 +1859,11 @@ static const int kDragThreshold = 3;
_keyFocusStolenCount = 0;
[self setNeedsDisplay:YES];
}
[self resetMouseLocationToRefuseFirstResponderAt];
if ([NSApp isActive]) {
[self resetMouseLocationToRefuseFirstResponderAt];
} else {
DLog(@"Ignore mouse exited because app is not active");
}
[self updateUnderlinedURLs:event];
[_delegate textViewShowHoverURL:nil];
}
Loading
Loading
@@ -6150,6 +6160,10 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
}
}
 
- (void)applicationDidResignActive:(NSNotification *)notification {
[self refuseFirstResponderAtCurrentMouseLocation];
}
- (BOOL)imageIsVisible:(iTermImageInfo *)image {
if (![_drawingHelper.missingImages containsObject:image.uniqueIdentifier]) {
return NO;
Loading
Loading
Loading
Loading
@@ -201,6 +201,9 @@ static const NSTimeInterval kOneMonth = 30 * 24 * 60 * 60;
NSMutableDictionary<id, ITMNotificationRequest *> *_terminateSessionSubscriptions;
NSMutableDictionary<id, ITMNotificationRequest *> *_layoutChangeSubscriptions;
BOOL _layoutChanged;
// Location of mouse when the app became inactive.
NSPoint _savedMouseLocation;
}
 
- (instancetype)init {
Loading
Loading
@@ -866,6 +869,7 @@ static const NSTimeInterval kOneMonth = 30 * 24 * 60 * 60;
DLog(@"Application resigning active. Disabling secure input.");
[self setSecureInput:NO];
}
_savedMouseLocation = [NSEvent mouseLocation];
}
 
- (void)applicationWillHide:(NSNotification *)aNotification {
Loading
Loading
@@ -883,7 +887,9 @@ static const NSTimeInterval kOneMonth = 30 * 24 * 60 * 60;
 
// If focus follows mouse is on, find the window under the cursor and make it key. If a PTYTextView
// is under the cursor make it first responder.
if ([iTermPreferences boolForKey:kPreferenceKeyFocusFollowsMouse]) {
NSPoint mouseLocation = [NSEvent mouseLocation];
if (!NSEqualPoints(mouseLocation, _savedMouseLocation) &&
[iTermPreferences boolForKey:kPreferenceKeyFocusFollowsMouse]) {
NSRect mouseRect = {
.origin = [NSEvent mouseLocation],
.size = { 0, 0 }
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