mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Implement WheelEvent Interface
Note: The WheelEvent interface supports rotation in all 3 spatial dimensions. This implementation only supports two due to limitations in the Glutin compositor. The wheelevent interface is a dom interface that triggers for any attached device that can rotate in one or more spatial dimensions. Traditionally this is the mouse wheel though other devices could be used as well. E.g. the trackball on a trackball mouse.
This commit is contained in:
parent
8f11b52d9a
commit
35bca991ad
16 changed files with 347 additions and 146 deletions
|
@ -462,6 +462,30 @@ pub enum MouseEventType {
|
|||
MouseUp,
|
||||
}
|
||||
|
||||
/// Mode to measure WheelDelta floats in
|
||||
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
|
||||
pub enum WheelMode {
|
||||
/// Delta values are specified in pixels
|
||||
DeltaPixel = 0x00,
|
||||
/// Delta values are specified in lines
|
||||
DeltaLine = 0x01,
|
||||
/// Delta values are specified in pages
|
||||
DeltaPage = 0x02,
|
||||
}
|
||||
|
||||
/// The Wheel event deltas in every direction
|
||||
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
|
||||
pub struct WheelDelta {
|
||||
/// Delta in the left/right direction
|
||||
pub x: f64,
|
||||
/// Delta in the up/down direction
|
||||
pub y: f64,
|
||||
/// Delta in the direction going into/out of the screen
|
||||
pub z: f64,
|
||||
/// Mode to measure the floats in
|
||||
pub mode: WheelMode,
|
||||
}
|
||||
|
||||
/// Events from the compositor that the script thread needs to know about
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub enum CompositorEvent {
|
||||
|
@ -491,6 +515,8 @@ pub enum CompositorEvent {
|
|||
Point2D<f32>,
|
||||
Option<UntrustedNodeAddress>,
|
||||
),
|
||||
/// A wheel event was generated with a delta in the X, Y, and/or Z directions
|
||||
WheelEvent(WheelDelta, Point2D<f32>, Option<UntrustedNodeAddress>),
|
||||
/// A key was pressed.
|
||||
KeyboardEvent(KeyboardEvent),
|
||||
/// An event from the IME is dispatched.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue