Created
May 9, 2015 15:47
-
-
Save zmike/114ba6f8af73caf25a5a to your computer and use it in GitHub Desktop.
cef
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/ports/cef/browser.rs b/ports/cef/browser.rs | |
| index 3250da9..6b63853 100644 | |
| --- a/ports/cef/browser.rs | |
| +++ b/ports/cef/browser.rs | |
| @@ -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(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; | |
| 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 | |
| diff --git a/ports/cef/browser_host.rs b/ports/cef/browser_host.rs | |
| index 96804c7..daf169f 100644 | |
| --- a/ports/cef/browser_host.rs | |
| +++ b/ports/cef/browser_host.rs | |
| @@ -4,7 +4,7 @@ | |
| use eutil::Downcast; | |
| use interfaces::{CefBrowser, CefBrowserHost, CefClient, 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}; | |
| @@ -160,6 +160,10 @@ full_cef_class_impl! { | |
| fn initialize_compositing(&this,) -> () {{ | |
| this.downcast().send_window_event(WindowEvent::InitializeCompositing); | |
| }} | |
| + | |
| + fn get_window_handle(&this,) -> cef_window_handle_t {{ | |
| + browser::get_window(this.downcast().browser.borrow_mut().take().unwrap()) as cef_window_handle_t | |
| + }} | |
| } | |
| } | |
| diff --git a/ports/glutin/window.rs b/ports/glutin/window.rs | |
| index ef3dda8..42e83f5 100644 | |
| --- a/ports/glutin/window.rs | |
| +++ b/ports/glutin/window.rs | |
| @@ -106,6 +106,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 { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment