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 command_line::command_line_init;
|
||||||
use interfaces::cef_app_t;
|
use interfaces::cef_app_t;
|
||||||
use types::{cef_main_args_t, cef_settings_t};
|
use types::{cef_main_args_t, cef_settings_t};
|
||||||
|
use window::init_window;
|
||||||
|
|
||||||
use libc::{c_char, c_int, c_void};
|
use libc::{c_char, c_int, c_void};
|
||||||
use util::opts;
|
use util::opts;
|
||||||
|
@ -67,6 +68,8 @@ pub extern "C" fn cef_initialize(args: *const cef_main_args_t,
|
||||||
temp_opts.resources_path = None;
|
temp_opts.resources_path = None;
|
||||||
opts::set(temp_opts);
|
opts::set(temp_opts);
|
||||||
|
|
||||||
|
init_window();
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,13 +35,14 @@ extern crate x11;
|
||||||
#[cfg(target_os="linux")]
|
#[cfg(target_os="linux")]
|
||||||
use self::x11::xlib::XOpenDisplay;
|
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.
|
/// The type of an off-screen window.
|
||||||
#[allow(raw_pointer_derive)]
|
#[allow(raw_pointer_derive)]
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Window {
|
pub struct Window {
|
||||||
cef_browser: RefCell<Option<CefBrowser>>,
|
cef_browser: RefCell<Option<CefBrowser>>,
|
||||||
#[cfg(target_os="linux")]
|
|
||||||
display: *mut c_void,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os="macos")]
|
#[cfg(target_os="macos")]
|
||||||
|
@ -76,16 +77,6 @@ fn load_gl() {
|
||||||
|
|
||||||
impl Window {
|
impl Window {
|
||||||
/// Creates a new 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> {
|
pub fn new() -> Rc<Window> {
|
||||||
load_gl();
|
load_gl();
|
||||||
|
|
||||||
|
@ -246,8 +237,10 @@ impl WindowMethods for Window {
|
||||||
|
|
||||||
#[cfg(target_os="linux")]
|
#[cfg(target_os="linux")]
|
||||||
fn native_metadata(&self) -> NativeGraphicsMetadata {
|
fn native_metadata(&self) -> NativeGraphicsMetadata {
|
||||||
NativeGraphicsMetadata {
|
unsafe {
|
||||||
display: self.display,
|
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