mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
parent
a9aa50683f
commit
5c408d2be9
39 changed files with 397 additions and 377 deletions
6
ports/cef/Cargo.lock
generated
6
ports/cef/Cargo.lock
generated
|
@ -384,7 +384,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "geom"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/rust-geom#1b49f8ce1c4e8ade720dd940d1964c657a96817f"
|
||||
source = "git+https://github.com/servo/rust-geom#16b91afc0b9b532f2fb56879069bc381f2143df1"
|
||||
dependencies = [
|
||||
"log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -616,7 +616,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
[[package]]
|
||||
name = "layers"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/rust-layers#ca37ca2949c46f91e37f28fa31ad6c1e8036f2d0"
|
||||
source = "git+https://github.com/servo/rust-layers#e566d3fc6ec80fe3aaf8ce67785683c99c46a015"
|
||||
dependencies = [
|
||||
"azure 0.1.0 (git+https://github.com/servo/rust-azure)",
|
||||
"cgl 0.0.1 (git+https://github.com/servo/cgl-rs)",
|
||||
|
@ -836,7 +836,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "offscreen_gl_context"
|
||||
version = "0.0.1"
|
||||
source = "git+https://github.com/ecoal95/rust-offscreen-rendering-context#0fd217b95d806bdcb6d381cf092ca8776de273c8"
|
||||
source = "git+https://github.com/ecoal95/rust-offscreen-rendering-context#c402c86f8d4472785e04e59505feb28638101700"
|
||||
dependencies = [
|
||||
"cgl 0.0.1 (git+https://github.com/servo/cgl-rs)",
|
||||
"core-foundation 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
|
@ -11,8 +11,8 @@ use browser::{self, ServoCefBrowserExtensions};
|
|||
use wrappers::CefWrap;
|
||||
|
||||
use compositing::windowing::{WindowEvent, MouseWindowEvent};
|
||||
use geom::point::TypedPoint2D;
|
||||
use geom::size::TypedSize2D;
|
||||
use geom::point::Point2D;
|
||||
use geom::size::Size2D;
|
||||
use libc::{c_double, c_int};
|
||||
use msg::constellation_msg::{self, KeyModifiers, KeyState};
|
||||
use script_traits::MouseButton;
|
||||
|
@ -385,7 +385,7 @@ full_cef_class_impl! {
|
|||
.get_render_handler()
|
||||
.get_view_rect(this.downcast().browser.borrow().clone().unwrap(), &mut rect);
|
||||
}
|
||||
let size = TypedSize2D(rect.width as u32, rect.height as u32);
|
||||
let size = Size2D::typed(rect.width as u32, rect.height as u32);
|
||||
this.downcast().send_window_event(WindowEvent::Resize(size));
|
||||
}}
|
||||
|
||||
|
@ -443,7 +443,7 @@ full_cef_class_impl! {
|
|||
cef_mouse_button_type_t::MBT_MIDDLE => MouseButton::Middle,
|
||||
cef_mouse_button_type_t::MBT_RIGHT => MouseButton::Right,
|
||||
};
|
||||
let point = TypedPoint2D((*event).x as f32, (*event).y as f32);
|
||||
let point = Point2D::typed((*event).x as f32, (*event).y as f32);
|
||||
if mouse_up != 0 {
|
||||
this.downcast().send_window_event(WindowEvent::MouseWindowEventClass(
|
||||
MouseWindowEvent::Click(button_type, point)))
|
||||
|
@ -457,7 +457,7 @@ full_cef_class_impl! {
|
|||
_mouse_exited: c_int [c_int],)
|
||||
-> () {{
|
||||
let event: &cef_mouse_event = event;
|
||||
let point = TypedPoint2D((*event).x as f32, (*event).y as f32);
|
||||
let point = Point2D::typed((*event).x as f32, (*event).y as f32);
|
||||
this.downcast().send_window_event(WindowEvent::MouseWindowMoveEventClass(point))
|
||||
}}
|
||||
|
||||
|
@ -469,8 +469,8 @@ full_cef_class_impl! {
|
|||
let event: &cef_mouse_event = event;
|
||||
let delta_x: c_int = delta_x;
|
||||
let delta_y: c_int = delta_y;
|
||||
let delta = TypedPoint2D(delta_x as f32, delta_y as f32);
|
||||
let origin = TypedPoint2D((*event).x as i32, (*event).y as i32);
|
||||
let delta = Point2D::typed(delta_x as f32, delta_y as f32);
|
||||
let origin = Point2D::typed((*event).x as i32, (*event).y as i32);
|
||||
this.downcast().send_window_event(WindowEvent::Scroll(delta, origin))
|
||||
}}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ use wrappers::CefWrap;
|
|||
use compositing::compositor_task::{self, CompositorProxy, CompositorReceiver};
|
||||
use compositing::windowing::{WindowEvent, WindowMethods};
|
||||
use geom::scale_factor::ScaleFactor;
|
||||
use geom::size::TypedSize2D;
|
||||
use geom::size::{Size2D, TypedSize2D};
|
||||
use gleam::gl;
|
||||
use layers::geometry::DevicePixel;
|
||||
use layers::platform::surface::NativeGraphicsMetadata;
|
||||
|
@ -86,7 +86,7 @@ impl Window {
|
|||
|
||||
Rc::new(Window {
|
||||
cef_browser: RefCell::new(None),
|
||||
size: TypedSize2D(width, height)
|
||||
size: Size2D::typed(width, height)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -199,7 +199,7 @@ impl WindowMethods for Window {
|
|||
}
|
||||
}
|
||||
|
||||
TypedSize2D(rect.width as u32, rect.height as u32)
|
||||
Size2D::typed(rect.width as u32, rect.height as u32)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -208,14 +208,14 @@ impl WindowMethods for Window {
|
|||
fn size(&self) -> TypedSize2D<ScreenPx,f32> {
|
||||
let browser = self.cef_browser.borrow();
|
||||
match *browser {
|
||||
None => TypedSize2D(400.0, 300.0),
|
||||
None => Size2D::typed(400.0, 300.0),
|
||||
Some(ref browser) => {
|
||||
let mut rect = cef_rect_t::zero();
|
||||
browser.get_host()
|
||||
.get_client()
|
||||
.get_render_handler()
|
||||
.get_view_rect((*browser).clone(), &mut rect);
|
||||
TypedSize2D(rect.width as f32, rect.height as f32)
|
||||
Size2D::typed(rect.width as f32, rect.height as f32)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
use compositing::compositor_task::{self, CompositorProxy, CompositorReceiver};
|
||||
use compositing::windowing::{WindowEvent, WindowMethods};
|
||||
use geom::scale_factor::ScaleFactor;
|
||||
use geom::size::TypedSize2D;
|
||||
use geom::size::{Size2D, TypedSize2D};
|
||||
use gleam::gl;
|
||||
use glutin;
|
||||
use layers::geometry::DevicePixel;
|
||||
|
@ -26,7 +26,7 @@ use NestedEventLoopListener;
|
|||
#[cfg(feature = "window")]
|
||||
use compositing::windowing::{MouseWindowEvent, WindowNavigateMsg};
|
||||
#[cfg(feature = "window")]
|
||||
use geom::point::{Point2D, TypedPoint2D};
|
||||
use geom::point::Point2D;
|
||||
#[cfg(feature = "window")]
|
||||
use glutin::{Api, ElementState, Event, GlRequest, MouseButton, VirtualKeyCode};
|
||||
#[cfg(feature = "window")]
|
||||
|
@ -90,9 +90,9 @@ impl Window {
|
|||
window: glutin_window,
|
||||
event_queue: RefCell::new(vec!()),
|
||||
mouse_down_button: Cell::new(None),
|
||||
mouse_down_point: Cell::new(Point2D(0, 0)),
|
||||
mouse_down_point: Cell::new(Point2D::new(0, 0)),
|
||||
|
||||
mouse_pos: Cell::new(Point2D(0, 0)),
|
||||
mouse_pos: Cell::new(Point2D::new(0, 0)),
|
||||
key_modifiers: Cell::new(KeyModifiers::empty()),
|
||||
};
|
||||
|
||||
|
@ -113,7 +113,8 @@ impl Window {
|
|||
match g_nested_event_loop_listener {
|
||||
None => {}
|
||||
Some(listener) => {
|
||||
(*listener).handle_event_from_nested_event_loop(WindowEvent::Resize(TypedSize2D(width, height)));
|
||||
(*listener).handle_event_from_nested_event_loop(
|
||||
WindowEvent::Resize(Size2D::typed(width, height)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -169,7 +170,7 @@ impl Window {
|
|||
}
|
||||
}
|
||||
Event::Resized(width, height) => {
|
||||
self.event_queue.borrow_mut().push(WindowEvent::Resize(TypedSize2D(width, height)));
|
||||
self.event_queue.borrow_mut().push(WindowEvent::Resize(Size2D::typed(width, height)));
|
||||
}
|
||||
Event::MouseInput(element_state, mouse_button) => {
|
||||
if mouse_button == MouseButton::Left ||
|
||||
|
@ -179,9 +180,9 @@ impl Window {
|
|||
}
|
||||
}
|
||||
Event::MouseMoved((x, y)) => {
|
||||
self.mouse_pos.set(Point2D(x, y));
|
||||
self.mouse_pos.set(Point2D::new(x, y));
|
||||
self.event_queue.borrow_mut().push(
|
||||
WindowEvent::MouseWindowMoveEventClass(TypedPoint2D(x as f32, y as f32)));
|
||||
WindowEvent::MouseWindowMoveEventClass(Point2D::typed(x as f32, y as f32)));
|
||||
}
|
||||
Event::MouseWheel(delta) => {
|
||||
if self.ctrl_pressed() {
|
||||
|
@ -220,8 +221,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 = WindowEvent::Scroll(TypedPoint2D(dx as f32, dy as f32),
|
||||
TypedPoint2D(mouse_pos.x as i32, mouse_pos.y as i32));
|
||||
let event = WindowEvent::Scroll(Point2D::typed(dx as f32, dy as f32),
|
||||
Point2D::typed(mouse_pos.x as i32, mouse_pos.y as i32));
|
||||
self.event_queue.borrow_mut().push(event);
|
||||
}
|
||||
|
||||
|
@ -233,21 +234,21 @@ impl Window {
|
|||
let max_pixel_dist = 10f64;
|
||||
let event = match action {
|
||||
ElementState::Pressed => {
|
||||
self.mouse_down_point.set(Point2D(x, y));
|
||||
self.mouse_down_point.set(Point2D::new(x, y));
|
||||
self.mouse_down_button.set(Some(button));
|
||||
MouseWindowEvent::MouseDown(MouseButton::Left, TypedPoint2D(x as f32, y as f32))
|
||||
MouseWindowEvent::MouseDown(MouseButton::Left, Point2D::typed(x as f32, y as f32))
|
||||
}
|
||||
ElementState::Released => {
|
||||
let mouse_up_event = MouseWindowEvent::MouseUp(MouseButton::Left, TypedPoint2D(x as f32, y as f32));
|
||||
let mouse_up_event = MouseWindowEvent::MouseUp(MouseButton::Left, Point2D::typed(x as f32, y as f32));
|
||||
match self.mouse_down_button.get() {
|
||||
None => mouse_up_event,
|
||||
Some(but) if button == but => {
|
||||
let pixel_dist = self.mouse_down_point.get() - Point2D(x, y);
|
||||
let pixel_dist = self.mouse_down_point.get() - Point2D::new(x, y);
|
||||
let pixel_dist = ((pixel_dist.x * pixel_dist.x +
|
||||
pixel_dist.y * pixel_dist.y) as f64).sqrt();
|
||||
if pixel_dist < max_pixel_dist {
|
||||
self.event_queue.borrow_mut().push(WindowEvent::MouseWindowEventClass(mouse_up_event));
|
||||
MouseWindowEvent::Click(MouseButton::Left, TypedPoint2D(x as f32, y as f32))
|
||||
MouseWindowEvent::Click(MouseButton::Left, Point2D::typed(x as f32, y as f32))
|
||||
} else {
|
||||
mouse_up_event
|
||||
}
|
||||
|
@ -462,12 +463,12 @@ impl WindowMethods for Window {
|
|||
fn framebuffer_size(&self) -> TypedSize2D<DevicePixel, u32> {
|
||||
let scale_factor = self.window.hidpi_factor() as u32;
|
||||
let (width, height) = self.window.get_inner_size().unwrap();
|
||||
TypedSize2D(width * scale_factor, height * scale_factor)
|
||||
Size2D::typed(width * scale_factor, height * scale_factor)
|
||||
}
|
||||
|
||||
fn size(&self) -> TypedSize2D<ScreenPx, f32> {
|
||||
let (width, height) = self.window.get_inner_size().unwrap();
|
||||
TypedSize2D(width as f32, height as f32)
|
||||
Size2D::typed(width as f32, height as f32)
|
||||
}
|
||||
|
||||
fn present(&self) {
|
||||
|
@ -672,11 +673,11 @@ impl Window {
|
|||
#[cfg(feature = "headless")]
|
||||
impl WindowMethods for Window {
|
||||
fn framebuffer_size(&self) -> TypedSize2D<DevicePixel, u32> {
|
||||
TypedSize2D(self.width, self.height)
|
||||
Size2D::typed(self.width, self.height)
|
||||
}
|
||||
|
||||
fn size(&self) -> TypedSize2D<ScreenPx, f32> {
|
||||
TypedSize2D(self.width as f32, self.height as f32)
|
||||
Size2D::typed(self.width as f32, self.height as f32)
|
||||
}
|
||||
|
||||
fn present(&self) {
|
||||
|
|
6
ports/gonk/Cargo.lock
generated
6
ports/gonk/Cargo.lock
generated
|
@ -363,7 +363,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
[[package]]
|
||||
name = "geom"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/rust-geom#1b49f8ce1c4e8ade720dd940d1964c657a96817f"
|
||||
source = "git+https://github.com/servo/rust-geom#16b91afc0b9b532f2fb56879069bc381f2143df1"
|
||||
dependencies = [
|
||||
"log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -550,7 +550,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
[[package]]
|
||||
name = "layers"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/rust-layers#ca37ca2949c46f91e37f28fa31ad6c1e8036f2d0"
|
||||
source = "git+https://github.com/servo/rust-layers#e566d3fc6ec80fe3aaf8ce67785683c99c46a015"
|
||||
dependencies = [
|
||||
"azure 0.1.0 (git+https://github.com/servo/rust-azure)",
|
||||
"cgl 0.0.1 (git+https://github.com/servo/cgl-rs)",
|
||||
|
@ -753,7 +753,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "offscreen_gl_context"
|
||||
version = "0.0.1"
|
||||
source = "git+https://github.com/ecoal95/rust-offscreen-rendering-context#0fd217b95d806bdcb6d381cf092ca8776de273c8"
|
||||
source = "git+https://github.com/ecoal95/rust-offscreen-rendering-context#c402c86f8d4472785e04e59505feb28638101700"
|
||||
dependencies = [
|
||||
"cgl 0.0.1 (git+https://github.com/servo/cgl-rs)",
|
||||
"core-foundation 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
|
@ -14,7 +14,7 @@ use std::thread;
|
|||
use std::sync::mpsc::Sender;
|
||||
use std::io::Read;
|
||||
|
||||
use geom::point::TypedPoint2D;
|
||||
use geom::point::Point2D;
|
||||
|
||||
use errno::errno;
|
||||
use libc::c_int;
|
||||
|
@ -167,7 +167,7 @@ fn read_input_device(device_path: &Path,
|
|||
let delta_y = slotA.y - first_y;
|
||||
let dist = delta_x * delta_x + delta_y * delta_y;
|
||||
if dist < 16 {
|
||||
let click_pt = TypedPoint2D(slotA.x as f32, slotA.y as f32);
|
||||
let click_pt = Point2D::typed(slotA.x as f32, slotA.y as f32);
|
||||
println!("Dispatching click!");
|
||||
sender.send(
|
||||
WindowEvent::MouseWindowEventClass(
|
||||
|
@ -193,8 +193,8 @@ fn read_input_device(device_path: &Path,
|
|||
} else {
|
||||
println!("Touch move x: {}, y: {}", slotA.x, slotA.y);
|
||||
sender.send(
|
||||
WindowEvent::Scroll(TypedPoint2D((slotA.x - last_x) as f32, (slotA.y - last_y) as f32),
|
||||
TypedPoint2D(slotA.x, slotA.y))).ok().unwrap();
|
||||
WindowEvent::Scroll(Point2D::typed((slotA.x - last_x) as f32, (slotA.y - last_y) as f32),
|
||||
Point2D::typed(slotA.x, slotA.y))).ok().unwrap();
|
||||
last_x = slotA.x;
|
||||
last_y = slotA.y;
|
||||
if touch_count >= 2 {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
use compositing::compositor_task::{self, CompositorProxy, CompositorReceiver};
|
||||
use compositing::windowing::{WindowEvent, WindowMethods};
|
||||
use geom::scale_factor::ScaleFactor;
|
||||
use geom::size::TypedSize2D;
|
||||
use geom::size::{Size2D, TypedSize2D};
|
||||
use layers::geometry::DevicePixel;
|
||||
use layers::platform::surface::NativeGraphicsMetadata;
|
||||
use libc::c_int;
|
||||
|
@ -784,12 +784,12 @@ impl Drop for Window {
|
|||
impl WindowMethods for Window {
|
||||
/// Returns the size of the window in hardware pixels.
|
||||
fn framebuffer_size(&self) -> TypedSize2D<DevicePixel, u32> {
|
||||
TypedSize2D(self.width as u32, self.height as u32)
|
||||
Size2D::typed(self.width as u32, self.height as u32)
|
||||
}
|
||||
|
||||
/// Returns the size of the window in density-independent "px" units.
|
||||
fn size(&self) -> TypedSize2D<ScreenPx, f32> {
|
||||
TypedSize2D(self.width as f32, self.height as f32)
|
||||
Size2D::typed(self.width as f32, self.height as f32)
|
||||
}
|
||||
|
||||
/// Presents the window to the screen (perhaps by page flipping).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue