1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-25 16:31:42 +00:00

Slightly adjusts mouse hiding semantics.

This allows the Macintosh and ST to fade out volume and settings even without having captured the mouse.
This commit is contained in:
Thomas Harte 2021-07-16 17:21:25 -04:00
parent a0799e14cc
commit c226be612f
3 changed files with 28 additions and 28 deletions

View File

@ -781,7 +781,7 @@ class MachineDocument:
optionsFader.animateIn()
}
internal func scanTargetViewWillHideOSMouseCursor(_ view: CSScanTargetView) {
internal func scanTargetViewWouldHideOSMouseCursor(_ view: CSScanTargetView) {
// The OS mouse cursor will be hidden, so hide the volume controls.
optionsFader.animateOut(delay: 0.0)
}

View File

@ -80,10 +80,12 @@
- (void)scanTargetViewDidShowOSMouseCursor:(nonnull CSScanTargetView *)view;
/*!
Announces that the OS mouse cursor will now be hidden.
Announces that the OS mouse cursor would now be hidden; 'would' means that if this is not
a mouse capture-enabled view then it will be hidden, but otherwise it might or might not be
as per whatever is user-friendly.
@param view The view making the announcement.
*/
- (void)scanTargetViewWillHideOSMouseCursor:(nonnull CSScanTargetView *)view;
- (void)scanTargetViewWouldHideOSMouseCursor:(nonnull CSScanTargetView *)view;
/*!
Announces receipt of a file by drag and drop to the delegate.

View File

@ -241,14 +241,16 @@ static CVReturn DisplayLinkCallback(__unused CVDisplayLinkRef displayLink, const
}
- (void)scheduleMouseHideAfter:(NSTimeInterval)interval {
if(!self.shouldCaptureMouse) {
[_mouseHideTimer invalidate];
_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
// it fairly confusing as to current application state.
if(!self.shouldCaptureMouse) {
[NSCursor setHiddenUntilMouseMoves:YES];
[self.responderDelegate scanTargetViewWillHideOSMouseCursor:self];
}];
}
[self.responderDelegate scanTargetViewWouldHideOSMouseCursor:self];
}];
}
- (void)mouseEntered:(NSEvent *)event {
@ -279,13 +281,12 @@ static CVReturn DisplayLinkCallback(__unused CVDisplayLinkRef displayLink, const
#pragma mark - Mouse motion
- (void)applyMouseMotion:(NSEvent *)event {
if(!self.shouldCaptureMouse) {
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];
[self.responderDelegate scanTargetViewDidShowOSMouseCursor:self];
} else {
if(_mouseIsCaptured) {
// Mouse capture is on, so move the cursor back to the middle of the window, and
// forward the deltas to the listener.
//
@ -300,9 +301,6 @@ static CVReturn DisplayLinkCallback(__unused CVDisplayLinkRef displayLink, const
));
[self.responderDelegate mouseMoved:event];
} else {
[self.responderDelegate scanTargetViewDidShowOSMouseCursor:self];
}
}
}
@ -334,7 +332,7 @@ static CVReturn DisplayLinkCallback(__unused CVDisplayLinkRef displayLink, const
_mouseIsCaptured = YES;
[NSCursor hide];
CGAssociateMouseAndMouseCursorPosition(false);
[self.responderDelegate scanTargetViewWillHideOSMouseCursor:self];
[self.responderDelegate scanTargetViewWouldHideOSMouseCursor:self];
[self.responderDelegate scanTargetViewDidCaptureMouse:self];
if(self.shouldUsurpCommand) {
((CSApplication *)[NSApplication sharedApplication]).eventDelegate = self;