mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
libservo: Allow embedders to signal when the cursor has left the WebView
(#37317)
Currently, the hover state will stay when the mouse moves out of the webview, this PR fixes it Testing: Hover on the `About` on servo.org, and then move the mouse up to the browser UI, see the hover state resets Signed-off-by: Tony <legendmastertony@gmail.com>
This commit is contained in:
parent
0896341285
commit
b9fcc95992
7 changed files with 125 additions and 27 deletions
|
@ -20,6 +20,7 @@ pub enum InputEvent {
|
|||
Keyboard(KeyboardEvent),
|
||||
MouseButton(MouseButtonEvent),
|
||||
MouseMove(MouseMoveEvent),
|
||||
MouseLeave(MouseLeaveEvent),
|
||||
Touch(TouchEvent),
|
||||
Wheel(WheelEvent),
|
||||
Scroll(ScrollEvent),
|
||||
|
@ -42,6 +43,7 @@ impl InputEvent {
|
|||
InputEvent::Keyboard(..) => None,
|
||||
InputEvent::MouseButton(event) => Some(event.point),
|
||||
InputEvent::MouseMove(event) => Some(event.point),
|
||||
InputEvent::MouseLeave(event) => Some(event.point),
|
||||
InputEvent::Touch(event) => Some(event.point),
|
||||
InputEvent::Wheel(event) => Some(event.point),
|
||||
InputEvent::Scroll(..) => None,
|
||||
|
@ -56,6 +58,7 @@ impl InputEvent {
|
|||
InputEvent::Keyboard(event) => event.webdriver_id,
|
||||
InputEvent::MouseButton(event) => event.webdriver_id,
|
||||
InputEvent::MouseMove(event) => event.webdriver_id,
|
||||
InputEvent::MouseLeave(..) => None,
|
||||
InputEvent::Touch(..) => None,
|
||||
InputEvent::Wheel(event) => event.webdriver_id,
|
||||
InputEvent::Scroll(..) => None,
|
||||
|
@ -76,6 +79,7 @@ impl InputEvent {
|
|||
InputEvent::MouseMove(ref mut event) => {
|
||||
event.webdriver_id = webdriver_id;
|
||||
},
|
||||
InputEvent::MouseLeave(..) => {},
|
||||
InputEvent::Touch(..) => {},
|
||||
InputEvent::Wheel(ref mut event) => {
|
||||
event.webdriver_id = webdriver_id;
|
||||
|
@ -214,6 +218,17 @@ impl MouseMoveEvent {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
|
||||
pub struct MouseLeaveEvent {
|
||||
pub point: DevicePoint,
|
||||
}
|
||||
|
||||
impl MouseLeaveEvent {
|
||||
pub fn new(point: DevicePoint) -> Self {
|
||||
Self { point }
|
||||
}
|
||||
}
|
||||
|
||||
/// The type of input represented by a multi-touch event.
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
|
||||
pub enum TouchEventType {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue