mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Various compile fixes for android rustup (link still fails).
This commit is contained in:
parent
466faac2a5
commit
1a9be88a1d
4 changed files with 77 additions and 67 deletions
17
components/servo/Cargo.lock
generated
17
components/servo/Cargo.lock
generated
|
@ -18,7 +18,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "android_glue"
|
||||
version = "0.0.1"
|
||||
source = "git+https://github.com/tomaka/android-rs-glue#cac0adb90bc576758f1ebf3b5e567961b1605c1f"
|
||||
source = "git+https://github.com/servo/android-rs-glue?ref=servo#de9f604bfc71e07f4e968d5dd393de5442dbb2c8"
|
||||
dependencies = [
|
||||
"compile_msg 0.1.1 (git+https://github.com/huonw/compile_msg)",
|
||||
]
|
||||
|
@ -64,7 +64,7 @@ source = "git+https://github.com/servo/rust-cocoa#19d6f6977dcedbf29000b65d83df66
|
|||
[[package]]
|
||||
name = "compile_msg"
|
||||
version = "0.1.1"
|
||||
source = "git+https://github.com/huonw/compile_msg#f526abe54b49642bc1e969e6c2af1411798b6776"
|
||||
source = "git+https://github.com/huonw/compile_msg#32a98df61c600ca5487487d2b5e8c55f4bc7a91a"
|
||||
|
||||
[[package]]
|
||||
name = "compositing"
|
||||
|
@ -329,14 +329,14 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "glutin"
|
||||
version = "0.0.2"
|
||||
source = "git+https://github.com/tomaka/glutin#749c47d8c20af078b06e8506b68a54e3799c1a8b"
|
||||
source = "git+https://github.com/servo/glutin?ref=servo#b86cbe5c61a943683309384fc9d7e7e97d58e290"
|
||||
dependencies = [
|
||||
"android_glue 0.0.1 (git+https://github.com/tomaka/android-rs-glue)",
|
||||
"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)",
|
||||
"compile_msg 0.1.1 (git+https://github.com/huonw/compile_msg)",
|
||||
"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.1 (git+https://github.com/retep998/winapi-rs)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -347,7 +347,7 @@ dependencies = [
|
|||
"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/tomaka/glutin)",
|
||||
"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)",
|
||||
|
@ -717,6 +717,11 @@ name = "uuid"
|
|||
version = "0.0.2"
|
||||
source = "git+https://github.com/rust-lang/uuid#f5d94d0043a615756edefaf9c6041f11e52b8370"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.0.1"
|
||||
source = "git+https://github.com/retep998/winapi-rs#80b6574a8bad8fc0a1f19c788b27a459bab26c83"
|
||||
|
||||
[[package]]
|
||||
name = "xlib"
|
||||
version = "0.1.0"
|
||||
|
|
|
@ -169,6 +169,7 @@ pub trait BloomHash {
|
|||
}
|
||||
|
||||
impl BloomHash for int {
|
||||
#[allow(exceeding_bitshifts)]
|
||||
#[inline]
|
||||
fn bloom_hash(&self) -> u32 {
|
||||
((*self >> 32) ^ *self) as u32
|
||||
|
@ -176,6 +177,7 @@ impl BloomHash for int {
|
|||
}
|
||||
|
||||
impl BloomHash for uint {
|
||||
#[allow(exceeding_bitshifts)]
|
||||
#[inline]
|
||||
fn bloom_hash(&self) -> u32 {
|
||||
((*self >> 32) ^ *self) as u32
|
||||
|
|
|
@ -23,7 +23,8 @@ path = "../../components/msg"
|
|||
path = "../../components/util"
|
||||
|
||||
[dependencies.glutin]
|
||||
git = "https://github.com/tomaka/glutin"
|
||||
git = "https://github.com/servo/glutin"
|
||||
branch = "servo"
|
||||
features = ["window", "headless"]
|
||||
|
||||
[dependencies.gleam]
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
|
||||
use compositing::compositor_task::{mod, CompositorProxy, CompositorReceiver};
|
||||
use compositing::windowing::{WindowEvent, WindowMethods, KeyEvent};
|
||||
use compositing::windowing::{IdleWindowEvent, ResizeWindowEvent};
|
||||
use compositing::windowing::{MouseWindowEventClass, MouseWindowMoveEventClass, ScrollWindowEvent};
|
||||
use compositing::windowing::{ZoomWindowEvent, PinchZoomWindowEvent, NavigationWindowEvent};
|
||||
use compositing::windowing::{QuitWindowEvent, MouseWindowClickEvent};
|
||||
use compositing::windowing::{Idle, Resize};
|
||||
use compositing::windowing::{MouseWindowEventClass, MouseWindowMoveEventClass, Scroll};
|
||||
use compositing::windowing::{Zoom, PinchZoom, Navigation};
|
||||
use compositing::windowing::{Quit, MouseWindowClickEvent};
|
||||
use compositing::windowing::{MouseWindowMouseDownEvent, MouseWindowMouseUpEvent};
|
||||
use compositing::windowing::{Forward, Back};
|
||||
use geom::point::{Point2D, TypedPoint2D};
|
||||
|
@ -18,17 +18,19 @@ use geom::size::TypedSize2D;
|
|||
use layers::geometry::DevicePixel;
|
||||
use layers::platform::surface::NativeGraphicsMetadata;
|
||||
use msg::constellation_msg;
|
||||
use msg::constellation_msg::{Key, KeyEscape, KeyEqual, KeyMinus, KeyBackspace, KeyPageUp, KeyPageDown, CONTROL, SHIFT, ALT};
|
||||
use msg::constellation_msg::{Key, CONTROL, SHIFT, ALT};
|
||||
use msg::compositor_msg::{IdlePaintState, PaintState, PaintingPaintState};
|
||||
use msg::compositor_msg::{FinishedLoading, Blank, Loading, PerformingLayout, ReadyState};
|
||||
use msg::constellation_msg::LoadData;
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::num::Float;
|
||||
use std::rc::Rc;
|
||||
use time::{mod, Timespec};
|
||||
use util::geometry::ScreenPx;
|
||||
use util::opts::{RenderApi, Mesa, OpenGL};
|
||||
use gleam::gl;
|
||||
use glutin;
|
||||
use glutin::{ElementState, Event, MouseButton, VirtualKeyCode};
|
||||
use NestedEventLoopListener;
|
||||
|
||||
#[cfg(target_os="linux")]
|
||||
|
@ -113,7 +115,7 @@ impl Window {
|
|||
.unwrap();
|
||||
unsafe { glutin_window.make_current() };
|
||||
|
||||
Windowed(glutin_window)
|
||||
WindowHandle::Windowed(glutin_window)
|
||||
}
|
||||
Mesa => {
|
||||
let headless_builder = glutin::HeadlessRendererBuilder::new(window_size.width,
|
||||
|
@ -121,7 +123,7 @@ impl Window {
|
|||
let headless_context = headless_builder.build().unwrap();
|
||||
unsafe { headless_context.make_current() };
|
||||
|
||||
Headless(HeadlessContext {
|
||||
WindowHandle::Headless(HeadlessContext {
|
||||
context: headless_context,
|
||||
size: size,
|
||||
})
|
||||
|
@ -157,9 +159,9 @@ impl WindowMethods for Window {
|
|||
/// Returns the size of the window in hardware pixels.
|
||||
fn framebuffer_size(&self) -> TypedSize2D<DevicePixel, uint> {
|
||||
let (width, height) = match self.glutin {
|
||||
Windowed(ref window) => window.get_inner_size(),
|
||||
Headless(ref context) => Some((context.size.to_untyped().width,
|
||||
context.size.to_untyped().height)),
|
||||
WindowHandle::Windowed(ref window) => window.get_inner_size(),
|
||||
WindowHandle::Headless(ref context) => Some((context.size.to_untyped().width,
|
||||
context.size.to_untyped().height)),
|
||||
}.unwrap();
|
||||
TypedSize2D(width as uint, height as uint)
|
||||
}
|
||||
|
@ -168,9 +170,9 @@ impl WindowMethods for Window {
|
|||
fn size(&self) -> TypedSize2D<ScreenPx, f32> {
|
||||
// TODO: Handle hidpi
|
||||
let (width, height) = match self.glutin {
|
||||
Windowed(ref window) => window.get_inner_size(),
|
||||
Headless(ref context) => Some((context.size.to_untyped().width,
|
||||
context.size.to_untyped().height)),
|
||||
WindowHandle::Windowed(ref window) => window.get_inner_size(),
|
||||
WindowHandle::Headless(ref context) => Some((context.size.to_untyped().width,
|
||||
context.size.to_untyped().height)),
|
||||
}.unwrap();
|
||||
TypedSize2D(width as f32, height as f32)
|
||||
}
|
||||
|
@ -178,8 +180,8 @@ impl WindowMethods for Window {
|
|||
/// Presents the window to the screen (perhaps by page flipping).
|
||||
fn present(&self) {
|
||||
match self.glutin {
|
||||
Windowed(ref window) => window.swap_buffers(),
|
||||
Headless(_) => {},
|
||||
WindowHandle::Windowed(ref window) => window.swap_buffers(),
|
||||
WindowHandle::Headless(_) => {},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -263,23 +265,23 @@ impl WindowMethods for Window {
|
|||
fn handle_key(&self, key: Key, mods: constellation_msg::KeyModifiers) {
|
||||
match key {
|
||||
// TODO(negge): handle window close event
|
||||
KeyEscape => {},
|
||||
KeyEqual if mods.contains(CONTROL) => { // Ctrl-+
|
||||
self.event_queue.borrow_mut().push(ZoomWindowEvent(1.1));
|
||||
Key::Escape => {},
|
||||
Key::Equal if mods.contains(CONTROL) => { // Ctrl-+
|
||||
self.event_queue.borrow_mut().push(Zoom(1.1));
|
||||
}
|
||||
KeyMinus if mods.contains(CONTROL) => { // Ctrl--
|
||||
self.event_queue.borrow_mut().push(ZoomWindowEvent(1.0/1.1));
|
||||
Key::Minus if mods.contains(CONTROL) => { // Ctrl--
|
||||
self.event_queue.borrow_mut().push(Zoom(1.0/1.1));
|
||||
}
|
||||
KeyBackspace if mods.contains(SHIFT) => { // Shift-Backspace
|
||||
self.event_queue.borrow_mut().push(NavigationWindowEvent(Forward));
|
||||
Key::Backspace if mods.contains(SHIFT) => { // Shift-Backspace
|
||||
self.event_queue.borrow_mut().push(Navigation(Forward));
|
||||
}
|
||||
KeyBackspace => { // Backspace
|
||||
self.event_queue.borrow_mut().push(NavigationWindowEvent(Back));
|
||||
Key::Backspace => { // Backspace
|
||||
self.event_queue.borrow_mut().push(Navigation(Back));
|
||||
}
|
||||
KeyPageDown => {
|
||||
Key::PageDown => {
|
||||
self.scroll_window(0.0, -self.framebuffer_size().as_f32().to_untyped().height);
|
||||
}
|
||||
KeyPageUp => {
|
||||
Key::PageUp => {
|
||||
self.scroll_window(0.0, self.framebuffer_size().as_f32().to_untyped().height);
|
||||
}
|
||||
_ => {}
|
||||
|
@ -291,7 +293,7 @@ impl Window {
|
|||
/// Helper function to set the window title in accordance with the ready state.
|
||||
fn update_window_title(&self) {
|
||||
match self.glutin {
|
||||
Windowed(ref window) => {
|
||||
WindowHandle::Windowed(ref window) => {
|
||||
let now = time::get_time();
|
||||
if now.sec == self.last_title_set_time.get().sec {
|
||||
return
|
||||
|
@ -320,7 +322,7 @@ impl Window {
|
|||
}
|
||||
}
|
||||
}
|
||||
Headless(_) => {},
|
||||
WindowHandle::Headless(_) => {},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -342,12 +344,12 @@ fn glutin_mods_to_script_mods(modifiers: KeyModifiers) -> constellation_msg::Key
|
|||
fn glutin_key_to_script_key(key: glutin::VirtualKeyCode) -> Result<constellation_msg::Key, ()> {
|
||||
// TODO(negge): add more key mappings
|
||||
match key {
|
||||
glutin::Escape => Ok(KeyEscape),
|
||||
glutin::Equals => Ok(KeyEqual),
|
||||
glutin::Minus => Ok(KeyMinus),
|
||||
glutin::Back => Ok(KeyBackspace),
|
||||
glutin::PageDown => Ok(KeyPageDown),
|
||||
glutin::PageUp => Ok(KeyPageUp),
|
||||
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),
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
|
@ -355,18 +357,18 @@ fn glutin_key_to_script_key(key: glutin::VirtualKeyCode) -> Result<constellation
|
|||
impl Window {
|
||||
fn handle_window_event(&self, event: glutin::Event) -> bool {
|
||||
match event {
|
||||
glutin::KeyboardInput(element_state, _scan_code, virtual_key_code) => {
|
||||
Event::KeyboardInput(element_state, _scan_code, virtual_key_code) => {
|
||||
if virtual_key_code.is_some() {
|
||||
let virtual_key_code = virtual_key_code.unwrap();
|
||||
|
||||
match (element_state, virtual_key_code) {
|
||||
(_, glutin::LControl) => self.toggle_modifier(LEFT_CONTROL),
|
||||
(_, glutin::RControl) => self.toggle_modifier(RIGHT_CONTROL),
|
||||
(_, glutin::LShift) => self.toggle_modifier(LEFT_SHIFT),
|
||||
(_, glutin::RShift) => self.toggle_modifier(RIGHT_SHIFT),
|
||||
(_, glutin::LAlt) => self.toggle_modifier(LEFT_ALT),
|
||||
(_, glutin::RAlt) => self.toggle_modifier(RIGHT_ALT),
|
||||
(glutin::Pressed, key_code) => {
|
||||
(_, VirtualKeyCode::LControl) => self.toggle_modifier(LEFT_CONTROL),
|
||||
(_, VirtualKeyCode::RControl) => self.toggle_modifier(RIGHT_CONTROL),
|
||||
(_, VirtualKeyCode::LShift) => self.toggle_modifier(LEFT_SHIFT),
|
||||
(_, VirtualKeyCode::RShift) => self.toggle_modifier(RIGHT_SHIFT),
|
||||
(_, VirtualKeyCode::LAlt) => self.toggle_modifier(LEFT_ALT),
|
||||
(_, VirtualKeyCode::RAlt) => self.toggle_modifier(RIGHT_ALT),
|
||||
(ElementState::Pressed, key_code) => {
|
||||
match glutin_key_to_script_key(key_code) {
|
||||
Ok(key) => {
|
||||
let state = constellation_msg::Pressed;
|
||||
|
@ -380,28 +382,28 @@ impl Window {
|
|||
}
|
||||
}
|
||||
}
|
||||
glutin::Resized(width, height) => {
|
||||
self.event_queue.borrow_mut().push(ResizeWindowEvent(TypedSize2D(width, height)));
|
||||
Event::Resized(width, height) => {
|
||||
self.event_queue.borrow_mut().push(Resize(TypedSize2D(width, height)));
|
||||
}
|
||||
glutin::MouseInput(element_state, mouse_button) => {
|
||||
if mouse_button == glutin::LeftMouseButton ||
|
||||
mouse_button == glutin::RightMouseButton {
|
||||
Event::MouseInput(element_state, mouse_button) => {
|
||||
if mouse_button == MouseButton::LeftMouseButton ||
|
||||
mouse_button == MouseButton::RightMouseButton {
|
||||
let mouse_pos = self.mouse_pos.get();
|
||||
self.handle_mouse(mouse_button, element_state, mouse_pos.x, mouse_pos.y);
|
||||
}
|
||||
}
|
||||
glutin::MouseMoved((x, y)) => {
|
||||
Event::MouseMoved((x, y)) => {
|
||||
self.mouse_pos.set(Point2D(x, y));
|
||||
self.event_queue.borrow_mut().push(
|
||||
MouseWindowMoveEventClass(TypedPoint2D(x as f32, y as f32)));
|
||||
}
|
||||
glutin::MouseWheel(delta) => {
|
||||
Event::MouseWheel(delta) => {
|
||||
if self.ctrl_pressed() {
|
||||
// Ctrl-Scrollwheel simulates a "pinch zoom" gesture.
|
||||
if delta < 0 {
|
||||
self.event_queue.borrow_mut().push(PinchZoomWindowEvent(1.0/1.1));
|
||||
self.event_queue.borrow_mut().push(PinchZoom(1.0/1.1));
|
||||
} else if delta > 0 {
|
||||
self.event_queue.borrow_mut().push(PinchZoomWindowEvent(1.1));
|
||||
self.event_queue.borrow_mut().push(PinchZoom(1.1));
|
||||
}
|
||||
} else {
|
||||
let dx = 0.0;
|
||||
|
@ -429,8 +431,8 @@ impl Window {
|
|||
/// Helper function to send a scroll event.
|
||||
fn scroll_window(&self, dx: f32, dy: f32) {
|
||||
let mouse_pos = self.mouse_pos.get();
|
||||
let event = ScrollWindowEvent(TypedPoint2D(dx as f32, dy as f32),
|
||||
TypedPoint2D(mouse_pos.x as i32, mouse_pos.y as i32));
|
||||
let event = Scroll(TypedPoint2D(dx as f32, dy as f32),
|
||||
TypedPoint2D(mouse_pos.x as i32, mouse_pos.y as i32));
|
||||
self.event_queue.borrow_mut().push(event);
|
||||
}
|
||||
|
||||
|
@ -439,12 +441,12 @@ impl Window {
|
|||
// FIXME(tkuehn): max pixel dist should be based on pixel density
|
||||
let max_pixel_dist = 10f64;
|
||||
let event = match action {
|
||||
glutin::Pressed => {
|
||||
ElementState::Pressed => {
|
||||
self.mouse_down_point.set(Point2D(x, y));
|
||||
self.mouse_down_button.set(Some(button));
|
||||
MouseWindowMouseDownEvent(0, TypedPoint2D(x as f32, y as f32))
|
||||
}
|
||||
glutin::Released => {
|
||||
ElementState::Released => {
|
||||
match self.mouse_down_button.get() {
|
||||
None => (),
|
||||
Some(but) if button == but => {
|
||||
|
@ -493,7 +495,7 @@ impl Window {
|
|||
}
|
||||
|
||||
match self.glutin {
|
||||
Windowed(ref window) => {
|
||||
WindowHandle::Windowed(ref window) => {
|
||||
let mut close_event = false;
|
||||
for event in window.wait_events() {
|
||||
close_event = self.handle_window_event(event);
|
||||
|
@ -503,13 +505,13 @@ impl Window {
|
|||
}
|
||||
|
||||
if close_event || window.is_closed() {
|
||||
QuitWindowEvent
|
||||
Quit
|
||||
} else {
|
||||
self.event_queue.borrow_mut().remove(0).unwrap_or(IdleWindowEvent)
|
||||
self.event_queue.borrow_mut().remove(0).unwrap_or(Idle)
|
||||
}
|
||||
}
|
||||
Headless(_) => {
|
||||
self.event_queue.borrow_mut().remove(0).unwrap_or(IdleWindowEvent)
|
||||
WindowHandle::Headless(_) => {
|
||||
self.event_queue.borrow_mut().remove(0).unwrap_or(Idle)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue