mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Stop animations when window is hidden (API + UWP)
This commit is contained in:
parent
5597ccf57d
commit
6ddde1a3e1
11 changed files with 77 additions and 0 deletions
|
@ -487,6 +487,17 @@ impl ServoGlue {
|
|||
self.process_event(WindowEvent::MediaSessionAction(action))
|
||||
}
|
||||
|
||||
pub fn change_visibility(&mut self, visible: bool) -> Result<(), &'static str> {
|
||||
info!("change_visibility");
|
||||
if let Ok(id) = self.get_browser_id() {
|
||||
let event = WindowEvent::ChangeBrowserVisibility(id, visible);
|
||||
self.process_event(event)
|
||||
} else {
|
||||
// Ignore visibility change if no browser has been created yet.
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn process_event(&mut self, event: WindowEvent) -> Result<(), &'static str> {
|
||||
self.events.push(event);
|
||||
if !self.batch_mode {
|
||||
|
|
|
@ -686,6 +686,14 @@ pub extern "C" fn media_session_action(action: CMediaSessionActionType) {
|
|||
});
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn change_visibility(visible: bool) {
|
||||
catch_any_panic(|| {
|
||||
debug!("change_visibility");
|
||||
call(|s| s.change_visibility(visible));
|
||||
});
|
||||
}
|
||||
|
||||
pub struct WakeupCallback(extern "C" fn());
|
||||
|
||||
impl WakeupCallback {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue