add parent window setting when creating windows with glutin

needed for embedding api usage
This commit is contained in:
Mike Blumenkrantz 2015-05-08 21:15:07 -04:00
parent f4381a6f1e
commit 16a9712ab7
4 changed files with 9 additions and 6 deletions

View file

@ -53,7 +53,7 @@ fn main() {
let window = if opts::get().headless { let window = if opts::get().headless {
None None
} else { } else {
Some(app::create_window()) Some(app::create_window(std::ptr::null_mut()))
}; };
// Our wrapper around `Browser` that also implements some // Our wrapper around `Browser` that also implements some

View file

@ -96,7 +96,7 @@ impl ServoCefBrowser {
let host = ServoCefBrowserHost::new(client.clone()).as_cef_interface(); let host = ServoCefBrowserHost::new(client.clone()).as_cef_interface();
let servo_browser = if window_info.windowless_rendering_enabled == 0 { let servo_browser = if window_info.windowless_rendering_enabled == 0 {
let glutin_window = glutin_app::create_window(); let glutin_window = glutin_app::create_window(window_info.parent_window as glutin_app::WindowID);
let servo_browser = Browser::new(Some(glutin_window.clone())); let servo_browser = Browser::new(Some(glutin_window.clone()));
ServoBrowser::OnScreen(servo_browser) ServoBrowser::OnScreen(servo_browser)
} else { } else {

View file

@ -30,11 +30,13 @@ use util::opts;
pub mod window; pub mod window;
pub type WindowID = glutin::WindowID;
pub trait NestedEventLoopListener { pub trait NestedEventLoopListener {
fn handle_event_from_nested_event_loop(&mut self, event: WindowEvent) -> bool; fn handle_event_from_nested_event_loop(&mut self, event: WindowEvent) -> bool;
} }
pub fn create_window() -> Rc<Window> { pub fn create_window(parent: WindowID) -> Rc<Window> {
// Read command-line options. // Read command-line options.
let opts = opts::get(); let opts = opts::get();
let foreground = opts.output_file.is_none(); let foreground = opts.output_file.is_none();
@ -42,5 +44,5 @@ pub fn create_window() -> Rc<Window> {
let size = opts.initial_window_size.as_f32() * scale_factor; let size = opts.initial_window_size.as_f32() * scale_factor;
// Open a window. // Open a window.
Window::new(foreground, size.as_uint().cast().unwrap()) Window::new(foreground, size.as_uint().cast().unwrap(), parent)
} }

View file

@ -71,12 +71,13 @@ pub struct Window {
#[cfg(feature = "window")] #[cfg(feature = "window")]
impl Window { impl Window {
pub fn new(is_foreground: bool, window_size: TypedSize2D<DevicePixel, u32>) -> Rc<Window> { pub fn new(is_foreground: bool, window_size: TypedSize2D<DevicePixel, u32>, parent: glutin::WindowID) -> Rc<Window> {
let mut glutin_window = glutin::WindowBuilder::new() let mut glutin_window = glutin::WindowBuilder::new()
.with_title("Servo".to_string()) .with_title("Servo".to_string())
.with_dimensions(window_size.to_untyped().width, window_size.to_untyped().height) .with_dimensions(window_size.to_untyped().width, window_size.to_untyped().height)
.with_gl(Window::gl_version()) .with_gl(Window::gl_version())
.with_visibility(is_foreground) .with_visibility(is_foreground)
.with_parent(parent)
.build() .build()
.unwrap(); .unwrap();
unsafe { glutin_window.make_current() }; unsafe { glutin_window.make_current() };
@ -614,7 +615,7 @@ pub struct Window {
#[cfg(feature = "headless")] #[cfg(feature = "headless")]
impl Window { impl Window {
pub fn new(_is_foreground: bool, window_size: TypedSize2D<DevicePixel, u32>) -> Rc<Window> { pub fn new(_is_foreground: bool, window_size: TypedSize2D<DevicePixel, u32>, _parent: glutin::WindowID) -> Rc<Window> {
let window_size = window_size.to_untyped(); let window_size = window_size.to_untyped();
let headless_builder = glutin::HeadlessRendererBuilder::new(window_size.width, let headless_builder = glutin::HeadlessRendererBuilder::new(window_size.width,
window_size.height); window_size.height);