mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
create x11 Display connection on cef_initialize() as expected
this is how cef does it, we must obey our chromium overlords
This commit is contained in:
parent
bf1d12e5e9
commit
42179cf6e7
2 changed files with 27 additions and 14 deletions
|
@ -5,6 +5,7 @@
|
|||
use command_line::command_line_init;
|
||||
use interfaces::cef_app_t;
|
||||
use types::{cef_main_args_t, cef_settings_t};
|
||||
use window::init_window;
|
||||
|
||||
use libc::{c_char, c_int, c_void};
|
||||
use util::opts;
|
||||
|
@ -67,6 +68,8 @@ pub extern "C" fn cef_initialize(args: *const cef_main_args_t,
|
|||
temp_opts.resources_path = None;
|
||||
opts::set(temp_opts);
|
||||
|
||||
init_window();
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
|
|
|
@ -35,13 +35,14 @@ extern crate x11;
|
|||
#[cfg(target_os="linux")]
|
||||
use self::x11::xlib::XOpenDisplay;
|
||||
|
||||
#[cfg(target_os="linux")]
|
||||
pub static mut DISPLAY: *mut c_void = 0 as *mut c_void;
|
||||
|
||||
/// The type of an off-screen window.
|
||||
#[allow(raw_pointer_derive)]
|
||||
#[derive(Clone)]
|
||||
pub struct Window {
|
||||
cef_browser: RefCell<Option<CefBrowser>>,
|
||||
#[cfg(target_os="linux")]
|
||||
display: *mut c_void,
|
||||
}
|
||||
|
||||
#[cfg(target_os="macos")]
|
||||
|
@ -76,16 +77,6 @@ fn load_gl() {
|
|||
|
||||
impl Window {
|
||||
/// Creates a new window.
|
||||
#[cfg(target_os="linux")]
|
||||
pub fn new() -> Rc<Window> {
|
||||
load_gl();
|
||||
|
||||
Rc::new(Window {
|
||||
cef_browser: RefCell::new(None),
|
||||
display: unsafe { XOpenDisplay(ptr::null()) as *mut c_void },
|
||||
})
|
||||
}
|
||||
#[cfg(not(target_os="linux"))]
|
||||
pub fn new() -> Rc<Window> {
|
||||
load_gl();
|
||||
|
||||
|
@ -246,8 +237,10 @@ impl WindowMethods for Window {
|
|||
|
||||
#[cfg(target_os="linux")]
|
||||
fn native_metadata(&self) -> NativeGraphicsMetadata {
|
||||
NativeGraphicsMetadata {
|
||||
display: self.display,
|
||||
unsafe {
|
||||
NativeGraphicsMetadata {
|
||||
display: DISPLAY,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -389,3 +382,20 @@ impl CompositorProxy for CefCompositorProxy {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os="linux")]
|
||||
pub fn init_window() {
|
||||
unsafe { DISPLAY = XOpenDisplay(ptr::null()) as *mut c_void ; }
|
||||
}
|
||||
#[cfg(not(target_os="linux"))]
|
||||
pub fn init_window() {}
|
||||
|
||||
#[cfg(target_os="linux")]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn cef_get_xdisplay() -> *mut c_void {
|
||||
unsafe { DISPLAY }
|
||||
}
|
||||
#[cfg(not(target_os="linux"))]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn cef_get_xdisplay() -> *mut c_void {
|
||||
ptr::null_mut()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue