mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
auto merge of #4550 : Ms2ger/servo/MouseWindowEvent, r=jdm
This commit is contained in:
commit
ca876edc05
7 changed files with 25 additions and 28 deletions
|
@ -797,9 +797,9 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
|
|
||||||
fn on_mouse_window_event_class(&self, mouse_window_event: MouseWindowEvent) {
|
fn on_mouse_window_event_class(&self, mouse_window_event: MouseWindowEvent) {
|
||||||
let point = match mouse_window_event {
|
let point = match mouse_window_event {
|
||||||
MouseWindowEvent::MouseWindowClickEvent(_, p) => p,
|
MouseWindowEvent::Click(_, p) => p,
|
||||||
MouseWindowEvent::MouseWindowMouseDownEvent(_, p) => p,
|
MouseWindowEvent::MouseDown(_, p) => p,
|
||||||
MouseWindowEvent::MouseWindowMouseUpEvent(_, p) => p,
|
MouseWindowEvent::MouseUp(_, p) => p,
|
||||||
};
|
};
|
||||||
match self.find_topmost_layer_at_point(point / self.scene.scale) {
|
match self.find_topmost_layer_at_point(point / self.scene.scale) {
|
||||||
Some(result) => result.layer.send_mouse_event(mouse_window_event, result.point),
|
Some(result) => result.layer.send_mouse_event(mouse_window_event, result.point),
|
||||||
|
|
|
@ -318,11 +318,11 @@ impl CompositorLayer for Layer<CompositorData> {
|
||||||
cursor: TypedPoint2D<LayerPixel, f32>) {
|
cursor: TypedPoint2D<LayerPixel, f32>) {
|
||||||
let event_point = cursor.to_untyped();
|
let event_point = cursor.to_untyped();
|
||||||
let message = match event {
|
let message = match event {
|
||||||
MouseWindowEvent::MouseWindowClickEvent(button, _) =>
|
MouseWindowEvent::Click(button, _) =>
|
||||||
ClickEvent(button, event_point),
|
ClickEvent(button, event_point),
|
||||||
MouseWindowEvent::MouseWindowMouseDownEvent(button, _) =>
|
MouseWindowEvent::MouseDown(button, _) =>
|
||||||
MouseDownEvent(button, event_point),
|
MouseDownEvent(button, event_point),
|
||||||
MouseWindowEvent::MouseWindowMouseUpEvent(button, _) =>
|
MouseWindowEvent::MouseUp(button, _) =>
|
||||||
MouseUpEvent(button, event_point),
|
MouseUpEvent(button, event_point),
|
||||||
};
|
};
|
||||||
let pipeline = &self.extra_data.borrow().pipeline;
|
let pipeline = &self.extra_data.borrow().pipeline;
|
||||||
|
|
|
@ -19,9 +19,9 @@ use std::fmt::{FormatError, Formatter, Show};
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
pub enum MouseWindowEvent {
|
pub enum MouseWindowEvent {
|
||||||
MouseWindowClickEvent(uint, TypedPoint2D<DevicePixel, f32>),
|
Click(uint, TypedPoint2D<DevicePixel, f32>),
|
||||||
MouseWindowMouseDownEvent(uint, TypedPoint2D<DevicePixel, f32>),
|
MouseDown(uint, TypedPoint2D<DevicePixel, f32>),
|
||||||
MouseWindowMouseUpEvent(uint, TypedPoint2D<DevicePixel, f32>),
|
MouseUp(uint, TypedPoint2D<DevicePixel, f32>),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum WindowNavigateMsg {
|
pub enum WindowNavigateMsg {
|
||||||
|
|
|
@ -102,10 +102,10 @@ cef_class_impl! {
|
||||||
let point = TypedPoint2D((*event).x as f32, (*event).y as f32);
|
let point = TypedPoint2D((*event).x as f32, (*event).y as f32);
|
||||||
if mouse_up != 0 {
|
if mouse_up != 0 {
|
||||||
core::send_window_event(WindowEvent::MouseWindowEventClass(
|
core::send_window_event(WindowEvent::MouseWindowEventClass(
|
||||||
MouseWindowEvent::MouseWindowClickEvent(button_type, point)))
|
MouseWindowEvent::Click(button_type, point)))
|
||||||
} else {
|
} else {
|
||||||
core::send_window_event(WindowEvent::MouseWindowEventClass(
|
core::send_window_event(WindowEvent::MouseWindowEventClass(
|
||||||
MouseWindowEvent::MouseWindowMouseUpEvent(button_type, point)))
|
MouseWindowEvent::MouseUp(button_type, point)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,9 @@ use NestedEventLoopListener;
|
||||||
use compositing::compositor_task::{mod, CompositorProxy, CompositorReceiver};
|
use compositing::compositor_task::{mod, CompositorProxy, CompositorReceiver};
|
||||||
use compositing::windowing::{Forward, Back};
|
use compositing::windowing::{Forward, Back};
|
||||||
use compositing::windowing::{Idle, Resize};
|
use compositing::windowing::{Idle, Resize};
|
||||||
use compositing::windowing::{KeyEvent, MouseWindowClickEvent, MouseWindowMouseDownEvent};
|
use compositing::windowing::{KeyEvent, MouseWindowEvent};
|
||||||
use compositing::windowing::{MouseWindowEventClass, MouseWindowMoveEventClass};
|
use compositing::windowing::{MouseWindowEventClass, MouseWindowMoveEventClass};
|
||||||
use compositing::windowing::{MouseWindowMouseUpEvent, Refresh};
|
use compositing::windowing::Refresh;
|
||||||
use compositing::windowing::{Navigation, Scroll, Zoom};
|
use compositing::windowing::{Navigation, Scroll, Zoom};
|
||||||
use compositing::windowing::{PinchZoom, Quit};
|
use compositing::windowing::{PinchZoom, Quit};
|
||||||
use compositing::windowing::{WindowEvent, WindowMethods};
|
use compositing::windowing::{WindowEvent, WindowMethods};
|
||||||
|
@ -373,7 +373,7 @@ impl Window {
|
||||||
glfw::Press => {
|
glfw::Press => {
|
||||||
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(button as uint, TypedPoint2D(x as f32, y as f32))
|
MouseWindowEvent::MouseDown(button as uint, TypedPoint2D(x as f32, y as f32))
|
||||||
}
|
}
|
||||||
glfw::Release => {
|
glfw::Release => {
|
||||||
match self.mouse_down_button.get() {
|
match self.mouse_down_button.get() {
|
||||||
|
@ -383,15 +383,14 @@ impl Window {
|
||||||
let pixel_dist = ((pixel_dist.x * pixel_dist.x +
|
let pixel_dist = ((pixel_dist.x * pixel_dist.x +
|
||||||
pixel_dist.y * pixel_dist.y) as f64).sqrt();
|
pixel_dist.y * pixel_dist.y) as f64).sqrt();
|
||||||
if pixel_dist < max_pixel_dist {
|
if pixel_dist < max_pixel_dist {
|
||||||
let click_event = MouseWindowClickEvent(button as uint,
|
let click_event = MouseWindowEvent::Click(
|
||||||
TypedPoint2D(x as f32,
|
button as uint, TypedPoint2D(x as f32, y as f32));
|
||||||
y as f32));
|
|
||||||
self.event_queue.borrow_mut().push(MouseWindowEventClass(click_event));
|
self.event_queue.borrow_mut().push(MouseWindowEventClass(click_event));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(_) => (),
|
Some(_) => (),
|
||||||
}
|
}
|
||||||
MouseWindowMouseUpEvent(button as uint, TypedPoint2D(x as f32, y as f32))
|
MouseWindowEvent::MouseUp(button as uint, TypedPoint2D(x as f32, y as f32))
|
||||||
}
|
}
|
||||||
_ => panic!("I cannot recognize the type of mouse action that occured. :-(")
|
_ => panic!("I cannot recognize the type of mouse action that occured. :-(")
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,8 +9,7 @@ use compositing::windowing::{WindowEvent, WindowMethods, KeyEvent};
|
||||||
use compositing::windowing::{Idle, Resize};
|
use compositing::windowing::{Idle, Resize};
|
||||||
use compositing::windowing::{MouseWindowEventClass, MouseWindowMoveEventClass, Scroll};
|
use compositing::windowing::{MouseWindowEventClass, MouseWindowMoveEventClass, Scroll};
|
||||||
use compositing::windowing::{Zoom, PinchZoom, Navigation};
|
use compositing::windowing::{Zoom, PinchZoom, Navigation};
|
||||||
use compositing::windowing::{Quit, MouseWindowClickEvent};
|
use compositing::windowing::{Quit, MouseWindowEvent};
|
||||||
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};
|
||||||
use geom::scale_factor::ScaleFactor;
|
use geom::scale_factor::ScaleFactor;
|
||||||
|
@ -477,7 +476,7 @@ impl Window {
|
||||||
ElementState::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))
|
MouseWindowEvent::MouseDown(0, TypedPoint2D(x as f32, y as f32))
|
||||||
}
|
}
|
||||||
ElementState::Released => {
|
ElementState::Released => {
|
||||||
match self.mouse_down_button.get() {
|
match self.mouse_down_button.get() {
|
||||||
|
@ -487,15 +486,14 @@ impl Window {
|
||||||
let pixel_dist = ((pixel_dist.x * pixel_dist.x +
|
let pixel_dist = ((pixel_dist.x * pixel_dist.x +
|
||||||
pixel_dist.y * pixel_dist.y) as f64).sqrt();
|
pixel_dist.y * pixel_dist.y) as f64).sqrt();
|
||||||
if pixel_dist < max_pixel_dist {
|
if pixel_dist < max_pixel_dist {
|
||||||
let click_event = MouseWindowClickEvent(0,
|
let click_event = MouseWindowEvent::Click(
|
||||||
TypedPoint2D(x as f32,
|
0, TypedPoint2D(x as f32, y as f32));
|
||||||
y as f32));
|
|
||||||
self.event_queue.borrow_mut().push(MouseWindowEventClass(click_event));
|
self.event_queue.borrow_mut().push(MouseWindowEventClass(click_event));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(_) => (),
|
Some(_) => (),
|
||||||
}
|
}
|
||||||
MouseWindowMouseUpEvent(0, TypedPoint2D(x as f32, y as f32))
|
MouseWindowEvent::MouseUp(0, TypedPoint2D(x as f32, y as f32))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
self.event_queue.borrow_mut().push(MouseWindowEventClass(event));
|
self.event_queue.borrow_mut().push(MouseWindowEventClass(event));
|
||||||
|
|
|
@ -160,9 +160,9 @@ fn read_input_device(device_path: &Path,
|
||||||
if dist < 16 {
|
if dist < 16 {
|
||||||
let click_pt = TypedPoint2D(slotA.x as f32, slotA.y as f32);
|
let click_pt = TypedPoint2D(slotA.x as f32, slotA.y as f32);
|
||||||
println!("Dispatching click!");
|
println!("Dispatching click!");
|
||||||
sender.send(WindowEvent::MouseWindowEventClass(MouseWindowEvent::MouseWindowMouseDownEvent(0, click_pt)));
|
sender.send(WindowEvent::MouseWindowEventClass(MouseWindowEvent::MouseDown(0, click_pt)));
|
||||||
sender.send(WindowEvent::MouseWindowEventClass(MouseWindowEvent::MouseWindowMouseUpEvent(0, click_pt)));
|
sender.send(WindowEvent::MouseWindowEventClass(MouseWindowEvent::MouseUp(0, click_pt)));
|
||||||
sender.send(WindowEvent::MouseWindowEventClass(MouseWindowEvent::MouseWindowClickEvent(0, click_pt)));
|
sender.send(WindowEvent::MouseWindowEventClass(MouseWindowEvent::Click(0, click_pt)));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
println!("Touch down");
|
println!("Touch down");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue