Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a problem with effects not stopping. #13

Merged
merged 3 commits into from Jan 10, 2022

Conversation

twenty3
Copy link
Collaborator

@twenty3 twenty3 commented Jan 8, 2022

With a multiple display setup, some effects would not stop when the mouse existed the notch. If a display is oriented above the notched display, the mouse cursor can move out the 'top' of the notch.

Many of our effects stop rendering when the mouse has moved outside the notch or some distance from the notch. This works because the mouse tracking area extends beyond the the bounds of the notch to the sides and below the notch. In these scenarios we generate mouseMoved() calls when the cursor leaves the notch, but is still in that tracking area. In this case though, the mouse can exit the notch at the top, which means it leaves the notch and the tracking area in one update of mouse position. This results in no mousedMoved() call, but an immediate mouseExited() call.

Effects that expect to end their rendering on a mouseMove() that happens with underNotch == false would then fail to stop. We could make sure that each effect also stops rendering on mouseExited(), but that leaves the door open to repeat this problem because it is not enforced.

This fix adds an explicit call to mouseMoved(at:underNotch:) before the call to mouseExited(at:point:). This ensures that any code in mouseMoved that switches on under the notch or not still gets a chance to run in the exit case.

Chris Parrish added 3 commits January 7, 2022 17:16
With a multiple display setup, some effects would not stop when the mouse existed the notch. If a display is oriented above the notched display, the mouse cursor can move out the 'top' of the notch.

 Many of our effects stop rendering when the mouse has moved outside the notch or some distance from the notch. This works because the mouse tracking area extends beyond the the bounds of the notch to the sides and below the notch. In these scenarios we generate `mouseMoved()` calls when the cursor leaves the notch, but is still in that tracking area. In this case though, the mouse can exit the notch at the top, which means it leaves the notch and the tracking area in one update of mouse position. This results in no `mousedMoved()` call, but an immediate `mouseExited()` call.

Effects that expect to end their rendering on a `mouseMove()` that happens with `underNotch == false` would then fail to stop. We could make sure that each effect also stops rendering on `mouseExited()`, but that leaves the door open to repeat this problem because it is not enforced.

This fix adds an explicit call to` mouseMoved(at:underNotch:)` before the call to `mouseExited(at:point:)`. This ensures that any code in mouseMoved that switches on under the notch or not still gets a chance to run in the exit case.
Copy link
Collaborator

@danielpunkass danielpunkass left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes all the cases I was previously able to reproduce. Nice!

Copy link
Owner

@chockenberry chockenberry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@chockenberry chockenberry merged commit 2572de4 into main Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants