mirror of
https://github.com/TomHarte/CLK.git
synced 2025-08-15 14:27:29 +00:00
Adds a 0.1 second pause before exit-related menu fadeout.
This is because the system may post a quick succession of exits and enters if the view hierarchy changes.
This commit is contained in:
@@ -14,6 +14,9 @@
|
|||||||
|
|
||||||
#include <stdatomic.h>
|
#include <stdatomic.h>
|
||||||
|
|
||||||
|
static const NSTimeInterval standardMouseHideInterval = 3.0;
|
||||||
|
static const NSTimeInterval quickMouseHideInterval = 0.1;
|
||||||
|
|
||||||
@interface CSScanTargetView () <NSDraggingDestination, CSApplicationEventDelegate>
|
@interface CSScanTargetView () <NSDraggingDestination, CSApplicationEventDelegate>
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@@ -237,11 +240,11 @@ static CVReturn DisplayLinkCallback(__unused CVDisplayLinkRef displayLink, const
|
|||||||
[self addTrackingArea:_mouseTrackingArea];
|
[self addTrackingArea:_mouseTrackingArea];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)scheduleMouseHide {
|
- (void)scheduleMouseHideAfter:(NSTimeInterval)interval {
|
||||||
if(!self.shouldCaptureMouse) {
|
if(!self.shouldCaptureMouse) {
|
||||||
[_mouseHideTimer invalidate];
|
[_mouseHideTimer invalidate];
|
||||||
|
|
||||||
_mouseHideTimer = [NSTimer scheduledTimerWithTimeInterval:3.0 repeats:NO block:^(__unused NSTimer * _Nonnull timer) {
|
_mouseHideTimer = [NSTimer scheduledTimerWithTimeInterval:interval repeats:NO block:^(__unused NSTimer * _Nonnull timer) {
|
||||||
[NSCursor setHiddenUntilMouseMoves:YES];
|
[NSCursor setHiddenUntilMouseMoves:YES];
|
||||||
[self.responderDelegate scanTargetViewWillHideOSMouseCursor:self];
|
[self.responderDelegate scanTargetViewWillHideOSMouseCursor:self];
|
||||||
}];
|
}];
|
||||||
@@ -249,16 +252,17 @@ static CVReturn DisplayLinkCallback(__unused CVDisplayLinkRef displayLink, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)mouseEntered:(NSEvent *)event {
|
- (void)mouseEntered:(NSEvent *)event {
|
||||||
[self.responderDelegate scanTargetViewDidShowOSMouseCursor:self];
|
|
||||||
[super mouseEntered:event];
|
[super mouseEntered:event];
|
||||||
[self scheduleMouseHide];
|
|
||||||
|
[self.responderDelegate scanTargetViewDidShowOSMouseCursor:self];
|
||||||
|
[self scheduleMouseHideAfter:standardMouseHideInterval];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)mouseExited:(NSEvent *)event {
|
- (void)mouseExited:(NSEvent *)event {
|
||||||
[super mouseExited:event];
|
[super mouseExited:event];
|
||||||
[_mouseHideTimer invalidate];
|
|
||||||
_mouseHideTimer = nil;
|
// Schedule a really short mouse-hiding interval.
|
||||||
[self.responderDelegate scanTargetViewWillHideOSMouseCursor:self];
|
[self scheduleMouseHideAfter:quickMouseHideInterval];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)releaseMouse {
|
- (void)releaseMouse {
|
||||||
@@ -278,7 +282,7 @@ static CVReturn DisplayLinkCallback(__unused CVDisplayLinkRef displayLink, const
|
|||||||
if(!self.shouldCaptureMouse) {
|
if(!self.shouldCaptureMouse) {
|
||||||
// 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.
|
||||||
[self scheduleMouseHide];
|
[self scheduleMouseHideAfter:standardMouseHideInterval];
|
||||||
[self.responderDelegate scanTargetViewDidShowOSMouseCursor:self];
|
[self.responderDelegate scanTargetViewDidShowOSMouseCursor:self];
|
||||||
} else {
|
} else {
|
||||||
if(_mouseIsCaptured) {
|
if(_mouseIsCaptured) {
|
||||||
|
Reference in New Issue
Block a user