From a296b2d0739dbb795c1af3584d300450d5dd3540 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 12 May 2015 18:41:55 -0400 Subject: [PATCH 01/24] add back cef_browser_host::composite() method --- ports/cef/interfaces/cef_browser.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/ports/cef/interfaces/cef_browser.rs b/ports/cef/interfaces/cef_browser.rs index 46c9fcaf100..57db64c60a2 100644 --- a/ports/cef/interfaces/cef_browser.rs +++ b/ports/cef/interfaces/cef_browser.rs @@ -1320,6 +1320,13 @@ pub struct _cef_browser_host_t { pub drag_source_system_drag_ended: Option ()>, + // + // Instructs the browser to perform an accelerated composite. The appropriate + // Direct3D or OpenGL state must have been set up before calling this + // function. + // + pub composite: Option ()>, + // // Instructs the browser to initialize accelerated compositing. The // appropriate Direct3D or OpenGL state must have been set up before calling @@ -2214,6 +2221,23 @@ impl CefBrowserHost { } } + // + // Instructs the browser to perform an accelerated composite. The appropriate + // Direct3D or OpenGL state must have been set up before calling this + // function. + // + pub fn composite(&self) -> () { + if self.c_object.is_null() || + self.c_object as usize == mem::POST_DROP_USIZE { + panic!("called a CEF method on a null object") + } + unsafe { + CefWrap::to_rust( + ((*self.c_object).composite.unwrap())( + self.c_object)) + } + } + // // Instructs the browser to initialize accelerated compositing. The // appropriate Direct3D or OpenGL state must have been set up before calling From 52fb8562d6b9bc793f7a621d37b0d63105faa555 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Wed, 13 May 2015 18:54:19 -0400 Subject: [PATCH 02/24] add embedding macro for checking pointer existence needed for determining whether an interface or callback has been provided --- ports/cef/macros.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ports/cef/macros.rs b/ports/cef/macros.rs index f498769e6c9..908fd8cc8a8 100644 --- a/ports/cef/macros.rs +++ b/ports/cef/macros.rs @@ -4,6 +4,13 @@ #![macro_use] + +macro_rules! check_ptr_exist { + ($var:expr, $member:ident) => ( + unsafe { (*CefWrap::to_c($var)).$member.is_some() } + ); +} + // Provides the implementation of a CEF class. An example follows: // // struct ServoCefThing { From bf1d12e5e96d7219d1eb3a31f127fbcacaffe563 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Thu, 14 May 2015 14:49:16 -0400 Subject: [PATCH 03/24] add note that cef_render_handler_t::get_backing_rect() is only for os --- ports/cef/interfaces/cef_render_handler.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/cef/interfaces/cef_render_handler.rs b/ports/cef/interfaces/cef_render_handler.rs index 68beac427ab..a813d7a8732 100644 --- a/ports/cef/interfaces/cef_render_handler.rs +++ b/ports/cef/interfaces/cef_render_handler.rs @@ -175,7 +175,7 @@ pub struct _cef_render_handler_t { // Called to retrieve the backing size of the view rectangle which is relative // to screen coordinates. On HiDPI displays, the backing size can differ from // the view size as returned by |GetViewRect|. Return true (1) if the - // rectangle was provided. + // rectangle was provided. Only used on Mac OS. // pub get_backing_rect: Option libc::c_int { From 42179cf6e7768132822f33813e1d530d20797e95 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Thu, 14 May 2015 21:36:09 -0400 Subject: [PATCH 04/24] create x11 Display connection on cef_initialize() as expected this is how cef does it, we must obey our chromium overlords --- ports/cef/core.rs | 3 +++ ports/cef/window.rs | 38 ++++++++++++++++++++++++-------------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/ports/cef/core.rs b/ports/cef/core.rs index dbd7985539b..04218bd9ae9 100644 --- a/ports/cef/core.rs +++ b/ports/cef/core.rs @@ -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 } diff --git a/ports/cef/window.rs b/ports/cef/window.rs index 06104484475..fd93081b1d6 100644 --- a/ports/cef/window.rs +++ b/ports/cef/window.rs @@ -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>, -#[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 { - 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 { 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() +} From 8330eabac191af1d724621a18b85e2c61539612a Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Fri, 15 May 2015 15:48:35 -0400 Subject: [PATCH 05/24] temp re-set default url for cef while I figure out wtf is going on --- ports/cef/browser.rs | 6 +++--- ports/cef/core.rs | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ports/cef/browser.rs b/ports/cef/browser.rs index 8b2ab3b2b0f..6903c63505d 100644 --- a/ports/cef/browser.rs +++ b/ports/cef/browser.rs @@ -238,9 +238,9 @@ fn browser_host_create(window_info: &cef_window_info_t, if callback_executed { browser_callback_after_created(browser.clone()); } - if url != ptr::null() { - unsafe { browser.downcast().frame.load_url(CefWrap::to_rust(url)); } - } + //if url != ptr::null() { + //unsafe { browser.downcast().frame.load_url(CefWrap::to_rust(url)); } + //} BROWSERS.with(|browsers| { browsers.borrow_mut().push(browser.clone()); }); diff --git a/ports/cef/core.rs b/ports/cef/core.rs index 04218bd9ae9..a06df477eb9 100644 --- a/ports/cef/core.rs +++ b/ports/cef/core.rs @@ -12,10 +12,11 @@ use util::opts; use std::ffi; use std::str; use browser; +use std_url::Url; const MAX_RENDERING_THREADS: usize = 128; -//static HOME_URL: &'static str = "http://s27.postimg.org/vqbtrolyr/servo.jpg"; +static HOME_URL: &'static str = "http://s27.postimg.org/vqbtrolyr/servo.jpg"; static CEF_API_HASH_UNIVERSAL: &'static [u8] = b"8efd129f4afc344bd04b2feb7f73a149b6c4e27f\0"; #[cfg(target_os="windows")] @@ -66,6 +67,7 @@ pub extern "C" fn cef_initialize(args: *const cef_main_args_t, temp_opts.hard_fail = false; temp_opts.enable_text_antialiasing = true; temp_opts.resources_path = None; + temp_opts.url = Url::parse(HOME_URL).unwrap(); opts::set(temp_opts); init_window(); From 9f7aacdacf2364983367316c772f3c3668a64a79 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Mon, 18 May 2015 15:35:14 -0400 Subject: [PATCH 06/24] add check for self.context existence in composite_specific_target() --- components/compositing/compositor.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index f618077f5ea..960f99f5568 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -1288,8 +1288,11 @@ impl IOCompositor { self.composite_specific_target(target); } - fn composite_specific_target(&mut self, target: CompositeTarget) -> Option { - if !self.window.prepare_for_composite() { + pub fn composite_specific_target(&mut self, target: CompositeTarget) -> Option { + if !self.context.is_some() { + return None + } + if !self.window.prepare_for_composite(width, height) { return None } From fb72a64833d90abbfd3dcfb0ef2a6310f84e99df Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Mon, 18 May 2015 15:37:49 -0400 Subject: [PATCH 07/24] pass width and height information through to cef paint callback --- components/compositing/compositor.rs | 5 ++--- components/compositing/windowing.rs | 2 +- ports/cef/render_handler.rs | 6 +++--- ports/cef/window.rs | 4 ++-- ports/glutin/window.rs | 2 +- ports/gonk/src/window.rs | 2 +- 6 files changed, 10 insertions(+), 11 deletions(-) diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index 960f99f5568..346666ac31b 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -1292,6 +1292,8 @@ impl IOCompositor { if !self.context.is_some() { return None } + let (width, height) = + (self.window_size.width.get() as usize, self.window_size.height.get() as usize); if !self.window.prepare_for_composite(width, height) { return None } @@ -1305,9 +1307,6 @@ impl IOCompositor { _ => {} } - let (width, height) = - (self.window_size.width.get() as usize, self.window_size.height.get() as usize); - let (framebuffer_ids, texture_ids) = match target { CompositeTarget::Window => (vec!(), vec!()), _ => initialize_png(width, height) diff --git a/components/compositing/windowing.rs b/components/compositing/windowing.rs index 51b13bfdf81..196e1e2653f 100644 --- a/components/compositing/windowing.rs +++ b/components/compositing/windowing.rs @@ -123,7 +123,7 @@ pub trait WindowMethods { /// Requests that the window system prepare a composite. Typically this will involve making /// some type of platform-specific graphics context current. Returns true if the composite may /// proceed and false if it should not. - fn prepare_for_composite(&self) -> bool; + fn prepare_for_composite(&self, width: usize, height: usize) -> bool; /// Sets the cursor to be used in the window. fn set_cursor(&self, cursor: Cursor); diff --git a/ports/cef/render_handler.rs b/ports/cef/render_handler.rs index ef80b6ea881..01d2f51603c 100644 --- a/ports/cef/render_handler.rs +++ b/ports/cef/render_handler.rs @@ -8,12 +8,12 @@ use types::cef_paint_element_type_t::PET_VIEW; use std::ptr; pub trait CefRenderHandlerExtensions { - fn paint(&self, browser: CefBrowser); + fn paint(&self, browser: CefBrowser, width: usize, height: usize); } impl CefRenderHandlerExtensions for CefRenderHandler { - fn paint(&self, browser: CefBrowser) { - self.on_paint(browser, PET_VIEW, 0, ptr::null(), &mut (), 0, 0) + fn paint(&self, browser: CefBrowser, width: usize, height: usize) { + self.on_paint(browser, PET_VIEW, 0, ptr::null(), &mut (), width as i32, height as i32) } } diff --git a/ports/cef/window.rs b/ports/cef/window.rs index fd93081b1d6..96a2379deca 100644 --- a/ports/cef/window.rs +++ b/ports/cef/window.rs @@ -253,12 +253,12 @@ impl WindowMethods for Window { box receiver as Box) } - fn prepare_for_composite(&self) -> bool { + fn prepare_for_composite(&self, width: usize, height: usize) -> bool { let browser = self.cef_browser.borrow(); match *browser { None => {} Some(ref browser) => { - browser.get_host().get_client().get_render_handler().paint(browser.clone()); + browser.get_host().get_client().get_render_handler().paint(browser.clone(), width, height); } } true diff --git a/ports/glutin/window.rs b/ports/glutin/window.rs index 1878389ced3..74f6d8d2a62 100644 --- a/ports/glutin/window.rs +++ b/ports/glutin/window.rs @@ -550,7 +550,7 @@ impl WindowMethods for Window { self.window.set_cursor(glutin_cursor); } - fn prepare_for_composite(&self) -> bool { + fn prepare_for_composite(&self, _width: usize, _height: usize) -> bool { true } diff --git a/ports/gonk/src/window.rs b/ports/gonk/src/window.rs index c6c60088232..457f9d01aec 100644 --- a/ports/gonk/src/window.rs +++ b/ports/gonk/src/window.rs @@ -818,7 +818,7 @@ impl WindowMethods for Window { fn set_cursor(&self, _: Cursor) { } - fn prepare_for_composite(&self) -> bool { + fn prepare_for_composite(&self, _width: usize, _height: usize) -> bool { true } } From 09aba1f9de0e27708458e0ee0a0048c2c3624c08 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Mon, 18 May 2015 15:39:41 -0400 Subject: [PATCH 08/24] remove misleading FIXME(pcwalton) regarding gtk event loops in cef window --- ports/cef/window.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/ports/cef/window.rs b/ports/cef/window.rs index 96a2379deca..d2f60b04ac9 100644 --- a/ports/cef/window.rs +++ b/ports/cef/window.rs @@ -371,7 +371,6 @@ impl CompositorProxy for CefCompositorProxy { #[cfg(target_os="linux")] fn send(&mut self, msg: compositor_task::Msg) { - // FIXME(pcwalton): Kick the GTK event loop awake? self.sender.send(msg).unwrap(); } From e5a274b46756fa494df1f3a26b7425fa7ac5e588 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Mon, 18 May 2015 15:41:24 -0400 Subject: [PATCH 09/24] call XInitThreads() before creating our cef Display* object --- ports/cef/window.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ports/cef/window.rs b/ports/cef/window.rs index d2f60b04ac9..a8391c3dc37 100644 --- a/ports/cef/window.rs +++ b/ports/cef/window.rs @@ -33,7 +33,7 @@ use std::sync::mpsc::{Sender, channel}; #[cfg(target_os="linux")] extern crate x11; #[cfg(target_os="linux")] -use self::x11::xlib::XOpenDisplay; +use self::x11::xlib::{XInitThreads,XOpenDisplay}; #[cfg(target_os="linux")] pub static mut DISPLAY: *mut c_void = 0 as *mut c_void; @@ -383,7 +383,10 @@ impl CompositorProxy for CefCompositorProxy { #[cfg(target_os="linux")] pub fn init_window() { - unsafe { DISPLAY = XOpenDisplay(ptr::null()) as *mut c_void ; } + unsafe { + assert!(XInitThreads() != 0); + DISPLAY = XOpenDisplay(ptr::null()) as *mut c_void; + } } #[cfg(not(target_os="linux"))] pub fn init_window() {} From 1cd850b121cee1a029dda41ef44d912e53cc7901 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Mon, 18 May 2015 15:46:27 -0400 Subject: [PATCH 10/24] add window member to servo cef browser object to fix framebuffer size method platforms other than macos will not need/use a get_backing_rect() method since there is no virtual pixel scaling, and this method will need to be usable even before browsers are finished setting up, so ensure we can at least pass initial window size back also check method pointer availability before calling into a null function --- ports/cef/browser.rs | 18 +++++++++++++----- ports/cef/window.rs | 40 ++++++++++++++++++++++++++++++++-------- 2 files changed, 45 insertions(+), 13 deletions(-) diff --git a/ports/cef/browser.rs b/ports/cef/browser.rs index 6903c63505d..5c7db34abba 100644 --- a/ports/cef/browser.rs +++ b/ports/cef/browser.rs @@ -18,6 +18,7 @@ use glutin_app; use libc::c_int; use std::cell::{Cell, RefCell, BorrowState}; use std::ptr; +use std::rc::Rc; use std::sync::atomic::{AtomicIsize, Ordering}; thread_local!(pub static ID_COUNTER: AtomicIsize = AtomicIsize::new(0)); @@ -87,6 +88,8 @@ pub struct ServoCefBrowser { pub host: CefBrowserHost, /// A reference to the browser client. pub client: CefClient, + /// the glutin window when using windowed rendering + pub window: Option>, /// Whether the on-created callback has fired yet. pub callback_executed: Cell, /// the display system window handle: only to be used with host.get_window_handle() @@ -102,11 +105,15 @@ impl ServoCefBrowser { let frame = ServoCefFrame::new().as_cef_interface(); let host = ServoCefBrowserHost::new(client.clone()).as_cef_interface(); let mut window_handle: cef_window_handle_t = get_null_window_handle(); + let mut glutin_window: Option> = None; let servo_browser = if window_info.windowless_rendering_enabled == 0 { - let glutin_window = glutin_app::create_window(window_info.parent_window as glutin_app::WindowID); - let servo_browser = Browser::new(Some(glutin_window.clone())); - window_handle = glutin_window.platform_window() as cef_window_handle_t; + glutin_window = Some(glutin_app::create_window(window_info.parent_window as glutin_app::WindowID)); + let servo_browser = Browser::new(glutin_window.clone()); + window_handle = match glutin_window { + Some(ref win) => win.platform_window() as cef_window_handle_t, + None => get_null_window_handle() + }; ServoBrowser::OnScreen(servo_browser) } else { ServoBrowser::Invalid @@ -120,6 +127,7 @@ impl ServoCefBrowser { frame: frame, host: host, client: client, + window: glutin_window, callback_executed: Cell::new(false), servo_browser: RefCell::new(servo_browser), message_queue: RefCell::new(vec!()), @@ -139,9 +147,9 @@ pub trait ServoCefBrowserExtensions { impl ServoCefBrowserExtensions for CefBrowser { fn init(&self, window_info: &cef_window_info_t) { if window_info.windowless_rendering_enabled != 0 { - let window = window::Window::new(); - let servo_browser = Browser::new(Some(window.clone())); + let window = window::Window::new(window_info.width, window_info.height); window.set_browser(self.clone()); + let servo_browser = Browser::new(Some(window.clone())); *self.downcast().servo_browser.borrow_mut() = ServoBrowser::OffScreen(servo_browser); } diff --git a/ports/cef/window.rs b/ports/cef/window.rs index a8391c3dc37..328152f8067 100644 --- a/ports/cef/window.rs +++ b/ports/cef/window.rs @@ -43,6 +43,7 @@ pub static mut DISPLAY: *mut c_void = 0 as *mut c_void; #[derive(Clone)] pub struct Window { cef_browser: RefCell>, + size: TypedSize2D } #[cfg(target_os="macos")] @@ -77,11 +78,12 @@ fn load_gl() { impl Window { /// Creates a new window. - pub fn new() -> Rc { + pub fn new(width: u32, height: u32) -> Rc { load_gl(); Rc::new(Window { cef_browser: RefCell::new(None), + size: TypedSize2D(width, height) }) } @@ -166,14 +168,36 @@ impl WindowMethods for Window { fn framebuffer_size(&self) -> TypedSize2D { let browser = self.cef_browser.borrow(); match *browser { - None => TypedSize2D(400, 300), + None => self.size, Some(ref browser) => { - let mut rect = cef_rect_t::zero(); - browser.get_host() - .get_client() - .get_render_handler() - .get_backing_rect((*browser).clone(), &mut rect); - TypedSize2D(rect.width as u32, rect.height as u32) + if browser.downcast().callback_executed.get() != true { + self.size + } else { + let mut rect = cef_rect_t::zero(); + rect.width = self.size.width.get() as i32; + rect.height = self.size.height.get() as i32; + if cfg!(target_os="macos") { + // osx relies on virtual pixel scaling to provide sizes different from actual + // pixel size on screen. other platforms are just 1.0 unless the desktop/toolkit says otherwise + if check_ptr_exist!(browser.get_host().get_client(), get_render_handler) && + check_ptr_exist!(browser.get_host().get_client().get_render_handler(), get_backing_rect) { + browser.get_host() + .get_client() + .get_render_handler() + .get_backing_rect((*browser).clone(), &mut rect); + } + } else { + if check_ptr_exist!(browser.get_host().get_client(), get_render_handler) && + check_ptr_exist!(browser.get_host().get_client().get_render_handler(), get_view_rect) { + browser.get_host() + .get_client() + .get_render_handler() + .get_view_rect((*browser).clone(), &mut rect); + } + } + + TypedSize2D(rect.width as u32, rect.height as u32) + } } } } From ca7fc036fe9647f4a3535d3739e9119dc5d54e81 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Mon, 18 May 2015 15:49:34 -0400 Subject: [PATCH 11/24] ensure window protocol handling occurs during cef browser loop updating fixes window events when using cef windowed rendering --- ports/cef/browser.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ports/cef/browser.rs b/ports/cef/browser.rs index 5c7db34abba..49fcdba1c79 100644 --- a/ports/cef/browser.rs +++ b/ports/cef/browser.rs @@ -206,7 +206,11 @@ pub fn update() { if browser.downcast().callback_executed.get() == false { browser_callback_after_created(browser.clone()); } - browser.send_window_event(WindowEvent::Idle); + let event = match browser.downcast().window { + Some(ref win) => win.wait_events(), + None => WindowEvent::Idle + }; + browser.send_window_event(event); } }); } From 1aed319684eb3434420eb480d34f4cb130b6ff4f Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Mon, 18 May 2015 15:52:05 -0400 Subject: [PATCH 12/24] add pointer checks for cef method calls to avoid crashing on nonexistent methods --- ports/cef/browser_host.rs | 17 ++++++++++++++--- ports/cef/window.rs | 32 +++++++++++++++++++++----------- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/ports/cef/browser_host.rs b/ports/cef/browser_host.rs index 412fd51f3da..b9112db85c9 100644 --- a/ports/cef/browser_host.rs +++ b/ports/cef/browser_host.rs @@ -7,6 +7,7 @@ use interfaces::{CefBrowser, CefBrowserHost, CefClient, cef_browser_t, cef_brows use types::{cef_mouse_button_type_t, cef_mouse_event, cef_rect_t, cef_key_event, cef_window_handle_t}; use types::cef_key_event_type_t::{KEYEVENT_CHAR, KEYEVENT_KEYDOWN, KEYEVENT_KEYUP, KEYEVENT_RAWKEYDOWN}; use browser::{self, ServoCefBrowserExtensions}; +use wrappers::CefWrap; use compositing::windowing::{WindowEvent, MouseWindowEvent}; use geom::point::TypedPoint2D; @@ -35,9 +36,19 @@ full_cef_class_impl! { fn was_resized(&this,) -> () {{ let mut rect = cef_rect_t::zero(); - this.get_client() - .get_render_handler() - .get_backing_rect(this.downcast().browser.borrow().clone().unwrap(), &mut rect); + if cfg!(target_os="macos") { + if check_ptr_exist!(this.get_client(), get_render_handler) && + check_ptr_exist!(this.get_client().get_render_handler(), get_backing_rect) { + this.get_client() + .get_render_handler() + .get_backing_rect(this.downcast().browser.borrow().clone().unwrap(), &mut rect); + } + } else if check_ptr_exist!(this.get_client(), get_render_handler) && + check_ptr_exist!(this.get_client().get_render_handler(), get_view_rect) { + this.get_client() + .get_render_handler() + .get_view_rect(this.downcast().browser.borrow().clone().unwrap(), &mut rect); + } let size = TypedSize2D(rect.width as u32, rect.height as u32); this.downcast().send_window_event(WindowEvent::Resize(size)); }} diff --git a/ports/cef/window.rs b/ports/cef/window.rs index 328152f8067..8662627fd5c 100644 --- a/ports/cef/window.rs +++ b/ports/cef/window.rs @@ -12,6 +12,7 @@ use interfaces::CefBrowser; use render_handler::CefRenderHandlerExtensions; use rustc_unicode::str::Utf16Encoder; use types::{cef_cursor_handle_t, cef_cursor_type_t, cef_rect_t}; +use wrappers::CefWrap; use compositing::compositor_task::{self, CompositorProxy, CompositorReceiver}; use compositing::windowing::{WindowEvent, WindowMethods}; @@ -20,7 +21,7 @@ use geom::size::TypedSize2D; use gleam::gl; use layers::geometry::DevicePixel; use layers::platform::surface::NativeGraphicsMetadata; -use libc::{c_char, c_void}; +use libc::{c_char, c_int, c_void}; use msg::constellation_msg::{Key, KeyModifiers}; use std::ptr; use std_url::Url; @@ -222,7 +223,10 @@ impl WindowMethods for Window { match *browser { None => {} Some(ref browser) => { - browser.get_host().get_client().get_render_handler().on_present(browser.clone()); + if check_ptr_exist!(browser.get_host().get_client(), get_render_handler) && + check_ptr_exist!(browser.get_host().get_client().get_render_handler(), on_present) { + browser.get_host().get_client().get_render_handler().on_present(browser.clone()); + } } } } @@ -295,10 +299,13 @@ impl WindowMethods for Window { None => return, Some(ref browser) => browser, }; - browser.get_host() - .get_client() - .get_load_handler() - .on_load_end((*browser).clone(), browser.get_main_frame(), 200); + if check_ptr_exist!(browser.get_host().get_client(), get_load_handler) && + check_ptr_exist!(browser.get_host().get_client().get_load_handler(), on_load_end) { + browser.get_host() + .get_client() + .get_load_handler() + .on_load_end((*browser).clone(), browser.get_main_frame(), 200); + } } fn set_page_title(&self, string: Option) { @@ -349,11 +356,14 @@ impl WindowMethods for Window { Some(ref browser) => { let cursor_handle = self.cursor_handle_for_cursor(cursor); let info = CefCursorInfo { hotspot: cef_point_t {x: 0, y: 0}, image_scale_factor: 0.0, buffer: 0 as *mut isize, size: cef_size_t { width: 0, height: 0 } }; - browser.get_host() - .get_client() - .get_render_handler() - .on_cursor_change(browser.clone(), cursor_handle, - self.cursor_type_for_cursor(cursor), &info) + if check_ptr_exist!(browser.get_host().get_client(), get_render_handler) && + check_ptr_exist!(browser.get_host().get_client().get_render_handler(), on_cursor_change) { + browser.get_host() + .get_client() + .get_render_handler() + .on_cursor_change(browser.clone(), cursor_handle, + self.cursor_type_for_cursor(cursor), &info) + } } } } From 789a4973f7de5fa0f0df64138d380a6f1cad4104 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Mon, 18 May 2015 15:56:48 -0400 Subject: [PATCH 13/24] check method existence for hidpi_factor(), handle platforms other than macos --- ports/cef/window.rs | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/ports/cef/window.rs b/ports/cef/window.rs index 8662627fd5c..827e067c7fa 100644 --- a/ports/cef/window.rs +++ b/ports/cef/window.rs @@ -232,22 +232,34 @@ impl WindowMethods for Window { } fn hidpi_factor(&self) -> ScaleFactor { - let browser = self.cef_browser.borrow(); - match *browser { - None => ScaleFactor::new(1.0), - Some(ref browser) => { - let mut view_rect = cef_rect_t::zero(); - browser.get_host() - .get_client() - .get_render_handler() - .get_view_rect((*browser).clone(), &mut view_rect); - let mut backing_rect = cef_rect_t::zero(); - browser.get_host() - .get_client() - .get_render_handler() - .get_backing_rect((*browser).clone(), &mut backing_rect); - ScaleFactor::new(backing_rect.width as f32 / view_rect.width as f32) + if cfg!(target_os="macos") { + let browser = self.cef_browser.borrow(); + match *browser { + None => ScaleFactor::new(1.0), + Some(ref browser) => { + let mut view_rect = cef_rect_t::zero(); + if check_ptr_exist!(browser.get_host().get_client(), get_render_handler) && + check_ptr_exist!(browser.get_host().get_client().get_render_handler(), get_view_rect) { + browser.get_host() + .get_client() + .get_render_handler() + .get_view_rect((*browser).clone(), &mut view_rect); + } + let mut backing_rect = cef_rect_t::zero(); + if check_ptr_exist!(browser.get_host().get_client(), get_render_handler) && + check_ptr_exist!(browser.get_host().get_client().get_render_handler(), get_backing_rect) { + browser.get_host() + .get_client() + .get_render_handler() + .get_backing_rect((*browser).clone(), &mut backing_rect); + } + ScaleFactor::new(backing_rect.width as f32 / view_rect.width as f32) + } } + } else { + // FIXME(zmike) + // need to figure out a method for actually getting the scale factor instead of this nonsense + ScaleFactor::new(1.0 as f32) } } From 12d792f427a99723256470b24cc03b46cbd22428 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Mon, 18 May 2015 16:25:08 -0400 Subject: [PATCH 14/24] only create our own Display* in embedding when using OSR --- ports/cef/core.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ports/cef/core.rs b/ports/cef/core.rs index a06df477eb9..aa49bb17b51 100644 --- a/ports/cef/core.rs +++ b/ports/cef/core.rs @@ -70,7 +70,9 @@ pub extern "C" fn cef_initialize(args: *const cef_main_args_t, temp_opts.url = Url::parse(HOME_URL).unwrap(); opts::set(temp_opts); - init_window(); + if unsafe { (*settings).windowless_rendering_enabled != 0 } { + init_window(); + } return 1 } From 5697d9ff2c1cfc831e1bc5c9c7c77502a87e2c68 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 19 May 2015 13:10:23 -0400 Subject: [PATCH 15/24] add back browser_host::composite() method for embedding this changes the way that applications will use servo. whereas previously it was only necessary to call initialize() -> makecurrent, it's now necessary to explicitly call the composite() method in order to trigger the gl rendering. any other composite attempts (by servo) will trigger the on_paint() method, informing the app that a frame is ready. it's then up to the app to schedule the composite() such that the frame is rendered in a timely manner --- ports/cef/browser_host.rs | 11 ++++++++++- ports/cef/window.rs | 15 ++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/ports/cef/browser_host.rs b/ports/cef/browser_host.rs index b9112db85c9..680f7e8b99b 100644 --- a/ports/cef/browser_host.rs +++ b/ports/cef/browser_host.rs @@ -15,13 +15,15 @@ use geom::size::TypedSize2D; use libc::{c_double, c_int}; use msg::constellation_msg::{self, KeyModifiers, KeyState}; use script_traits::MouseButton; -use std::cell::RefCell; +use std::cell::{Cell, RefCell}; pub struct ServoCefBrowserHost { /// A reference to the browser. pub browser: RefCell>, /// A reference to the client. pub client: CefClient, + /// flag for return value of prepare_for_composite + pub composite_ok: Cell, } full_cef_class_impl! { @@ -176,6 +178,12 @@ full_cef_class_impl! { this.downcast().send_window_event(WindowEvent::InitializeCompositing); }} + fn composite(&this,) -> () {{ + this.downcast().composite_ok.set(true); + this.downcast().send_window_event(WindowEvent::Refresh); + this.downcast().composite_ok.set(false); + }} + fn get_window_handle(&this,) -> cef_window_handle_t {{ let t = this.downcast(); let browser = t.browser.borrow(); @@ -189,6 +197,7 @@ impl ServoCefBrowserHost { ServoCefBrowserHost { browser: RefCell::new(None), client: client, + composite_ok: Cell::new(false), } } diff --git a/ports/cef/window.rs b/ports/cef/window.rs index 827e067c7fa..a73f2253fe8 100644 --- a/ports/cef/window.rs +++ b/ports/cef/window.rs @@ -296,12 +296,21 @@ impl WindowMethods for Window { fn prepare_for_composite(&self, width: usize, height: usize) -> bool { let browser = self.cef_browser.borrow(); match *browser { - None => {} + None => { + panic!("No browser?!?"); + } Some(ref browser) => { - browser.get_host().get_client().get_render_handler().paint(browser.clone(), width, height); + if browser.downcast().host.downcast().composite_ok.get() == true { + true + } else { + if check_ptr_exist!(browser.get_host().get_client(), get_render_handler) && + check_ptr_exist!(browser.get_host().get_client().get_render_handler(), on_paint) { + browser.get_host().get_client().get_render_handler().paint(browser.clone(), width, height); + } + false + } } } - true } fn load_end(&self) { From 82cf1d53e31b81cb63a4309968b47776830abcc9 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 19 May 2015 13:34:25 -0400 Subject: [PATCH 16/24] bump rust-layers version --- components/servo/Cargo.lock | 2 +- ports/gonk/Cargo.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock index bbf2a3e0739..beb5c04723e 100644 --- a/components/servo/Cargo.lock +++ b/components/servo/Cargo.lock @@ -616,7 +616,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "layers" version = "0.1.0" -source = "git+https://github.com/servo/rust-layers#ff65707d621498949ed428077da7e42a9f9d2745" +source = "git+https://github.com/servo/rust-layers#0a09aa7bc8084aadf704d7d04b1b9d779860f46c" dependencies = [ "azure 0.1.0 (git+https://github.com/servo/rust-azure)", "cgl 0.0.1 (git+https://github.com/servo/rust-cgl)", diff --git a/ports/gonk/Cargo.lock b/ports/gonk/Cargo.lock index 168f839f5fd..f8ea9b89efa 100644 --- a/ports/gonk/Cargo.lock +++ b/ports/gonk/Cargo.lock @@ -527,7 +527,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "layers" version = "0.1.0" -source = "git+https://github.com/servo/rust-layers#ff65707d621498949ed428077da7e42a9f9d2745" +source = "git+https://github.com/servo/rust-layers#0a09aa7bc8084aadf704d7d04b1b9d779860f46c" dependencies = [ "azure 0.1.0 (git+https://github.com/servo/rust-azure)", "cgl 0.0.1 (git+https://github.com/servo/rust-cgl)", From 9b8585f20d642dfdc558221b7f6f60b3005b974c Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Thu, 21 May 2015 17:16:18 -0400 Subject: [PATCH 17/24] update cargo layers rust thing checkout --- components/servo/Cargo.lock | 13 +++++++++++-- ports/gonk/Cargo.lock | 13 +++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock index beb5c04723e..36de0159446 100644 --- a/components/servo/Cargo.lock +++ b/components/servo/Cargo.lock @@ -616,7 +616,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "layers" version = "0.1.0" -source = "git+https://github.com/servo/rust-layers#0a09aa7bc8084aadf704d7d04b1b9d779860f46c" +source = "git+https://github.com/servo/rust-layers#cfc29e48a11f0c1e5390a049850c3ba10f23e0ad" dependencies = [ "azure 0.1.0 (git+https://github.com/servo/rust-azure)", "cgl 0.0.1 (git+https://github.com/servo/rust-cgl)", @@ -630,7 +630,7 @@ dependencies = [ "log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "skia 0.0.20130412 (git+https://github.com/servo/skia)", - "xlib 0.1.0 (git+https://github.com/servo/rust-xlib)", + "x11 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1341,6 +1341,15 @@ dependencies = [ "libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "x11" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "xlib" version = "0.1.0" diff --git a/ports/gonk/Cargo.lock b/ports/gonk/Cargo.lock index f8ea9b89efa..cde02e745ae 100644 --- a/ports/gonk/Cargo.lock +++ b/ports/gonk/Cargo.lock @@ -527,7 +527,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "layers" version = "0.1.0" -source = "git+https://github.com/servo/rust-layers#0a09aa7bc8084aadf704d7d04b1b9d779860f46c" +source = "git+https://github.com/servo/rust-layers#cfc29e48a11f0c1e5390a049850c3ba10f23e0ad" dependencies = [ "azure 0.1.0 (git+https://github.com/servo/rust-azure)", "cgl 0.0.1 (git+https://github.com/servo/rust-cgl)", @@ -541,7 +541,7 @@ dependencies = [ "log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "skia 0.0.20130412 (git+https://github.com/servo/skia)", - "xlib 0.1.0 (git+https://github.com/servo/rust-xlib)", + "x11 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1183,6 +1183,15 @@ dependencies = [ "libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "x11" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "xlib" version = "0.1.0" From f53fc1900de3e66be94f6014f91c8f0a2daa40b6 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Thu, 21 May 2015 17:58:25 -0400 Subject: [PATCH 18/24] update pkg-config for cargo --- components/servo/Cargo.lock | 3 ++- ports/cef/Cargo.lock | 1 + ports/gonk/Cargo.lock | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock index 36de0159446..70f942b3661 100644 --- a/components/servo/Cargo.lock +++ b/components/servo/Cargo.lock @@ -890,6 +890,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "shared_library 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1347,7 +1348,7 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock index cecb4d20dd0..26d3027763f 100644 --- a/ports/cef/Cargo.lock +++ b/ports/cef/Cargo.lock @@ -880,6 +880,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "shared_library 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] diff --git a/ports/gonk/Cargo.lock b/ports/gonk/Cargo.lock index cde02e745ae..98a9a7b696e 100644 --- a/ports/gonk/Cargo.lock +++ b/ports/gonk/Cargo.lock @@ -1189,7 +1189,7 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] From 25f87aa8ab91ef425d177435b794be048b9dff28 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Thu, 21 May 2015 20:50:35 -0400 Subject: [PATCH 19/24] fix compile after pcwalton's multi-event handling PR --- ports/cef/browser.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ports/cef/browser.rs b/ports/cef/browser.rs index 49fcdba1c79..cf868cb10d0 100644 --- a/ports/cef/browser.rs +++ b/ports/cef/browser.rs @@ -206,11 +206,16 @@ pub fn update() { if browser.downcast().callback_executed.get() == false { browser_callback_after_created(browser.clone()); } - let event = match browser.downcast().window { + let mut events = match browser.downcast().window { Some(ref win) => win.wait_events(), - None => WindowEvent::Idle + None => vec![WindowEvent::Idle] }; - browser.send_window_event(event); + loop { + match events.pop() { + Some(event) => browser.send_window_event(event), + None => break + } + } } }); } From 442bfb716b8974b424f3c2422ce8a38a59bfd8c5 Mon Sep 17 00:00:00 2001 From: Lars Bergstrom Date: Fri, 22 May 2015 16:16:50 -0500 Subject: [PATCH 20/24] Update various Cargo patches and deal with the fallout --- components/servo/Cargo.lock | 16 ++++------------ ports/cef/Cargo.lock | 24 ++++++++---------------- ports/cef/lib.rs | 1 + ports/cef/window.rs | 11 ++++++----- ports/glutin/Cargo.toml | 1 + ports/glutin/lib.rs | 1 + ports/glutin/window.rs | 3 ++- ports/gonk/Cargo.lock | 4 ++-- 8 files changed, 25 insertions(+), 36 deletions(-) diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock index 70f942b3661..73a1c7b5a09 100644 --- a/components/servo/Cargo.lock +++ b/components/servo/Cargo.lock @@ -460,7 +460,7 @@ dependencies = [ "osmesa-sys 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "user32-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "x11 0.0.33 (registry+https://github.com/rust-lang/crates.io-index)", + "x11 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -481,6 +481,7 @@ dependencies = [ "time 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "url 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "util 0.0.1", + "x11 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -848,7 +849,7 @@ dependencies = [ [[package]] name = "offscreen_gl_context" version = "0.0.1" -source = "git+https://github.com/ecoal95/rust-offscreen-rendering-context#97eacf34b72f69b10130a0de016529e98ee32f04" +source = "git+https://github.com/ecoal95/rust-offscreen-rendering-context#71d5dbd838f7038feb9b366ec5a95503bb81039f" dependencies = [ "cgl 0.0.1 (git+https://github.com/servo/rust-cgl)", "core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)", @@ -858,7 +859,7 @@ dependencies = [ "layers 0.1.0 (git+https://github.com/servo/rust-layers)", "libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "xlib 0.1.0 (git+https://github.com/servo/rust-xlib)", + "x11 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -890,7 +891,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "shared_library 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1334,14 +1334,6 @@ dependencies = [ "libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "x11" -version = "0.0.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "x11" version = "1.1.0" diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock index 26d3027763f..31babf1132f 100644 --- a/ports/cef/Cargo.lock +++ b/ports/cef/Cargo.lock @@ -29,7 +29,7 @@ dependencies = [ "style 0.0.1", "url 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "util 0.0.1", - "x11 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "x11 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -462,7 +462,7 @@ dependencies = [ "osmesa-sys 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "user32-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "x11 0.0.33 (registry+https://github.com/rust-lang/crates.io-index)", + "x11 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -483,6 +483,7 @@ dependencies = [ "time 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "url 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "util 0.0.1", + "x11 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -618,7 +619,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "layers" version = "0.1.0" -source = "git+https://github.com/servo/rust-layers#ff65707d621498949ed428077da7e42a9f9d2745" +source = "git+https://github.com/servo/rust-layers#cfc29e48a11f0c1e5390a049850c3ba10f23e0ad" dependencies = [ "azure 0.1.0 (git+https://github.com/servo/rust-azure)", "cgl 0.0.1 (git+https://github.com/servo/rust-cgl)", @@ -632,7 +633,7 @@ dependencies = [ "log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "skia 0.0.20130412 (git+https://github.com/servo/skia)", - "xlib 0.1.0 (git+https://github.com/servo/rust-xlib)", + "x11 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -838,7 +839,7 @@ dependencies = [ [[package]] name = "offscreen_gl_context" version = "0.0.1" -source = "git+https://github.com/ecoal95/rust-offscreen-rendering-context#97eacf34b72f69b10130a0de016529e98ee32f04" +source = "git+https://github.com/ecoal95/rust-offscreen-rendering-context#71d5dbd838f7038feb9b366ec5a95503bb81039f" dependencies = [ "cgl 0.0.1 (git+https://github.com/servo/rust-cgl)", "core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)", @@ -848,7 +849,7 @@ dependencies = [ "layers 0.1.0 (git+https://github.com/servo/rust-layers)", "libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "xlib 0.1.0 (git+https://github.com/servo/rust-xlib)", + "x11 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -880,7 +881,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "shared_library 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1321,15 +1321,7 @@ dependencies = [ [[package]] name = "x11" -version = "0.0.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "x11" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/ports/cef/lib.rs b/ports/cef/lib.rs index ae9209022ef..54225fd3ae7 100644 --- a/ports/cef/lib.rs +++ b/ports/cef/lib.rs @@ -58,6 +58,7 @@ extern crate core_text; #[cfg(target_os="macos")] #[macro_use] extern crate objc; +#[cfg(target_os="linux")] extern crate x11; // Must come first. pub mod macros; diff --git a/ports/cef/window.rs b/ports/cef/window.rs index a73f2253fe8..8bf21db2ef4 100644 --- a/ports/cef/window.rs +++ b/ports/cef/window.rs @@ -277,11 +277,12 @@ impl WindowMethods for Window { #[cfg(target_os="linux")] fn native_metadata(&self) -> NativeGraphicsMetadata { - unsafe { - NativeGraphicsMetadata { - display: DISPLAY, - } - } + use x11::xlib; + unsafe { + NativeGraphicsMetadata { + display: DISPLAY as *mut xlib::Display, + } + } } fn create_compositor_channel(_: &Option>) diff --git a/ports/glutin/Cargo.toml b/ports/glutin/Cargo.toml index cdf0e9890a5..f503ee86441 100644 --- a/ports/glutin/Cargo.toml +++ b/ports/glutin/Cargo.toml @@ -47,3 +47,4 @@ time = "0.1.12" bitflags = "*" libc = "*" url = "*" +x11 = "*" diff --git a/ports/glutin/lib.rs b/ports/glutin/lib.rs index a0104edb991..3d66e50a5e4 100644 --- a/ports/glutin/lib.rs +++ b/ports/glutin/lib.rs @@ -21,6 +21,7 @@ extern crate time; extern crate util; extern crate egl; extern crate url; +#[cfg(target_os="linux")] extern crate x11; use compositing::windowing::WindowEvent; use geom::scale_factor::ScaleFactor; diff --git a/ports/glutin/window.rs b/ports/glutin/window.rs index 74f6d8d2a62..5da1b03fb7d 100644 --- a/ports/glutin/window.rs +++ b/ports/glutin/window.rs @@ -556,8 +556,9 @@ impl WindowMethods for Window { #[cfg(target_os="linux")] fn native_metadata(&self) -> NativeGraphicsMetadata { + use x11::xlib; NativeGraphicsMetadata { - display: unsafe { self.window.platform_display() } + display: unsafe { self.window.platform_display() as *mut xlib::Display } } } diff --git a/ports/gonk/Cargo.lock b/ports/gonk/Cargo.lock index 98a9a7b696e..b69d7fe34aa 100644 --- a/ports/gonk/Cargo.lock +++ b/ports/gonk/Cargo.lock @@ -730,7 +730,7 @@ dependencies = [ [[package]] name = "offscreen_gl_context" version = "0.0.1" -source = "git+https://github.com/ecoal95/rust-offscreen-rendering-context#97eacf34b72f69b10130a0de016529e98ee32f04" +source = "git+https://github.com/ecoal95/rust-offscreen-rendering-context#71d5dbd838f7038feb9b366ec5a95503bb81039f" dependencies = [ "cgl 0.0.1 (git+https://github.com/servo/rust-cgl)", "core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)", @@ -740,7 +740,7 @@ dependencies = [ "layers 0.1.0 (git+https://github.com/servo/rust-layers)", "libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "xlib 0.1.0 (git+https://github.com/servo/rust-xlib)", + "x11 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] From c6a4bdb787faf6b6a4b225c02428b6e9237ba813 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Fri, 22 May 2015 21:11:08 -0400 Subject: [PATCH 21/24] x11 version bump --- components/servo/Cargo.lock | 10 +++++----- ports/cef/Cargo.lock | 12 ++++++------ ports/gonk/Cargo.lock | 6 +++--- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock index 73a1c7b5a09..e4b4b3c14d4 100644 --- a/components/servo/Cargo.lock +++ b/components/servo/Cargo.lock @@ -460,7 +460,7 @@ dependencies = [ "osmesa-sys 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "user32-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "x11 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "x11 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -481,7 +481,7 @@ dependencies = [ "time 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "url 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "util 0.0.1", - "x11 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "x11 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -631,7 +631,7 @@ dependencies = [ "log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "skia 0.0.20130412 (git+https://github.com/servo/skia)", - "x11 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "x11 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -859,7 +859,7 @@ dependencies = [ "layers 0.1.0 (git+https://github.com/servo/rust-layers)", "libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "x11 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "x11 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1336,7 +1336,7 @@ dependencies = [ [[package]] name = "x11" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock index 31babf1132f..d6a56dc4dba 100644 --- a/ports/cef/Cargo.lock +++ b/ports/cef/Cargo.lock @@ -29,7 +29,7 @@ dependencies = [ "style 0.0.1", "url 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "util 0.0.1", - "x11 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "x11 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -462,7 +462,7 @@ dependencies = [ "osmesa-sys 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "user32-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "x11 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "x11 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -483,7 +483,7 @@ dependencies = [ "time 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "url 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "util 0.0.1", - "x11 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "x11 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -633,7 +633,7 @@ dependencies = [ "log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "skia 0.0.20130412 (git+https://github.com/servo/skia)", - "x11 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "x11 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -849,7 +849,7 @@ dependencies = [ "layers 0.1.0 (git+https://github.com/servo/rust-layers)", "libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "x11 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "x11 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1321,7 +1321,7 @@ dependencies = [ [[package]] name = "x11" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/ports/gonk/Cargo.lock b/ports/gonk/Cargo.lock index b69d7fe34aa..bdcc1527588 100644 --- a/ports/gonk/Cargo.lock +++ b/ports/gonk/Cargo.lock @@ -541,7 +541,7 @@ dependencies = [ "log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "skia 0.0.20130412 (git+https://github.com/servo/skia)", - "x11 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "x11 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -740,7 +740,7 @@ dependencies = [ "layers 0.1.0 (git+https://github.com/servo/rust-layers)", "libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "x11 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "x11 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1185,7 +1185,7 @@ dependencies = [ [[package]] name = "x11" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", From fcb5cf9c6d8a075b0a942c47806bea446ff89f58 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Sat, 23 May 2015 08:39:37 -0400 Subject: [PATCH 22/24] update offscreen_gl_context --- components/servo/Cargo.lock | 2 +- ports/cef/Cargo.lock | 2 +- ports/gonk/Cargo.lock | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock index e4b4b3c14d4..d32b61b57a6 100644 --- a/components/servo/Cargo.lock +++ b/components/servo/Cargo.lock @@ -849,7 +849,7 @@ dependencies = [ [[package]] name = "offscreen_gl_context" version = "0.0.1" -source = "git+https://github.com/ecoal95/rust-offscreen-rendering-context#71d5dbd838f7038feb9b366ec5a95503bb81039f" +source = "git+https://github.com/ecoal95/rust-offscreen-rendering-context#99cee719a811f28e70fe33fa71137663ac210487" dependencies = [ "cgl 0.0.1 (git+https://github.com/servo/rust-cgl)", "core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)", diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock index d6a56dc4dba..bace045caf9 100644 --- a/ports/cef/Cargo.lock +++ b/ports/cef/Cargo.lock @@ -839,7 +839,7 @@ dependencies = [ [[package]] name = "offscreen_gl_context" version = "0.0.1" -source = "git+https://github.com/ecoal95/rust-offscreen-rendering-context#71d5dbd838f7038feb9b366ec5a95503bb81039f" +source = "git+https://github.com/ecoal95/rust-offscreen-rendering-context#99cee719a811f28e70fe33fa71137663ac210487" dependencies = [ "cgl 0.0.1 (git+https://github.com/servo/rust-cgl)", "core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)", diff --git a/ports/gonk/Cargo.lock b/ports/gonk/Cargo.lock index bdcc1527588..3631b0e431d 100644 --- a/ports/gonk/Cargo.lock +++ b/ports/gonk/Cargo.lock @@ -730,7 +730,7 @@ dependencies = [ [[package]] name = "offscreen_gl_context" version = "0.0.1" -source = "git+https://github.com/ecoal95/rust-offscreen-rendering-context#71d5dbd838f7038feb9b366ec5a95503bb81039f" +source = "git+https://github.com/ecoal95/rust-offscreen-rendering-context#99cee719a811f28e70fe33fa71137663ac210487" dependencies = [ "cgl 0.0.1 (git+https://github.com/servo/rust-cgl)", "core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)", From 8799213d4a555c87e09931b0bdc5979f05b87315 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Sat, 23 May 2015 09:03:42 -0400 Subject: [PATCH 23/24] fix build --- ports/glutin/window.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/glutin/window.rs b/ports/glutin/window.rs index 5da1b03fb7d..726ddf97ba3 100644 --- a/ports/glutin/window.rs +++ b/ports/glutin/window.rs @@ -688,7 +688,7 @@ impl WindowMethods for Window { fn set_cursor(&self, _: Cursor) { } - fn prepare_for_composite(&self) -> bool { + fn prepare_for_composite(&self, _width: usize, _height: usize) -> bool { true } From c884b43b712fa020e69218dbfa3fc4d29e2cfede Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Sun, 24 May 2015 19:53:44 -0400 Subject: [PATCH 24/24] another glutin update --- components/servo/Cargo.lock | 2 +- ports/cef/Cargo.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock index d32b61b57a6..53b16cd2540 100644 --- a/components/servo/Cargo.lock +++ b/components/servo/Cargo.lock @@ -443,7 +443,7 @@ dependencies = [ [[package]] name = "glutin" version = "0.0.26" -source = "git+https://github.com/servo/glutin?branch=servo#ec7a5e40c1cc7b8176eb1e1f7bf70c8a19559400" +source = "git+https://github.com/servo/glutin?branch=servo#e888dc79471f062ae0b5fae0ba9e0f01ac96048e" dependencies = [ "android_glue 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "gdi32-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock index bace045caf9..5aed32ef333 100644 --- a/ports/cef/Cargo.lock +++ b/ports/cef/Cargo.lock @@ -445,7 +445,7 @@ dependencies = [ [[package]] name = "glutin" version = "0.0.26" -source = "git+https://github.com/servo/glutin?branch=servo#ec7a5e40c1cc7b8176eb1e1f7bf70c8a19559400" +source = "git+https://github.com/servo/glutin?branch=servo#e888dc79471f062ae0b5fae0ba9e0f01ac96048e" dependencies = [ "android_glue 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "gdi32-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",