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:
bors-servo 2020-02-20 14:28:09 -05:00 committed by GitHub
commit b5b9732509
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 78 additions and 1 deletions

View file

@ -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 {

View file

@ -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 {