From 4ee34fe43a1a960f9a806faae2c65d5f0643c412 Mon Sep 17 00:00:00 2001 From: Drakulix Date: Tue, 13 Mar 2018 17:53:10 +0100 Subject: [PATCH] Fix winit transformed input for negative positions --- src/backend/winit.rs | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/backend/winit.rs b/src/backend/winit.rs index f5f0d04..ccf3acd 100644 --- a/src/backend/winit.rs +++ b/src/backend/winit.rs @@ -360,21 +360,27 @@ impl PointerMotionAbsoluteEvent for WinitMouseMovedEvent { } fn x_transformed(&self, width: u32) -> u32 { - (self.x * width as f64 - / self.window - .window() - .get_inner_size() - .unwrap_or((width, 0)) - .0 as f64) as u32 + cmp::max( + (self.x * width as f64 + / self.window + .window() + .get_inner_size() + .unwrap_or((width, 0)) + .0 as f64) as i32, + 0, + ) as u32 } fn y_transformed(&self, height: u32) -> u32 { - (self.y * height as f64 - / self.window - .window() - .get_inner_size() - .unwrap_or((0, height)) - .1 as f64) as u32 + cmp::max( + (self.y * height as f64 + / self.window + .window() + .get_inner_size() + .unwrap_or((0, height)) + .1 as f64) as i32, + 0, + ) as u32 } }