From db31b818bcdeaa646d5f77fd3d1ddd95d4f5286e Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Mon, 19 Jan 2015 08:56:43 +1000 Subject: [PATCH 1/2] Switch CEF on screen build from glfw -> glutin. --- ports/cef/Cargo.lock | 49 ++++++++++++++++++++++++++++++++++++++++++-- ports/cef/Cargo.toml | 8 ++------ ports/cef/browser.rs | 8 ++++---- ports/cef/lib.rs | 3 +-- 4 files changed, 54 insertions(+), 14 deletions(-) diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock index 56759acaba8..bbcb25348c0 100644 --- a/ports/cef/Cargo.lock +++ b/ports/cef/Cargo.lock @@ -9,8 +9,7 @@ dependencies = [ "devtools 0.0.1", "geom 0.1.0 (git+https://github.com/servo/rust-geom)", "gfx 0.0.1", - "glfw 0.0.1 (git+https://github.com/servo/glfw-rs?ref=servo)", - "glfw_app 0.0.1", + "glutin_app 0.0.1", "js 0.1.0 (git+https://github.com/servo/rust-mozjs)", "layers 0.1.0 (git+https://github.com/servo/rust-layers)", "msg 0.0.1", @@ -24,6 +23,14 @@ dependencies = [ "util 0.0.1", ] +[[package]] +name = "android_glue" +version = "0.0.1" +source = "git+https://github.com/servo/android-rs-glue?ref=servo#122bc28545b5e59a923c466a484c403fa691bd55" +dependencies = [ + "compile_msg 0.1.3 (git+https://github.com/huonw/compile_msg)", +] + [[package]] name = "azure" version = "0.1.0" @@ -61,6 +68,11 @@ name = "cocoa" version = "0.1.1" source = "git+https://github.com/servo/rust-cocoa#bf53a53ce306279fc1cae0d56fdd5e7216696420" +[[package]] +name = "compile_msg" +version = "0.1.3" +source = "git+https://github.com/huonw/compile_msg#b19da50cacf5b11bbc065da6b449f6b4fe7c019a" + [[package]] name = "compositing" version = "0.0.1" @@ -327,6 +339,34 @@ dependencies = [ "util 0.0.1", ] +[[package]] +name = "glutin" +version = "0.0.2" +source = "git+https://github.com/servo/glutin?ref=servo#db27370a1cbafcbfcaeee52a44076a61b3e0573c" +dependencies = [ + "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)", + "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_generator 0.0.1 (git+https://github.com/bjz/gl-rs.git)", + "winapi 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "glutin_app" +version = "0.0.1" +dependencies = [ + "cgl 0.0.1 (git+https://github.com/servo/rust-cgl)", + "compositing 0.0.1", + "geom 0.1.0 (git+https://github.com/servo/rust-geom)", + "gleam 0.0.1 (git+https://github.com/servo/gleam)", + "glutin 0.0.2 (git+https://github.com/servo/glutin?ref=servo)", + "layers 0.1.0 (git+https://github.com/servo/rust-layers)", + "msg 0.0.1", + "time 0.1.0 (git+https://github.com/rust-lang/time)", + "util 0.0.1", +] + [[package]] name = "glx" version = "0.0.1" @@ -726,6 +766,11 @@ name = "uuid" version = "0.1.1" source = "git+https://github.com/rust-lang/uuid#fc793c974a25c126c5cf5daa3b18973512a7a6a0" +[[package]] +name = "winapi" +version = "0.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "xlib" version = "0.1.0" diff --git a/ports/cef/Cargo.toml b/ports/cef/Cargo.toml index 817ba629c94..87d6c7c141e 100644 --- a/ports/cef/Cargo.toml +++ b/ports/cef/Cargo.toml @@ -11,8 +11,8 @@ crate-type = ["dylib"] [dependencies.servo] path = "../../components/servo" -[dependencies.glfw_app] -path = "../glfw" +[dependencies.glutin_app] +path = "../glutin" [dependencies.plugins] path = "../../components/plugins" @@ -44,10 +44,6 @@ git = "https://github.com/servo/rust-azure" [dependencies.geom] git = "https://github.com/servo/rust-geom" -[dependencies.glfw] -git = "https://github.com/servo/glfw-rs" -branch = "servo" - [dependencies.js] git = "https://github.com/servo/rust-mozjs" diff --git a/ports/cef/browser.rs b/ports/cef/browser.rs index 2092f4cf824..1e70d79deab 100644 --- a/ports/cef/browser.rs +++ b/ports/cef/browser.rs @@ -13,7 +13,7 @@ use types::{cef_browser_settings_t, cef_string_t, cef_window_info_t}; use window; use compositing::windowing::{WindowNavigateMsg, WindowEvent}; -use glfw_app; +use glutin_app; use libc::c_int; use servo_util::opts; use std::cell::{Cell, RefCell}; @@ -22,7 +22,7 @@ thread_local!(pub static BROWSERS: RefCell> = RefCell::new(vec!( pub enum ServoBrowser { Invalid, - OnScreen(Browser), + OnScreen(Browser), OffScreen(Browser), } @@ -93,8 +93,8 @@ impl ServoCefBrowser { let host = ServoCefBrowserHost::new(client.clone()).as_cef_interface(); let servo_browser = if window_info.windowless_rendering_enabled == 0 { - let glfw_window = glfw_app::create_window(); - let servo_browser = Browser::new(Some(glfw_window.clone())); + let glutin_window = glutin_app::create_window(); + let servo_browser = Browser::new(Some(glutin_window.clone())); ServoBrowser::OnScreen(servo_browser) } else { ServoBrowser::Invalid diff --git a/ports/cef/lib.rs b/ports/cef/lib.rs index 3fac5abb456..669f8239686 100644 --- a/ports/cef/lib.rs +++ b/ports/cef/lib.rs @@ -20,8 +20,7 @@ extern crate azure; extern crate geom; extern crate gfx; extern crate gleam; -extern crate glfw; -extern crate glfw_app; +extern crate glutin_app; extern crate js; extern crate layers; extern crate png; From 36e151dc955e111e420efe6451d44185562c29b7 Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Mon, 19 Jan 2015 08:57:05 +1000 Subject: [PATCH 2/2] Add more key mappings. --- ports/glutin/window.rs | 73 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/ports/glutin/window.rs b/ports/glutin/window.rs index 4180b6223ee..52d404f7e87 100644 --- a/ports/glutin/window.rs +++ b/ports/glutin/window.rs @@ -377,12 +377,85 @@ fn glutin_mods_to_script_mods(modifiers: KeyModifiers) -> constellation_msg::Key fn glutin_key_to_script_key(key: glutin::VirtualKeyCode) -> Result { // TODO(negge): add more key mappings match key { + VirtualKeyCode::A => Ok(Key::A), + VirtualKeyCode::B => Ok(Key::B), + VirtualKeyCode::C => Ok(Key::C), + VirtualKeyCode::D => Ok(Key::D), + VirtualKeyCode::E => Ok(Key::E), + VirtualKeyCode::F => Ok(Key::F), + VirtualKeyCode::G => Ok(Key::G), + VirtualKeyCode::H => Ok(Key::H), + VirtualKeyCode::I => Ok(Key::I), + VirtualKeyCode::J => Ok(Key::J), + VirtualKeyCode::K => Ok(Key::K), + VirtualKeyCode::L => Ok(Key::L), + VirtualKeyCode::M => Ok(Key::M), + VirtualKeyCode::N => Ok(Key::N), + VirtualKeyCode::O => Ok(Key::O), + VirtualKeyCode::P => Ok(Key::P), + VirtualKeyCode::Q => Ok(Key::Q), + VirtualKeyCode::R => Ok(Key::R), + VirtualKeyCode::S => Ok(Key::S), + VirtualKeyCode::T => Ok(Key::T), + VirtualKeyCode::U => Ok(Key::U), + VirtualKeyCode::V => Ok(Key::V), + VirtualKeyCode::W => Ok(Key::W), + VirtualKeyCode::X => Ok(Key::X), + VirtualKeyCode::Y => Ok(Key::Y), + VirtualKeyCode::Z => Ok(Key::Z), + + VirtualKeyCode::Numpad0 => Ok(Key::Num0), + VirtualKeyCode::Numpad1 => Ok(Key::Num1), + VirtualKeyCode::Numpad2 => Ok(Key::Num2), + VirtualKeyCode::Numpad3 => Ok(Key::Num3), + VirtualKeyCode::Numpad4 => Ok(Key::Num4), + VirtualKeyCode::Numpad5 => Ok(Key::Num5), + VirtualKeyCode::Numpad6 => Ok(Key::Num6), + VirtualKeyCode::Numpad7 => Ok(Key::Num7), + VirtualKeyCode::Numpad8 => Ok(Key::Num8), + VirtualKeyCode::Numpad9 => Ok(Key::Num9), + + VirtualKeyCode::Key0 => Ok(Key::Kp0), + VirtualKeyCode::Key1 => Ok(Key::Kp1), + VirtualKeyCode::Key2 => Ok(Key::Kp2), + VirtualKeyCode::Key3 => Ok(Key::Kp3), + VirtualKeyCode::Key4 => Ok(Key::Kp4), + VirtualKeyCode::Key5 => Ok(Key::Kp5), + VirtualKeyCode::Key6 => Ok(Key::Kp6), + VirtualKeyCode::Key7 => Ok(Key::Kp7), + VirtualKeyCode::Key8 => Ok(Key::Kp8), + VirtualKeyCode::Key9 => Ok(Key::Kp9), + + VirtualKeyCode::Return => Ok(Key::Enter), + VirtualKeyCode::Space => Ok(Key::Space), VirtualKeyCode::Escape => Ok(Key::Escape), VirtualKeyCode::Equals => Ok(Key::Equal), VirtualKeyCode::Minus => Ok(Key::Minus), VirtualKeyCode::Back => Ok(Key::Backspace), VirtualKeyCode::PageDown => Ok(Key::PageDown), VirtualKeyCode::PageUp => Ok(Key::PageUp), + + VirtualKeyCode::Insert => Ok(Key::Insert), + VirtualKeyCode::Home => Ok(Key::Home), + VirtualKeyCode::Delete => Ok(Key::Delete), + VirtualKeyCode::End => Ok(Key::End), + + VirtualKeyCode::Left => Ok(Key::Left), + VirtualKeyCode::Up => Ok(Key::Up), + VirtualKeyCode::Right => Ok(Key::Right), + VirtualKeyCode::Down => Ok(Key::Down), + + VirtualKeyCode::Apostrophe => Ok(Key::Apostrophe), + VirtualKeyCode::Backslash => Ok(Key::Backslash), + VirtualKeyCode::Comma => Ok(Key::Comma), + VirtualKeyCode::Grave => Ok(Key::GraveAccent), + VirtualKeyCode::LBracket => Ok(Key::LeftBracket), + VirtualKeyCode::Period => Ok(Key::Period), + VirtualKeyCode::RBracket => Ok(Key::RightBracket), + VirtualKeyCode::Semicolon => Ok(Key::Semicolon), + VirtualKeyCode::Slash => Ok(Key::Slash), + VirtualKeyCode::Tab => Ok(Key::Tab), + _ => Err(()), } }