fix(player): keep app-owned fullscreen when Escape leaves the player (#1791)
Physical Escape inside the player resolved to exitFullscreenIfActive on Windows and Linux whenever HTPC-style player navigation was off, so it dropped the window out of fullscreen regardless of who put it there. For anyone running with "start in fullscreen" (or who had toggled fullscreen from the browse UI), backing out of a movie left the app windowed, with "exit fullscreen on player close" switched off. Track fullscreen ownership instead: FullscreenStateManager now exposes a scope that the player opens in initState and closes in dispose, and setFullscreen — the single funnel every desktop platform reports through (window_manager on Linux, the Win32 runner callback on Windows, NSWindowDelegate on macOS) — records whether the fullscreen currently active was entered inside that scope. Escape only exits fullscreen the player itself entered; otherwise it is plain Back. The scope is depth-counted so the next-episode swap, where the incoming screen's initState runs before the outgoing screen's dispose, carries ownership across rather than resetting it. Nothing changes for a user who fullscreens from inside the player: Escape still exits fullscreen first, then acts as Back. The fullscreen toggle button and its shortcut are untouched, as is exitFullscreenOnPlayerClose. Fixes #1624.
This commit is contained in:
@@ -845,6 +845,10 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
|
||||
super.initState();
|
||||
unawaited(AndroidExitDiagnostics.markUiState(AndroidUiState.player));
|
||||
|
||||
// Fullscreen entered from here on is the player's to drop; whatever was
|
||||
// already fullscreen belongs to the app window (#1624).
|
||||
FullscreenStateManager().beginScope();
|
||||
|
||||
_playerNavigationCoordinator = PlayerNavigationCoordinator(
|
||||
chromeController: _chromeController,
|
||||
isPromptOpen: () => _showPlayNextDialog || _showStillWatchingPrompt,
|
||||
@@ -854,10 +858,14 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
|
||||
exitFullscreenIfActive: FullscreenStateManager().exitFullscreenIfActive,
|
||||
// macOS fullscreen belongs to the app window, while HTPC-style player
|
||||
// navigation treats physical Escape as semantic Back. In both cases the
|
||||
// player must leave native fullscreen alone.
|
||||
// player must leave native fullscreen alone. So must it when the window
|
||||
// was already fullscreen before the player opened — that fullscreen is
|
||||
// the app's (start-in-fullscreen, or a toggle from the browse UI) and
|
||||
// Escape is plain Back (#1624).
|
||||
physicalEscapeExitsFullscreen: () => shouldPhysicalEscapeExitFullscreen(
|
||||
isMacOS: Platform.isMacOS,
|
||||
videoPlayerNavigationEnabled: _videoPlayerNavigationEnabled,
|
||||
playerEnteredFullscreen: FullscreenStateManager().scopeOwnsFullscreen,
|
||||
),
|
||||
exitPlayer: () => unawaited(_handleBackButton()),
|
||||
navigateHome: _handleHomeButton,
|
||||
@@ -1708,6 +1716,7 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
|
||||
FullscreenStateManager().removeListener(_onFullscreenChanged);
|
||||
_fullscreenListenerAttached = false;
|
||||
}
|
||||
FullscreenStateManager().endScope();
|
||||
// Not _restoreWindowsDisplayMode(): that helper waits 200ms after clearing
|
||||
// the HDR hint before restoring, which dispose() cannot do. Fire the hint
|
||||
// clear at the still-live player and restore immediately.
|
||||
|
||||
Reference in New Issue
Block a user