Merge pull request #81 from Smithay/fix/winit_negative_pointer

Fix winit transformed input for negative positions
This commit is contained in:
Victor Brekenfeld 2018-03-17 18:14:48 +01:00 committed by GitHub
commit 79d99c1cc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 12 deletions

View File

@ -360,21 +360,27 @@ impl PointerMotionAbsoluteEvent for WinitMouseMovedEvent {
} }
fn x_transformed(&self, width: u32) -> u32 { fn x_transformed(&self, width: u32) -> u32 {
(self.x * width as f64 cmp::max(
/ self.window (self.x * width as f64
.window() / self.window
.get_inner_size() .window()
.unwrap_or((width, 0)) .get_inner_size()
.0 as f64) as u32 .unwrap_or((width, 0))
.0 as f64) as i32,
0,
) as u32
} }
fn y_transformed(&self, height: u32) -> u32 { fn y_transformed(&self, height: u32) -> u32 {
(self.y * height as f64 cmp::max(
/ self.window (self.y * height as f64
.window() / self.window
.get_inner_size() .window()
.unwrap_or((0, height)) .get_inner_size()
.1 as f64) as u32 .unwrap_or((0, height))
.1 as f64) as i32,
0,
) as u32
} }
} }