aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/compositing/compositor.rs12
-rw-r--r--components/compositing/windowing.rs2
-rw-r--r--components/servo/Cargo.lock16
-rw-r--r--ports/cef/Cargo.lock25
-rw-r--r--ports/cef/browser.rs35
-rw-r--r--ports/cef/browser_host.rs28
-rw-r--r--ports/cef/core.rs9
-rw-r--r--ports/cef/interfaces/cef_browser.rs24
-rw-r--r--ports/cef/interfaces/cef_render_handler.rs4
-rw-r--r--ports/cef/lib.rs1
-rw-r--r--ports/cef/macros.rs7
-rw-r--r--ports/cef/render_handler.rs6
-rw-r--r--ports/cef/window.rs178
-rw-r--r--ports/glutin/Cargo.toml1
-rw-r--r--ports/glutin/lib.rs1
-rw-r--r--ports/glutin/window.rs7
-rw-r--r--ports/gonk/Cargo.lock17
-rw-r--r--ports/gonk/src/window.rs2
18 files changed, 264 insertions, 111 deletions
diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs
index f618077f5ea..346666ac31b 100644
--- a/components/compositing/compositor.rs
+++ b/components/compositing/compositor.rs
@@ -1288,8 +1288,13 @@ impl<Window: WindowMethods> IOCompositor<Window> {
self.composite_specific_target(target);
}
- fn composite_specific_target(&mut self, target: CompositeTarget) -> Option<png::Image> {
- if !self.window.prepare_for_composite() {
+ pub fn composite_specific_target(&mut self, target: CompositeTarget) -> Option<png::Image> {
+ 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
}
@@ -1302,9 +1307,6 @@ impl<Window: WindowMethods> IOCompositor<Window> {
_ => {}
}
- 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/components/servo/Cargo.lock b/components/servo/Cargo.lock
index 26b0fe8f2c5..5928aa440b5 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)",
@@ -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.1 (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.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -616,7 +617,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)",
@@ -630,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)",
- "xlib 0.1.0 (git+https://github.com/servo/rust-xlib)",
+ "x11 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -843,7 +844,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#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)",
@@ -853,7 +854,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.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -1329,10 +1330,11 @@ dependencies = [
[[package]]
name = "x11"
-version = "0.0.33"
+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)",
+ "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 13a1492c42f..4a73b7d95d3 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.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -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)",
@@ -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.1 (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.1 (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.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -833,7 +834,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#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)",
@@ -843,7 +844,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.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -1314,15 +1315,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.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/browser.rs b/ports/cef/browser.rs
index 8b2ab3b2b0f..cf868cb10d0 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<Rc<glutin_app::window::Window>>,
/// Whether the on-created callback has fired yet.
pub callback_executed: Cell<bool>,
/// 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<Rc<glutin_app::window::Window>> = 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);
}
@@ -198,7 +206,16 @@ pub fn update() {
if browser.downcast().callback_executed.get() == false {
browser_callback_after_created(browser.clone());
}
- browser.send_window_event(WindowEvent::Idle);
+ let mut events = match browser.downcast().window {
+ Some(ref win) => win.wait_events(),
+ None => vec![WindowEvent::Idle]
+ };
+ loop {
+ match events.pop() {
+ Some(event) => browser.send_window_event(event),
+ None => break
+ }
+ }
}
});
}
@@ -238,9 +255,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/browser_host.rs b/ports/cef/browser_host.rs
index 412fd51f3da..680f7e8b99b 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;
@@ -14,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<Option<CefBrowser>>,
/// A reference to the client.
pub client: CefClient,
+ /// flag for return value of prepare_for_composite
+ pub composite_ok: Cell<bool>,
}
full_cef_class_impl! {
@@ -35,9 +38,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));
}}
@@ -165,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();
@@ -178,6 +197,7 @@ impl ServoCefBrowserHost {
ServoCefBrowserHost {
browser: RefCell::new(None),
client: client,
+ composite_ok: Cell::new(false),
}
}
diff --git a/ports/cef/core.rs b/ports/cef/core.rs
index dbd7985539b..aa49bb17b51 100644
--- a/ports/cef/core.rs
+++ b/ports/cef/core.rs
@@ -5,16 +5,18 @@
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;
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")]
@@ -65,8 +67,13 @@ 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);
+ if unsafe { (*settings).windowless_rendering_enabled != 0 } {
+ init_window();
+ }
+
return 1
}
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
@@ -1321,6 +1321,13 @@ pub struct _cef_browser_host_t {
this: *mut cef_browser_host_t) -> ()>,
//
+ // 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<extern "C" fn(this: *mut cef_browser_host_t) -> ()>,
+
+ //
// Instructs the browser to initialize accelerated compositing. The
// appropriate Direct3D or OpenGL state must have been set up before calling
// this function.
@@ -2215,6 +2222,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
// this function.
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<extern "C" fn(this: *mut cef_render_handler_t,
browser: *mut interfaces::cef_browser_t,
@@ -527,7 +527,7 @@ impl CefRenderHandler {
// 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 fn get_backing_rect(&self, browser: interfaces::CefBrowser,
rect: &mut types::cef_rect_t) -> libc::c_int {
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/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 {
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 06104484475..8bf21db2ef4 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;
@@ -33,15 +34,17 @@ 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;
/// 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,
+ size: TypedSize2D<DevicePixel,u32>
}
#[cfg(target_os="macos")]
@@ -76,21 +79,12 @@ 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> {
+ pub fn new(width: u32, height: u32) -> Rc<Window> {
load_gl();
Rc::new(Window {
cef_browser: RefCell::new(None),
+ size: TypedSize2D(width, height)
})
}
@@ -175,14 +169,36 @@ impl WindowMethods for Window {
fn framebuffer_size(&self) -> TypedSize2D<DevicePixel,u32> {
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)
+ }
}
}
}
@@ -207,28 +223,43 @@ 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());
+ }
}
}
}
fn hidpi_factor(&self) -> ScaleFactor<ScreenPx,DevicePixel,f32> {
- 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)
}
}
@@ -246,9 +277,12 @@ impl WindowMethods for Window {
#[cfg(target_os="linux")]
fn native_metadata(&self) -> NativeGraphicsMetadata {
- NativeGraphicsMetadata {
- display: self.display,
- }
+ use x11::xlib;
+ unsafe {
+ NativeGraphicsMetadata {
+ display: DISPLAY as *mut xlib::Display,
+ }
+ }
}
fn create_compositor_channel(_: &Option<Rc<Window>>)
@@ -260,15 +294,24 @@ impl WindowMethods for Window {
box receiver as Box<CompositorReceiver>)
}
- 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 => {}
+ None => {
+ panic!("No browser?!?");
+ }
Some(ref browser) => {
- browser.get_host().get_client().get_render_handler().paint(browser.clone());
+ 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) {
@@ -278,10 +321,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<String>) {
@@ -332,11 +378,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)
+ }
}
}
}
@@ -378,7 +427,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();
}
@@ -389,3 +437,23 @@ impl CompositorProxy for CefCompositorProxy {
}
}
+#[cfg(target_os="linux")]
+pub fn init_window() {
+ unsafe {
+ assert!(XInitThreads() != 0);
+ 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()
+}
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 7989cbc1f0f..8caa33d286e 100644
--- a/ports/glutin/window.rs
+++ b/ports/glutin/window.rs
@@ -552,14 +552,15 @@ 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
}
#[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 }
}
}
@@ -691,7 +692,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
}
diff --git a/ports/gonk/Cargo.lock b/ports/gonk/Cargo.lock
index 85edae988ce..f233496e3d5 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#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.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -725,7 +725,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#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)",
@@ -735,7 +735,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.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -1178,6 +1178,15 @@ dependencies = [
]
[[package]]
+name = "x11"
+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)",
+ "pkg-config 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "xlib"
version = "0.1.0"
source = "git+https://github.com/servo/rust-xlib#1a0f3d48fbebf96e2d1bf83ac71309b27f49e0c7"
diff --git a/ports/gonk/src/window.rs b/ports/gonk/src/window.rs
index 0655a64dd14..632f0257855 100644
--- a/ports/gonk/src/window.rs
+++ b/ports/gonk/src/window.rs
@@ -831,7 +831,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
}
}