diff --git a/rust-toolchain b/rust-toolchain index 9006c0b..837f16a 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.70.0 \ No newline at end of file +1.73.0 \ No newline at end of file diff --git a/src/platform/pnp_detect_libusb.rs b/src/platform/pnp_detect_libusb.rs index 424d05a..ec559d3 100644 --- a/src/platform/pnp_detect_libusb.rs +++ b/src/platform/pnp_detect_libusb.rs @@ -28,8 +28,8 @@ impl rusb::Hotplug for PnPDetectLibusb { } impl PnPDetectLibusb { - pub fn new(callback: Box) -> Self { - PnPDetectLibusb { callback } + pub fn new(callback: Box) -> Box { + Box::new(PnPDetectLibusb { callback }) } pub fn detect(self) -> Result<()> { diff --git a/src/platform/pnp_detect_windows.rs b/src/platform/pnp_detect_windows.rs index baad0eb..0e5dd2e 100644 --- a/src/platform/pnp_detect_windows.rs +++ b/src/platform/pnp_detect_windows.rs @@ -29,12 +29,12 @@ pub struct PnPDetectWindows { } impl PnPDetectWindows { - pub fn new(callback: Box) -> Self { - let mut pnp_detect = Self { + pub fn new(callback: Box) -> Box { + let mut pnp_detect = Box::new(Self { callback, current_devices: Self::read_device_list().unwrap_or_default(), hwnd: std::ptr::null_mut(), - }; + }); pnp_detect.create_window(); return pnp_detect; } @@ -95,8 +95,8 @@ impl PnPDetectWindows { PostQuitMessage(0); } WM_DEVICECHANGE => { - let self_ptr = GetWindowLongPtrW(hwnd, GWLP_USERDATA) as *mut Self; - let window_state: &mut Self = self_ptr.as_mut().unwrap(); + let self_ptr = GetWindowLongPtrW(hwnd, GWLP_USERDATA); + let window_state: &mut Self = &mut *(self_ptr as *mut Self); window_state.handle_hotplug_event(); } _ => return DefWindowProcW(hwnd, msg, wparam, lparam), @@ -146,8 +146,7 @@ impl PnPDetectWindows { std::ptr::null_mut(), std::ptr::null_mut(), hinstance, - self as *mut Self as *mut winapi::ctypes::c_void, - //std::ptr::null_mut(), + self as *mut _ as *mut _, ) }; diff --git a/src/platform/wake_displays.rs b/src/platform/wake_displays.rs index 97b743d..9009f27 100644 --- a/src/platform/wake_displays.rs +++ b/src/platform/wake_displays.rs @@ -43,9 +43,9 @@ pub fn wake_displays() -> Result<()> { use std::{thread, time}; use uinput::event::controller::Controller::Mouse; use uinput::event::controller::Mouse::Left; - use uinput::event::Event::{Controller, Relative}; use uinput::event::relative::Position::X; use uinput::event::relative::Relative::Position; + use uinput::event::Event::{Controller, Relative}; let mut device = uinput::default()? .name("display-switch")? @@ -54,7 +54,6 @@ pub fn wake_displays() -> Result<()> { .event(Relative(Position(X)))? .create()?; - // This sleep appears to be necessary based on testing. // Possibly X does not immediately recognize the new device? thread::sleep(time::Duration::from_secs(1)); @@ -75,7 +74,11 @@ mod tests { fn test_wake_displays() { let waked = wake_displays(); if let Err(err) = &waked { - assert!(err.to_string() == "Permission denied", "Couldn't wake displays: {:?}", err); + assert!( + err.to_string() == "Permission denied", + "Couldn't wake displays: {:?}", + err + ); } } }