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