Extend libsimpleservo API with a callback for media session activation

This commit is contained in:
Fernando Jiménez Moreno 2019-10-07 11:21:55 +02:00
parent d7d775ac60
commit fd040b0a55
2 changed files with 8 additions and 0 deletions

View file

@ -130,6 +130,8 @@ pub trait HostTrait {
fn get_clipboard_contents(&self) -> Option<String>;
/// Sets system clipboard contents
fn set_clipboard_contents(&self, contents: String);
/// Called when a media session is activated or deactived.
fn on_media_session(&self, active: bool);
}
pub struct ServoGlue {

View file

@ -216,6 +216,7 @@ pub struct CHostCallbacks {
pub on_ime_state_changed: extern "C" fn(show: bool),
pub get_clipboard_contents: extern "C" fn() -> *const c_char,
pub set_clipboard_contents: extern "C" fn(contents: *const c_char),
pub on_media_session: extern "C" fn(active: bool),
}
/// Servo options
@ -708,4 +709,9 @@ impl HostTrait for HostCallbacks {
let contents = CString::new(contents).expect("Can't create string");
(self.0.set_clipboard_contents)(contents.as_ptr());
}
fn on_media_session(&self, active: bool) {
debug!("on_media_session (active: {:?})", active);
(self.0.on_media_session)(active);
}
}