mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Auto merge of #25799 - paulrouget:hideWindow, r=Manishearth
Hide window Stop animations when the window is hidden. Tested with both Immersive Mode, and regular window being minimized. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #25794 (GitHub issue number if applicable)
This commit is contained in:
commit
b5b9732509
12 changed files with 78 additions and 1 deletions
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1681,6 +1681,9 @@ where
|
|||
FromCompositorMsg::MediaSessionAction(action) => {
|
||||
self.handle_media_session_action_msg(action);
|
||||
},
|
||||
FromCompositorMsg::ChangeBrowserVisibility(top_level_browsing_context_id, visible) => {
|
||||
self.handle_change_browser_visibility(top_level_browsing_context_id, visible);
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4276,6 +4279,32 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
fn handle_change_browser_visibility(
|
||||
&mut self,
|
||||
top_level_browsing_context_id: TopLevelBrowsingContextId,
|
||||
visible: bool,
|
||||
) {
|
||||
let browsing_context_id = BrowsingContextId::from(top_level_browsing_context_id);
|
||||
let pipeline_id = match self.browsing_contexts.get(&browsing_context_id) {
|
||||
Some(browsing_context) => browsing_context.pipeline_id,
|
||||
None => {
|
||||
return warn!(
|
||||
"Browsing context {} got visibility change event after closure.",
|
||||
browsing_context_id
|
||||
);
|
||||
},
|
||||
};
|
||||
match self.pipelines.get(&pipeline_id) {
|
||||
None => {
|
||||
return warn!(
|
||||
"Pipeline {} got visibility change event after closure.",
|
||||
pipeline_id
|
||||
)
|
||||
},
|
||||
Some(pipeline) => pipeline.notify_visibility(visible),
|
||||
};
|
||||
}
|
||||
|
||||
fn notify_history_changed(&self, top_level_browsing_context_id: TopLevelBrowsingContextId) {
|
||||
// Send a flat projection of the history to embedder.
|
||||
// The final vector is a concatenation of the LoadData of the past
|
||||
|
|
|
@ -735,6 +735,19 @@ where
|
|||
);
|
||||
}
|
||||
},
|
||||
|
||||
WindowEvent::ChangeBrowserVisibility(top_level_browsing_context_id, visible) => {
|
||||
let msg = ConstellationMsg::ChangeBrowserVisibility(
|
||||
top_level_browsing_context_id,
|
||||
visible,
|
||||
);
|
||||
if let Err(e) = self.constellation_chan.send(msg) {
|
||||
warn!(
|
||||
"Sending ChangeBrowserVisibility to constellation failed ({:?}).",
|
||||
e
|
||||
);
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue