From fd040b0a5525e62c0483db0986aa63a4f611d6c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20Jim=C3=A9nez=20Moreno?= Date: Mon, 7 Oct 2019 11:21:55 +0200 Subject: [PATCH] Extend libsimpleservo API with a callback for media session activation --- ports/libsimpleservo/api/src/lib.rs | 2 ++ ports/libsimpleservo/capi/src/lib.rs | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/ports/libsimpleservo/api/src/lib.rs b/ports/libsimpleservo/api/src/lib.rs index 952d85f9d31..0984b7c49f3 100644 --- a/ports/libsimpleservo/api/src/lib.rs +++ b/ports/libsimpleservo/api/src/lib.rs @@ -130,6 +130,8 @@ pub trait HostTrait { fn get_clipboard_contents(&self) -> Option; /// 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 { diff --git a/ports/libsimpleservo/capi/src/lib.rs b/ports/libsimpleservo/capi/src/lib.rs index c6b27ae6d48..4fbd239000e 100644 --- a/ports/libsimpleservo/capi/src/lib.rs +++ b/ports/libsimpleservo/capi/src/lib.rs @@ -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); + } }