Remove excess type conversions

This commit is contained in:
Sergey Smirnykh 2020-03-21 21:22:06 +07:00 committed by Victor Berger
parent 9e1bce7c66
commit 3bc1c728a8
1 changed files with 8 additions and 8 deletions

View File

@ -509,18 +509,18 @@ impl TouchDownEvent for WinitTouchStartedEvent {
fn x_transformed(&self, width: u32) -> u32 { fn x_transformed(&self, width: u32) -> u32 {
let wsize = self.size.borrow(); let wsize = self.size.borrow();
let w_width = wsize.physical_size.to_logical::<f64>(wsize.scale_factor).width; let w_width = wsize.physical_size.to_logical::<i32>(wsize.scale_factor).width;
cmp::min( cmp::min(
self.location.0 as i32 * width as i32 / w_width as i32, self.location.0 as i32 * width as i32 / w_width,
0, 0,
) as u32 ) as u32
} }
fn y_transformed(&self, height: u32) -> u32 { fn y_transformed(&self, height: u32) -> u32 {
let wsize = self.size.borrow(); let wsize = self.size.borrow();
let w_height = wsize.physical_size.to_logical::<f64>(wsize.scale_factor).height; let w_height = wsize.physical_size.to_logical::<i32>(wsize.scale_factor).height;
cmp::min( cmp::min(
self.location.1 as i32 * height as i32 / w_height as i32, self.location.1 as i32 * height as i32 / w_height,
0, 0,
) as u32 ) as u32
} }
@ -558,14 +558,14 @@ impl TouchMotionEvent for WinitTouchMovedEvent {
fn x_transformed(&self, width: u32) -> u32 { fn x_transformed(&self, width: u32) -> u32 {
let wsize = self.size.borrow(); let wsize = self.size.borrow();
let w_width = wsize.physical_size.to_logical::<f64>(wsize.scale_factor).width; let w_width = wsize.physical_size.to_logical::<u32>(wsize.scale_factor).width;
self.location.0 as u32 * width / w_width as u32 self.location.0 as u32 * width / w_width
} }
fn y_transformed(&self, height: u32) -> u32 { fn y_transformed(&self, height: u32) -> u32 {
let wsize = self.size.borrow(); let wsize = self.size.borrow();
let w_height = wsize.physical_size.to_logical::<f64>(wsize.scale_factor).height; let w_height = wsize.physical_size.to_logical::<u32>(wsize.scale_factor).height;
self.location.1 as u32 * height / w_height as u32 self.location.1 as u32 * height / w_height
} }
} }