1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-10-26 17:17:58 +00:00

Don't hide mouse cursor if over an interesting subview.

This commit is contained in:
Thomas Harte
2025-02-21 11:43:47 -05:00
parent 50acbb70da
commit 1684d88a3b

View File

@@ -286,8 +286,12 @@ static CVReturn DisplayLinkCallback(__unused CVDisplayLinkRef displayLink, const
[self recalculateSubviewTrackingAreas]; [self recalculateSubviewTrackingAreas];
} }
- (void)scheduleMouseHideAfter:(NSTimeInterval)interval { - (void)cancelMouseHide {
[_mouseHideTimer invalidate]; [_mouseHideTimer invalidate];
}
- (void)scheduleMouseHideAfter:(NSTimeInterval)interval {
[self cancelMouseHide];
_mouseHideTimer = [NSTimer scheduledTimerWithTimeInterval:interval repeats:NO block:^(__unused NSTimer * _Nonnull timer) { _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 // 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]; [self scheduleMouseHideAfter:standardMouseHideInterval];
} }
if(event.trackingArea == _subviewTrackingArea && !_mouseIsCaptured) { if(event.trackingArea == _subviewTrackingArea && !_mouseIsCaptured) {
[self cancelMouseHide];
[self.responderDelegate scanTargetViewDidMouseoverSubviews:self]; [self.responderDelegate scanTargetViewDidMouseoverSubviews:self];
} }
} }
@@ -332,14 +337,14 @@ static CVReturn DisplayLinkCallback(__unused CVDisplayLinkRef displayLink, const
- (void)applyMouseMotion:(NSEvent *)event { - (void)applyMouseMotion:(NSEvent *)event {
if(!_mouseIsCaptured) { if(!_mouseIsCaptured) {
// Mouse capture is off, so don't play games with the cursor, just schedule it to // Mouse capture is off, so don't play games with the cursor, just schedule it to
// hide in the near future. // hide in the near future unless over an interesting subview.
[self scheduleMouseHideAfter:standardMouseHideInterval];
if( if(
_subviewTrackingArea && _subviewTrackingArea &&
NSPointInRect([self convertPoint:event.locationInWindow fromView:nil], _subviewTrackingArea.rect) NSPointInRect([self convertPoint:event.locationInWindow fromView:nil], _subviewTrackingArea.rect)
) { ) {
[self.responderDelegate scanTargetViewDidMouseoverSubviews:self]; [self.responderDelegate scanTargetViewDidMouseoverSubviews:self];
} else {
[self scheduleMouseHideAfter:standardMouseHideInterval];
} }
} else { } else {
// Mouse capture is on, so move the cursor back to the middle of the window, and // Mouse capture is on, so move the cursor back to the middle of the window, and