diff --git a/Cargo.lock b/Cargo.lock index a3aad805..9566efb7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2440,7 +2440,7 @@ dependencies = [ "serde_json", "vst3-sys", "widestring", - "windows 0.32.0", + "windows 0.44.0", "zstd", ] @@ -4575,19 +4575,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbedf6db9096bc2364adce0ae0aa636dcd89f3c3f2cd67947062aaf0ca2a10ec" -dependencies = [ - "windows_aarch64_msvc 0.32.0", - "windows_i686_gnu 0.32.0", - "windows_i686_msvc 0.32.0", - "windows_x86_64_gnu 0.32.0", - "windows_x86_64_msvc 0.32.0", -] - [[package]] name = "windows" version = "0.37.0" @@ -4670,12 +4657,6 @@ version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" -[[package]] -name = "windows_aarch64_msvc" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8e92753b1c443191654ec532f14c199742964a061be25d77d7a96f09db20bf5" - [[package]] name = "windows_aarch64_msvc" version = "0.37.0" @@ -4688,12 +4669,6 @@ version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" -[[package]] -name = "windows_i686_gnu" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a711c68811799e017b6038e0922cb27a5e2f43a2ddb609fe0b6f3eeda9de615" - [[package]] name = "windows_i686_gnu" version = "0.37.0" @@ -4706,12 +4681,6 @@ version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" -[[package]] -name = "windows_i686_msvc" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "146c11bb1a02615db74680b32a68e2d61f553cc24c4eb5b4ca10311740e44172" - [[package]] name = "windows_i686_msvc" version = "0.37.0" @@ -4724,12 +4693,6 @@ version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" -[[package]] -name = "windows_x86_64_gnu" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c912b12f7454c6620635bbff3450962753834be2a594819bd5e945af18ec64bc" - [[package]] name = "windows_x86_64_gnu" version = "0.37.0" @@ -4748,12 +4711,6 @@ version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" -[[package]] -name = "windows_x86_64_msvc" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "504a2476202769977a040c6364301a3f65d0cc9e3fb08600b2bda150a0488316" - [[package]] name = "windows_x86_64_msvc" version = "0.37.0" diff --git a/Cargo.toml b/Cargo.toml index fd44c13e..cbe09a3f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -125,7 +125,7 @@ objc = "0.2.7" core-foundation = "0.9.3" [target.'cfg(target_os = "windows")'.dependencies.windows] -version = "0.32" +version = "0.44" features = [ "Win32_Foundation", "Win32_Graphics_Gdi", diff --git a/src/event_loop/windows.rs b/src/event_loop/windows.rs index 7b1e8d66..61e0d4dd 100644 --- a/src/event_loop/windows.rs +++ b/src/event_loop/windows.rs @@ -7,7 +7,8 @@ use std::mem; use std::ptr; use std::sync::Weak; use std::thread::{self, ThreadId}; -use windows::Win32::Foundation::{HINSTANCE, HWND, LPARAM, LRESULT, PSTR, WPARAM}; +use windows::core::PCSTR; +use windows::Win32::Foundation::{HINSTANCE, HWND, LPARAM, LRESULT, WPARAM}; use windows::Win32::System::{ LibraryLoader::GetModuleHandleA, Performance::QueryPerformanceCounter, }; @@ -72,12 +73,13 @@ where assert!(unsafe { QueryPerformanceCounter(&mut ticks).as_bool() }); let class_name = CString::new(format!("nih-event-loop-{ticks}")) .expect("Where did these null bytes come from?"); - let class_name_ptr = PSTR(class_name.as_bytes_with_nul().as_ptr()); + let class_name_ptr = PCSTR(class_name.as_bytes_with_nul().as_ptr()); let class = WNDCLASSEXA { cbSize: mem::size_of::() as u32, lpfnWndProc: Some(window_proc), - hInstance: unsafe { GetModuleHandleA(PSTR(ptr::null())) }, + hInstance: unsafe { GetModuleHandleA(PCSTR(ptr::null())) } + .expect("Could not get the current module's handle"), lpszClassName: class_name_ptr, ..Default::default() }; @@ -107,7 +109,7 @@ where CreateWindowExA( WINDOW_EX_STYLE(0), class_name_ptr, - PSTR(b"NIH-plug event loop\0".as_ptr()), + PCSTR(b"NIH-plug event loop\0".as_ptr()), WINDOW_STYLE(0), 0, 0, @@ -119,10 +121,10 @@ where // NOTE: We're boxing a box here. As mentioned in [PollCallback], we can't directly // pass around fat pointers, so we need a normal pointer to a fat pointer to // be able to call this and deallocate it later - Box::into_raw(Box::new(callback)) as *const c_void, + Some(Box::into_raw(Box::new(callback)) as *const c_void), ) }; - assert!(!window.is_invalid()); + assert_ne!(!window.0, 0); Self { executor: executor.clone(), @@ -174,7 +176,7 @@ impl Drop for WindowsEventLoop { unsafe { DestroyWindow(self.message_window) }; unsafe { UnregisterClassA( - PSTR(self.message_window_class_name.as_bytes_with_nul().as_ptr()), + PCSTR(self.message_window_class_name.as_bytes_with_nul().as_ptr()), HINSTANCE(0), ) };