From 72f89ba77f45e5345ef863d5e75b99895419f583 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 25 Aug 2020 01:39:54 +0200 Subject: Fix cursor position after a `CursorLeft` event --- winit/src/application.rs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'winit/src/application.rs') diff --git a/winit/src/application.rs b/winit/src/application.rs index 1fa282a1..73dad398 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -148,6 +148,7 @@ pub fn run( .expect("Open window"); let clipboard = Clipboard::new(&window); + // TODO: Encode cursor availability in the type-system let mut cursor_position = winit::dpi::PhysicalPosition::new(-1.0, -1.0); let mut mouse_interaction = mouse::Interaction::default(); let mut modifiers = winit::event::ModifiersState::default(); @@ -378,6 +379,10 @@ pub fn handle_window_event( WindowEvent::CursorMoved { position, .. } => { *cursor_position = *position; } + WindowEvent::CursorLeft { .. } => { + // TODO: Encode cursor availability in the type-system + *cursor_position = winit::dpi::PhysicalPosition::new(-1.0, -1.0); + } WindowEvent::ModifiersChanged(new_modifiers) => { *modifiers = *new_modifiers; } -- cgit