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