fix unnecessary cast lint (#2596)

* fix clippy lints on Windows

* fix lints on other platforms

* a couple more

* again

* don't know what's goging on anymore

* fix examples

* comon

* how about now?

* this is getting annoying

* hmmm

* explicitly set a type

* 😢

* don't cast on x64 targets

* apply code review requests

* fix attributes on expressions

* fix ios
This commit is contained in:
Amr Bashir 2022-12-22 21:35:33 +02:00 committed by GitHub
parent da7422c6e1
commit 402cbd55f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 63 additions and 64 deletions

View file

@ -57,7 +57,7 @@ impl<T: 'static> EventProcessor<T> {
F: Fn(&Arc<UnownedWindow>) -> Ret,
{
let mut deleted = false;
let window_id = WindowId(window_id as u64);
let window_id = WindowId(window_id as _);
let wt = get_xtarget(&self.target);
let result = wt
.windows
@ -347,7 +347,7 @@ impl<T: 'static> EventProcessor<T> {
// These are both in physical space.
let new_inner_size = (xev.width as u32, xev.height as u32);
let new_inner_position = (xev.x as i32, xev.y as i32);
let new_inner_position = (xev.x, xev.y);
let (mut resized, moved) = {
let mut shared_state_lock = window.shared_state_lock();
@ -520,7 +520,7 @@ impl<T: 'static> EventProcessor<T> {
// In the event that the window's been destroyed without being dropped first, we
// cleanup again here.
wt.windows.borrow_mut().remove(&WindowId(window as u64));
wt.windows.borrow_mut().remove(&WindowId(window as _));
// Since all XIM stuff needs to happen from the same thread, we destroy the input
// context here instead of when dropping the window.
@ -1021,8 +1021,7 @@ impl<T: 'static> EventProcessor<T> {
if self.window_exists(xev.event) {
let id = xev.detail as u64;
let modifiers = self.device_mod_state.modifiers();
let location =
PhysicalPosition::new(xev.event_x as f64, xev.event_y as f64);
let location = PhysicalPosition::new(xev.event_x, xev.event_y);
// Mouse cursor position changes when touch events are received.
// Only the first concurrently active touch ID moves the mouse cursor.

View file

@ -711,7 +711,7 @@ struct XExtension {
}
fn mkwid(w: ffi::Window) -> crate::window::WindowId {
crate::window::WindowId(crate::platform_impl::platform::WindowId(w as u64))
crate::window::WindowId(crate::platform_impl::platform::WindowId(w as _))
}
fn mkdid(w: c_int) -> crate::event::DeviceId {
crate::event::DeviceId(crate::platform_impl::DeviceId::X(DeviceId(w)))

View file

@ -108,6 +108,7 @@ impl std::hash::Hash for MonitorHandle {
#[inline]
pub fn mode_refresh_rate_millihertz(mode: &XRRModeInfo) -> Option<u32> {
if mode.dotClock > 0 && mode.hTotal > 0 && mode.vTotal > 0 {
#[allow(clippy::unnecessary_cast)]
Some((mode.dotClock as u64 * 1000 / (mode.hTotal as u64 * mode.vTotal as u64)) as u32)
} else {
None
@ -123,8 +124,8 @@ impl MonitorHandle {
primary: bool,
) -> Option<Self> {
let (name, scale_factor, video_modes) = unsafe { xconn.get_output_info(resources, crtc)? };
let dimensions = unsafe { ((*crtc).width as u32, (*crtc).height as u32) };
let position = unsafe { ((*crtc).x as i32, (*crtc).y as i32) };
let dimensions = unsafe { ((*crtc).width, (*crtc).height) };
let position = unsafe { ((*crtc).x, (*crtc).y) };
// Get the refresh rate of the current video mode.
let current_mode = unsafe { (*crtc).mode };
@ -175,7 +176,7 @@ impl MonitorHandle {
#[inline]
pub fn native_identifier(&self) -> u32 {
self.id as u32
self.id as _
}
pub fn size(&self) -> PhysicalSize<u32> {

View file

@ -129,12 +129,12 @@ impl FrameExtentsHeuristic {
width.saturating_add(
self.frame_extents
.left
.saturating_add(self.frame_extents.right) as u32,
.saturating_add(self.frame_extents.right) as _,
),
height.saturating_add(
self.frame_extents
.top
.saturating_add(self.frame_extents.bottom) as u32,
.saturating_add(self.frame_extents.bottom) as _,
),
)
}

View file

@ -198,7 +198,7 @@ impl<'a> NormalHints<'a> {
pub fn get_position(&self) -> Option<(i32, i32)> {
has_flag(self.size_hints.flags, ffi::PPosition)
.then(|| (self.size_hints.x as i32, self.size_hints.y as i32))
.then(|| (self.size_hints.x, self.size_hints.y))
}
pub fn get_resize_increments(&self) -> Option<(u32, u32)> {

View file

@ -126,11 +126,8 @@ impl XConnection {
let scale_factor = match dpi_env {
EnvVarDPI::Randr => calc_dpi_factor(
((*crtc).width as u32, (*crtc).height as u32),
(
(*output_info).mm_width as u64,
(*output_info).mm_height as u64,
),
((*crtc).width, (*crtc).height),
((*output_info).mm_width as _, (*output_info).mm_height as _),
),
EnvVarDPI::Scale(dpi_override) => {
if !validate_scale_factor(dpi_override) {
@ -146,11 +143,8 @@ impl XConnection {
dpi / 96.
} else {
calc_dpi_factor(
((*crtc).width as u32, (*crtc).height as u32),
(
(*output_info).mm_width as u64,
(*output_info).mm_height as u64,
),
((*crtc).width, (*crtc).height),
((*output_info).mm_width as _, (*output_info).mm_height as _),
)
}
}

View file

@ -1551,14 +1551,14 @@ impl UnownedWindow {
#[inline]
pub fn id(&self) -> WindowId {
WindowId(self.xwindow as u64)
WindowId(self.xwindow as _)
}
#[inline]
pub fn request_redraw(&self) {
self.redraw_sender
.sender
.send(WindowId(self.xwindow as u64))
.send(WindowId(self.xwindow as _))
.unwrap();
self.redraw_sender.waker.wake().unwrap();
}