CEF updates for Linux / MiniServo-GTK.

This commit is contained in:
Glenn Watson 2014-12-11 05:46:26 +10:00
parent d988d01dd0
commit 2bd6e48035
4 changed files with 42 additions and 16 deletions

View file

@ -82,4 +82,3 @@ pub mod window;
pub mod wrappers;
pub mod xml_reader;
pub mod zip_reader;

View file

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

View file

@ -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")]

View file

@ -37,21 +37,40 @@ pub struct Window {
cef_browser: RefCell<Option<CefBrowser>>,
}
#[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<Window> {
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<Rc<Window>>)