feat: auto-hide the mouse cursor while idle in fullscreen - #954
Open
Ortes wants to merge 4 commits into
Open
Conversation
Toggle the root MouseRegion's cursor to SystemMouseCursors.none once the controls auto-hide in fullscreen, and restore it on mouse movement (the existing onHover handler already reveals the controls). Works on web and desktop, no-op on pointerless devices. Gated by the new ChewieController.hideCursorInFullScreen option (default true).
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #954 +/- ##
==========================================
+ Coverage 43.82% 48.51% +4.69%
==========================================
Files 21 21
Lines 1602 1618 +16
==========================================
+ Hits 702 785 +83
+ Misses 900 833 -67 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
In fullscreen the mouse cursor currently stays visible forever. This makes it auto-hide together with the controls once the player goes idle, and reappear as soon as the mouse moves — the behaviour of most video players (YouTube, VLC, …).
How
MouseRegionwhoseonHoverreveals the controls. We simply set that region'scursortoSystemMouseCursors.nonewhilehideCursorInFullScreen && isFullScreen && hideStuff, andMouseCursor.deferotherwise (so inner per-widget cursors still win when the controls are visible).MaterialDesktopControls,MaterialControls,CupertinoControls), matching the cross-file precedent ofpauseOnBackgroundTap.SystemMouseCursors.nonemaps to CSScursor: noneon web and works on desktop too; it is a no-op on pointerless devices.ChewieController.hideCursorInFullScreenoption (defaulttrue), wired throughcopyWith.Tests
test/hide_cursor_test.dartcovers the option default/copyWithand that the cursor is never hidden while not in fullscreen even when the controls are idle (the gate).dart format,flutter analyze lib test, and the fullflutter testsuite are clean.