Stop animations when window is hidden (API + UWP)

This commit is contained in:
Paul Rouget 2020-02-19 14:09:50 +01:00
parent 5597ccf57d
commit 6ddde1a3e1
11 changed files with 77 additions and 0 deletions

View file

@ -110,6 +110,8 @@ pub enum ConstellationMsg {
ExitFullScreen(TopLevelBrowsingContextId),
/// Media session action.
MediaSessionAction(MediaSessionActionType),
/// Toggle browser visibility.
ChangeBrowserVisibility(TopLevelBrowsingContextId, bool),
}
impl fmt::Debug for ConstellationMsg {
@ -141,6 +143,7 @@ impl fmt::Debug for ConstellationMsg {
DisableProfiler => "DisableProfiler",
ExitFullScreen(..) => "ExitFullScreen",
MediaSessionAction(..) => "MediaSessionAction",
ChangeBrowserVisibility(..) => "ChangeBrowserVisibility",
};
write!(formatter, "ConstellationMsg::{}", variant)
}

View file

@ -105,6 +105,8 @@ pub enum WindowEvent {
/// Sent when the user triggers a media action through the UA exposed media UI
/// (play, pause, seek, etc.).
MediaSessionAction(MediaSessionActionType),
/// Set browser visibility. A hidden browser will not tick the animations.
ChangeBrowserVisibility(TopLevelBrowsingContextId, bool),
}
impl Debug for WindowEvent {
@ -136,6 +138,7 @@ impl Debug for WindowEvent {
WindowEvent::ToggleSamplingProfiler(..) => write!(f, "ToggleSamplingProfiler"),
WindowEvent::ExitFullScreen(..) => write!(f, "ExitFullScreen"),
WindowEvent::MediaSessionAction(..) => write!(f, "MediaSessionAction"),
WindowEvent::ChangeBrowserVisibility(..) => write!(f, "ChangeBrowserVisibility"),
}
}
}