Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embedding windowing #6016

Merged
merged 8 commits into from May 15, 2015

implement cef_browser_host_t::get_window_handle()

  • Loading branch information
Mike Blumenkrantz
Mike Blumenkrantz committed May 12, 2015
commit 4513d45c04b392a7b5205fe7645f8fcbb3b50d8f
@@ -9,7 +9,7 @@ use interfaces::{CefBrowser, CefBrowserHost, CefClient, CefFrame, CefRequestCont
use interfaces::{cef_browser_t, cef_browser_host_t, cef_client_t, cef_frame_t};
use interfaces::{cef_request_context_t};
use servo::Browser;
use types::{cef_browser_settings_t, cef_string_t, cef_window_info_t};
use types::{cef_browser_settings_t, cef_string_t, cef_window_info_t, cef_window_handle_t};
use window;
use wrappers::CefWrap;

@@ -90,6 +90,8 @@ pub struct ServoCefBrowser {
pub client: CefClient,
/// 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()
window_handle: cef_window_handle_t,

id: isize,
servo_browser: RefCell<ServoBrowser>,
@@ -100,10 +102,12 @@ impl ServoCefBrowser {
pub fn new(window_info: &cef_window_info_t, client: CefClient) -> 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 = 0;

let servo_browser = if window_info.windowless_rendering_enabled == 0 {
let glutin_window = glutin_app::create_window();
let servo_browser = Browser::new(Some(glutin_window.clone()));
window_handle = glutin_window.platform_window() as cef_window_handle_t;
ServoBrowser::OnScreen(servo_browser)
} else {
ServoBrowser::Invalid
@@ -121,6 +125,7 @@ impl ServoCefBrowser {
servo_browser: RefCell::new(servo_browser),
message_queue: RefCell::new(vec!()),
id: id,
window_handle: window_handle,
}
}
}
@@ -199,6 +204,10 @@ pub fn close(browser: CefBrowser) {
});
}

pub fn get_window(browser: &CefBrowser) -> cef_window_handle_t {
browser.downcast().window_handle
}

pub fn browser_callback_after_created(browser: CefBrowser) {
if browser.downcast().client.is_null_cef_object() {
return
@@ -4,7 +4,7 @@

use eutil::Downcast;
use interfaces::{CefBrowser, CefBrowserHost, CefClient, cef_browser_t, cef_browser_host_t, cef_client_t};
use types::{cef_mouse_button_type_t, cef_mouse_event, cef_rect_t, cef_key_event};
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};

@@ -164,6 +164,12 @@ full_cef_class_impl! {
fn initialize_compositing(&this,) -> () {{
this.downcast().send_window_event(WindowEvent::InitializeCompositing);
}}

fn get_window_handle(&this,) -> cef_window_handle_t {{
let t = this.downcast();
let browser = t.browser.borrow();
browser::get_window(&browser.as_ref().unwrap()) as cef_window_handle_t
}}
}
}

@@ -105,6 +105,10 @@ impl Window {
Rc::new(window)
}

pub fn platform_window(&self) -> glutin::WindowID {
unsafe { self.window.platform_window() }
}

fn nested_window_resize(width: u32, height: u32) {
unsafe {
match g_nested_event_loop_listener {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.