mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
glutin - Add support for waking up blocked event loop, and smooth resize on mac.
This commit is contained in:
parent
9aaae08c36
commit
4a70752a87
3 changed files with 43 additions and 21 deletions
10
components/servo/Cargo.lock
generated
10
components/servo/Cargo.lock
generated
|
@ -59,7 +59,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cocoa"
|
name = "cocoa"
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
source = "git+https://github.com/servo/rust-cocoa#19d6f6977dcedbf29000b65d83df66cf589c20c3"
|
source = "git+https://github.com/servo/rust-cocoa#8f47f126fe534d4dad86aa1f5b2da46a0581a232"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "compile_msg"
|
name = "compile_msg"
|
||||||
|
@ -329,14 +329,14 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "glutin"
|
name = "glutin"
|
||||||
version = "0.0.2"
|
version = "0.0.2"
|
||||||
source = "git+https://github.com/servo/glutin?ref=servo#b86cbe5c61a943683309384fc9d7e7e97d58e290"
|
source = "git+https://github.com/servo/glutin?ref=servo#936519a44f77f6b646c504eff38fe7d57a17b1f4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"android_glue 0.0.1 (git+https://github.com/servo/android-rs-glue?ref=servo)",
|
"android_glue 0.0.1 (git+https://github.com/servo/android-rs-glue?ref=servo)",
|
||||||
"cocoa 0.1.1 (git+https://github.com/servo/rust-cocoa)",
|
"cocoa 0.1.1 (git+https://github.com/servo/rust-cocoa)",
|
||||||
"core_graphics 0.1.0 (git+https://github.com/servo/rust-core-graphics)",
|
"core_graphics 0.1.0 (git+https://github.com/servo/rust-core-graphics)",
|
||||||
"gl_common 0.0.1 (git+https://github.com/bjz/gl-rs.git)",
|
"gl_common 0.0.1 (git+https://github.com/bjz/gl-rs.git)",
|
||||||
"gl_generator 0.0.1 (git+https://github.com/bjz/gl-rs.git)",
|
"gl_generator 0.0.1 (git+https://github.com/bjz/gl-rs.git)",
|
||||||
"winapi 0.0.1 (git+https://github.com/retep998/winapi-rs)",
|
"winapi 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -720,8 +720,8 @@ source = "git+https://github.com/rust-lang/uuid#f5d94d0043a615756edefaf9c6041f11
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi"
|
name = "winapi"
|
||||||
version = "0.0.1"
|
version = "0.0.2"
|
||||||
source = "git+https://github.com/retep998/winapi-rs#80b6574a8bad8fc0a1f19c788b27a459bab26c83"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "xlib"
|
name = "xlib"
|
||||||
|
|
2
ports/cef/Cargo.lock
generated
2
ports/cef/Cargo.lock
generated
|
@ -60,7 +60,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cocoa"
|
name = "cocoa"
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
source = "git+https://github.com/servo/rust-cocoa#19d6f6977dcedbf29000b65d83df66cf589c20c3"
|
source = "git+https://github.com/servo/rust-cocoa#8f47f126fe534d4dad86aa1f5b2da46a0581a232"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "compositing"
|
name = "compositing"
|
||||||
|
|
|
@ -47,6 +47,19 @@ enum WindowHandle {
|
||||||
Headless(HeadlessContext),
|
Headless(HeadlessContext),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static mut g_nested_event_loop_listener: Option<*mut NestedEventLoopListener + 'static> = None;
|
||||||
|
|
||||||
|
fn nested_window_resize(width: uint, height: uint) {
|
||||||
|
unsafe {
|
||||||
|
match g_nested_event_loop_listener {
|
||||||
|
None => {}
|
||||||
|
Some(listener) => {
|
||||||
|
(*listener).handle_event_from_nested_event_loop(Resize(TypedSize2D(width, height)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bitflags!(
|
bitflags!(
|
||||||
#[deriving(Show)]
|
#[deriving(Show)]
|
||||||
flags KeyModifiers: u8 {
|
flags KeyModifiers: u8 {
|
||||||
|
@ -107,7 +120,7 @@ impl Window {
|
||||||
|
|
||||||
let glutin = match render_api {
|
let glutin = match render_api {
|
||||||
OpenGL => {
|
OpenGL => {
|
||||||
let glutin_window = glutin::WindowBuilder::new()
|
let mut glutin_window = glutin::WindowBuilder::new()
|
||||||
.with_title("Servo [glutin]".to_string())
|
.with_title("Servo [glutin]".to_string())
|
||||||
.with_dimensions(window_size.width, window_size.height)
|
.with_dimensions(window_size.width, window_size.height)
|
||||||
.with_gl_version(gl_version())
|
.with_gl_version(gl_version())
|
||||||
|
@ -116,6 +129,7 @@ impl Window {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
unsafe { glutin_window.make_current() };
|
unsafe { glutin_window.make_current() };
|
||||||
|
|
||||||
|
glutin_window.set_window_resize_callback(Some(nested_window_resize));
|
||||||
WindowHandle::Windowed(glutin_window)
|
WindowHandle::Windowed(glutin_window)
|
||||||
}
|
}
|
||||||
Mesa => {
|
Mesa => {
|
||||||
|
@ -186,11 +200,23 @@ impl WindowMethods for Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_compositor_channel(_: &Option<Rc<Window>>)
|
fn create_compositor_channel(window: &Option<Rc<Window>>)
|
||||||
-> (Box<CompositorProxy+Send>, Box<CompositorReceiver>) {
|
-> (Box<CompositorProxy+Send>, Box<CompositorReceiver>) {
|
||||||
let (sender, receiver) = channel();
|
let (sender, receiver) = channel();
|
||||||
|
|
||||||
|
let window_proxy = match window {
|
||||||
|
&Some(ref window) => {
|
||||||
|
match window.glutin {
|
||||||
|
WindowHandle::Windowed(ref window) => Some(window.create_window_proxy()),
|
||||||
|
WindowHandle::Headless(_) => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&None => None,
|
||||||
|
};
|
||||||
|
|
||||||
(box GlutinCompositorProxy {
|
(box GlutinCompositorProxy {
|
||||||
sender: sender,
|
sender: sender,
|
||||||
|
window_proxy: window_proxy,
|
||||||
} as Box<CompositorProxy+Send>,
|
} as Box<CompositorProxy+Send>,
|
||||||
box receiver as Box<CompositorReceiver>)
|
box receiver as Box<CompositorReceiver>)
|
||||||
}
|
}
|
||||||
|
@ -476,20 +502,12 @@ impl Window {
|
||||||
|
|
||||||
pub unsafe fn set_nested_event_loop_listener(
|
pub unsafe fn set_nested_event_loop_listener(
|
||||||
&self,
|
&self,
|
||||||
_listener: *mut NestedEventLoopListener + 'static) {
|
listener: *mut NestedEventLoopListener + 'static) {
|
||||||
// TODO: Support this with glutin
|
g_nested_event_loop_listener = Some(listener)
|
||||||
//self.glfw_window.set_refresh_polling(false);
|
|
||||||
//glfw::ffi::glfwSetWindowRefreshCallback(self.glfw_window.ptr, Some(on_refresh));
|
|
||||||
//glfw::ffi::glfwSetFramebufferSizeCallback(self.glfw_window.ptr, Some(on_framebuffer_size));
|
|
||||||
//g_nested_event_loop_listener = Some(listener)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn remove_nested_event_loop_listener(&self) {
|
pub unsafe fn remove_nested_event_loop_listener(&self) {
|
||||||
// TODO: Support this with glutin
|
g_nested_event_loop_listener = None
|
||||||
//glfw::ffi::glfwSetWindowRefreshCallback(self.glfw_window.ptr, None);
|
|
||||||
//glfw::ffi::glfwSetFramebufferSizeCallback(self.glfw_window.ptr, None);
|
|
||||||
//self.glfw_window.set_refresh_polling(true);
|
|
||||||
//g_nested_event_loop_listener = None
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn wait_events(&self) -> WindowEvent {
|
pub fn wait_events(&self) -> WindowEvent {
|
||||||
|
@ -525,18 +543,22 @@ impl Window {
|
||||||
|
|
||||||
struct GlutinCompositorProxy {
|
struct GlutinCompositorProxy {
|
||||||
sender: Sender<compositor_task::Msg>,
|
sender: Sender<compositor_task::Msg>,
|
||||||
|
window_proxy: Option<glutin::WindowProxy>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CompositorProxy for GlutinCompositorProxy {
|
impl CompositorProxy for GlutinCompositorProxy {
|
||||||
fn send(&mut self, msg: compositor_task::Msg) {
|
fn send(&mut self, msg: compositor_task::Msg) {
|
||||||
// Send a message and kick the OS event loop awake.
|
// Send a message and kick the OS event loop awake.
|
||||||
self.sender.send(msg);
|
self.sender.send(msg);
|
||||||
// TODO: Support this with glutin
|
match self.window_proxy {
|
||||||
//glfw::Glfw::post_empty_event()
|
Some(ref window_proxy) => window_proxy.wakeup_event_loop(),
|
||||||
|
None => {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fn clone_compositor_proxy(&self) -> Box<CompositorProxy+Send> {
|
fn clone_compositor_proxy(&self) -> Box<CompositorProxy+Send> {
|
||||||
box GlutinCompositorProxy {
|
box GlutinCompositorProxy {
|
||||||
sender: self.sender.clone(),
|
sender: self.sender.clone(),
|
||||||
|
window_proxy: self.window_proxy.clone(),
|
||||||
} as Box<CompositorProxy+Send>
|
} as Box<CompositorProxy+Send>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue