From 1684d88a3b51b8d3e58f65596300c1d89cfacdcf Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 21 Feb 2025 11:43:47 -0500 Subject: [PATCH] Don't hide mouse cursor if over an interesting subview. --- .../Mac/Clock Signal/Views/CSScanTargetView.m | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/OSBindings/Mac/Clock Signal/Views/CSScanTargetView.m b/OSBindings/Mac/Clock Signal/Views/CSScanTargetView.m index 1f9523f76..068b6f87c 100644 --- a/OSBindings/Mac/Clock Signal/Views/CSScanTargetView.m +++ b/OSBindings/Mac/Clock Signal/Views/CSScanTargetView.m @@ -286,8 +286,12 @@ static CVReturn DisplayLinkCallback(__unused CVDisplayLinkRef displayLink, const [self recalculateSubviewTrackingAreas]; } -- (void)scheduleMouseHideAfter:(NSTimeInterval)interval { +- (void)cancelMouseHide { [_mouseHideTimer invalidate]; +} + +- (void)scheduleMouseHideAfter:(NSTimeInterval)interval { + [self cancelMouseHide]; _mouseHideTimer = [NSTimer scheduledTimerWithTimeInterval:interval repeats:NO block:^(__unused NSTimer * _Nonnull timer) { // Don't actually hide the mouse if this is a mouse-capture machine; that makes @@ -306,6 +310,7 @@ static CVReturn DisplayLinkCallback(__unused CVDisplayLinkRef displayLink, const [self scheduleMouseHideAfter:standardMouseHideInterval]; } if(event.trackingArea == _subviewTrackingArea && !_mouseIsCaptured) { + [self cancelMouseHide]; [self.responderDelegate scanTargetViewDidMouseoverSubviews:self]; } } @@ -332,14 +337,14 @@ static CVReturn DisplayLinkCallback(__unused CVDisplayLinkRef displayLink, const - (void)applyMouseMotion:(NSEvent *)event { if(!_mouseIsCaptured) { // Mouse capture is off, so don't play games with the cursor, just schedule it to - // hide in the near future. - [self scheduleMouseHideAfter:standardMouseHideInterval]; - + // hide in the near future unless over an interesting subview. if( _subviewTrackingArea && NSPointInRect([self convertPoint:event.locationInWindow fromView:nil], _subviewTrackingArea.rect) ) { [self.responderDelegate scanTargetViewDidMouseoverSubviews:self]; + } else { + [self scheduleMouseHideAfter:standardMouseHideInterval]; } } else { // Mouse capture is on, so move the cursor back to the middle of the window, and