mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
add parent window setting when creating windows with glutin
needed for embedding api usage
This commit is contained in:
parent
f4381a6f1e
commit
16a9712ab7
4 changed files with 9 additions and 6 deletions
|
@ -53,7 +53,7 @@ fn main() {
|
|||
let window = if opts::get().headless {
|
||||
None
|
||||
} else {
|
||||
Some(app::create_window())
|
||||
Some(app::create_window(std::ptr::null_mut()))
|
||||
};
|
||||
|
||||
// Our wrapper around `Browser` that also implements some
|
||||
|
|
|
@ -96,7 +96,7 @@ impl ServoCefBrowser {
|
|||
let host = ServoCefBrowserHost::new(client.clone()).as_cef_interface();
|
||||
|
||||
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()));
|
||||
ServoBrowser::OnScreen(servo_browser)
|
||||
} else {
|
||||
|
|
|
@ -30,11 +30,13 @@ use util::opts;
|
|||
|
||||
pub mod window;
|
||||
|
||||
pub type WindowID = glutin::WindowID;
|
||||
|
||||
pub trait NestedEventLoopListener {
|
||||
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.
|
||||
let opts = opts::get();
|
||||
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;
|
||||
|
||||
// Open a window.
|
||||
Window::new(foreground, size.as_uint().cast().unwrap())
|
||||
Window::new(foreground, size.as_uint().cast().unwrap(), parent)
|
||||
}
|
||||
|
|
|
@ -71,12 +71,13 @@ pub struct Window {
|
|||
|
||||
#[cfg(feature = "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()
|
||||
.with_title("Servo".to_string())
|
||||
.with_dimensions(window_size.to_untyped().width, window_size.to_untyped().height)
|
||||
.with_gl(Window::gl_version())
|
||||
.with_visibility(is_foreground)
|
||||
.with_parent(parent)
|
||||
.build()
|
||||
.unwrap();
|
||||
unsafe { glutin_window.make_current() };
|
||||
|
@ -614,7 +615,7 @@ pub struct Window {
|
|||
|
||||
#[cfg(feature = "headless")]
|
||||
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 headless_builder = glutin::HeadlessRendererBuilder::new(window_size.width,
|
||||
window_size.height);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue