mirror of
https://github.com/servo/servo.git
synced 2025-08-28 16:48:22 +01:00
forcetouch events support
This enables Apple forcetouch DOM events. It requires the preference dom.forcetouch.enabled. The DOM events are described here: - https://developer.apple.com/library/mac/documentation/AppleApplications/Conceptual/SafariJSProgTopics/RespondingtoForceTouchEventsfromJavaScript.html The Cocoa mechanism is documented here: - https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSEvent_Class/#//apple_ref/doc/uid/20000016-SW274
This commit is contained in:
parent
05a4dcdc3b
commit
df6e7394d4
13 changed files with 245 additions and 8 deletions
|
@ -20,7 +20,7 @@ use layers::platform::surface::NativeDisplay;
|
|||
use msg::constellation_msg::{KeyState, NONE, CONTROL, SHIFT, ALT, SUPER};
|
||||
use msg::constellation_msg::{self, Key};
|
||||
use net_traits::net_error_list::NetError;
|
||||
use script_traits::TouchEventType;
|
||||
use script_traits::{TouchEventType, TouchpadPressurePhase};
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::os::raw::c_void;
|
||||
use std::rc::Rc;
|
||||
|
@ -241,6 +241,12 @@ impl Window {
|
|||
let point = Point2D::typed(touch.location.0 as f32, touch.location.1 as f32);
|
||||
self.event_queue.borrow_mut().push(WindowEvent::Touch(phase, id, point));
|
||||
}
|
||||
Event::TouchpadPressure(pressure, stage) => {
|
||||
let m = self.mouse_pos.get();
|
||||
let point = Point2D::typed(m.x as f32, m.y as f32);
|
||||
let phase = glutin_pressure_stage_to_touchpad_pressure_phase(stage);
|
||||
self.event_queue.borrow_mut().push(WindowEvent::TouchpadPressure(point, pressure, phase));
|
||||
}
|
||||
Event::Refresh => {
|
||||
self.event_queue.borrow_mut().push(WindowEvent::Refresh);
|
||||
}
|
||||
|
@ -812,6 +818,16 @@ fn glutin_phase_to_touch_event_type(phase: TouchPhase) -> TouchEventType {
|
|||
}
|
||||
}
|
||||
|
||||
fn glutin_pressure_stage_to_touchpad_pressure_phase(stage: i64) -> TouchpadPressurePhase {
|
||||
if stage < 1 {
|
||||
TouchpadPressurePhase::BeforeClick
|
||||
} else if stage < 2 {
|
||||
TouchpadPressurePhase::AfterFirstClick
|
||||
} else {
|
||||
TouchpadPressurePhase::AfterSecondClick
|
||||
}
|
||||
}
|
||||
|
||||
// These functions aren't actually called. They are here as a link
|
||||
// hack because Skia references them.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue