diff --git a/ports/cef/core.rs b/ports/cef/core.rs index aa49bb17b51..847fbe185b9 100644 --- a/ports/cef/core.rs +++ b/ports/cef/core.rs @@ -26,6 +26,8 @@ static CEF_API_HASH_PLATFORM: &'static [u8] = b"6813214accbf2ebfb6bdcf8d00654650 #[cfg(target_os="linux")] static CEF_API_HASH_PLATFORM: &'static [u8] = b"2bc564c3871965ef3a2531b528bda3e17fa17a6d\0"; +pub static mut CEF_APP: *mut cef_app_t = 0 as *mut cef_app_t; + #[no_mangle] pub extern "C" fn cef_initialize(args: *const cef_main_args_t, @@ -36,6 +38,11 @@ pub extern "C" fn cef_initialize(args: *const cef_main_args_t, if args.is_null() { return 0; } + unsafe { + if !CEF_APP.is_null() { + panic!("Attempting to call cef_initialize() multiple times!"); + } + } unsafe { command_line_init((*args).argc, (*args).argv); @@ -47,6 +54,7 @@ pub extern "C" fn cef_initialize(args: *const cef_main_args_t, (*handler).on_context_initialized.map(|hcb| hcb(handler)); } }); + CEF_APP = application; } } diff --git a/ports/cef/window.rs b/ports/cef/window.rs index 8bf21db2ef4..87bda1af854 100644 --- a/ports/cef/window.rs +++ b/ports/cef/window.rs @@ -7,8 +7,9 @@ //! This is used for off-screen rendering mode only; on-screen windows (the default embedding mode) //! are managed by a platform toolkit (Glutin). +use core::CEF_APP; use eutil::Downcast; -use interfaces::CefBrowser; +use interfaces::{CefApp, CefBrowser}; use render_handler::CefRenderHandlerExtensions; use rustc_unicode::str::Utf16Encoder; use types::{cef_cursor_handle_t, cef_cursor_type_t, cef_rect_t}; @@ -428,6 +429,12 @@ impl CompositorProxy for CefCompositorProxy { #[cfg(target_os="linux")] fn send(&mut self, msg: compositor_task::Msg) { self.sender.send(msg).unwrap(); + unsafe { if CEF_APP.is_null() { return; } } + let capp = unsafe { CefApp::from_c_object_addref(CEF_APP) }; + if unsafe { (*CEF_APP).get_browser_process_handler.is_some() } && + check_ptr_exist!(capp.get_browser_process_handler(), on_work_available) { + capp.get_browser_process_handler().on_work_available(); + } } fn clone_compositor_proxy(&self) -> Box { diff --git a/ports/cef/wrappers.rs b/ports/cef/wrappers.rs index edeb664e2e5..2cc1d48fe63 100644 --- a/ports/cef/wrappers.rs +++ b/ports/cef/wrappers.rs @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use interfaces::{cef_drag_data_t, cef_post_data_element_t, cef_v8value_t, CefPostDataElement}; +use interfaces::{cef_app_t, CefApp, cef_drag_data_t, cef_post_data_element_t, cef_v8value_t, CefPostDataElement}; use interfaces::{CefV8Value}; use interfaces::{cef_download_handler_t, cef_drag_handler_t, cef_context_menu_handler_t}; use interfaces::{cef_dialog_handler_t, cef_focus_handler_t}; @@ -98,6 +98,7 @@ cef_pointer_wrapper!(()); cef_pointer_wrapper!(*mut ()); cef_pointer_wrapper!(*mut c_void); cef_pointer_wrapper!(c_void); +cef_pointer_wrapper!(cef_app_t); cef_pointer_wrapper!(cef_base_t); cef_pointer_wrapper!(cef_browser_settings_t); cef_pointer_wrapper!(cef_cookie_t); @@ -137,6 +138,7 @@ cef_noop_wrapper!(*mut cef_request_handler_t); cef_noop_wrapper!(*mut cef_string_list_t); cef_noop_wrapper!(*mut cef_string_utf16); cef_noop_wrapper!(c_int); +cef_noop_wrapper!(CefApp); cef_noop_wrapper!(CefBrowserSettings); cef_noop_wrapper!(CefScreenInfo); cef_noop_wrapper!(CefRequestContextSettings);