From 2bd6e48035cdec944f12f8d02de8479d178a06b5 Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Thu, 11 Dec 2014 05:46:26 +1000 Subject: [PATCH] CEF updates for Linux / MiniServo-GTK. --- ports/cef/lib.rs | 1 - ports/cef/macros.rs | 1 + ports/cef/types.rs | 2 +- ports/cef/window.rs | 54 +++++++++++++++++++++++++++++++++------------ 4 files changed, 42 insertions(+), 16 deletions(-) diff --git a/ports/cef/lib.rs b/ports/cef/lib.rs index 3b44180ec11..74c1f057e49 100644 --- a/ports/cef/lib.rs +++ b/ports/cef/lib.rs @@ -82,4 +82,3 @@ pub mod window; pub mod wrappers; pub mod xml_reader; pub mod zip_reader; - diff --git a/ports/cef/macros.rs b/ports/cef/macros.rs index c02f936c2ee..1a96cef97b2 100644 --- a/ports/cef/macros.rs +++ b/ports/cef/macros.rs @@ -119,6 +119,7 @@ macro_rules! cef_stub_static_method_impls( )* ) => ( $( + #[no_mangle] pub extern "C" fn $method_name($(_: $method_arg_type),*) -> $method_return_type { panic!("unimplemented static method: {}", stringify!($method_name)) diff --git a/ports/cef/types.rs b/ports/cef/types.rs index 3f0d0752661..b44f2a84159 100644 --- a/ports/cef/types.rs +++ b/ports/cef/types.rs @@ -40,7 +40,7 @@ pub enum cef_keyboard_handler_t {} pub enum cef_render_handler_t {} pub enum cef_request_handler_t {} #[cfg(target_os="linux")] -pub type cef_window_handle_t = c_uint; +pub type cef_window_handle_t = c_ulong; #[cfg(target_os="macos")] pub type cef_window_handle_t = *mut c_void; //NSView* //#[cfg(target_os="win")] diff --git a/ports/cef/window.rs b/ports/cef/window.rs index 2e3ec5c34a1..f677cf036d8 100644 --- a/ports/cef/window.rs +++ b/ports/cef/window.rs @@ -37,21 +37,40 @@ pub struct Window { cef_browser: RefCell>, } +#[cfg(target_os="macos")] +fn load_gl() { + const RTLD_DEFAULT: *mut c_void = (-2) as *mut c_void; + + extern { + fn dlsym(handle: *mut c_void, symbol: *const c_char) -> *mut c_void; + } + + gl::load_with(|s| { + unsafe { + let c_str = s.to_c_str(); + dlsym(RTLD_DEFAULT, c_str.as_ptr()) as *const c_void + } + }); +} + +#[cfg(target_os="linux")] +fn load_gl() { + extern { + fn glXGetProcAddress(symbol: *const c_char) -> *mut c_void; + } + + gl::load_with(|s| { + unsafe { + let c_str = s.to_c_str(); + glXGetProcAddress(c_str.as_ptr()) as *const c_void + } + }); +} + impl Window { /// Creates a new window. pub fn new() -> Rc { - const RTLD_DEFAULT: *mut c_void = (-2) as *mut c_void; - - extern { - fn dlsym(handle: *mut c_void, symbol: *const c_char) -> *mut c_void; - } - - gl::load_with(|s| { - unsafe { - let c_str = s.to_c_str(); - dlsym(RTLD_DEFAULT, c_str.as_ptr()) as *const c_void - } - }); + load_gl(); Rc::new(Window { cef_browser: RefCell::new(None), @@ -164,8 +183,15 @@ impl WindowMethods for Window { #[cfg(target_os="linux")] fn native_metadata(&self) -> NativeGraphicsMetadata { - // TODO(pcwalton) - panic!() + extern { + fn cef_get_xdisplay() -> *mut c_void; + } + + unsafe { + NativeGraphicsMetadata { + display: cef_get_xdisplay() + } + } } fn create_compositor_channel(_: &Option>)