diff --git a/Cargo.lock b/Cargo.lock index d80dea7..831723a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -77,43 +77,57 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "windows" -version = "0.39.0" +version = "0.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1c4bd0a50ac6020f65184721f758dba47bb9fbc2133df715ec74a237b26794a" +checksum = "5a3ed69de2c1f8d0524a8a3417a80a85dd316a071745fbfdf5eb028b310058ab" dependencies = [ + "windows_aarch64_gnullvm", "windows_aarch64_msvc", "windows_i686_gnu", "windows_i686_msvc", "windows_x86_64_gnu", + "windows_x86_64_gnullvm", "windows_x86_64_msvc", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "163d2761774f2278ecb4e6719e80b2b5e92e5a2be73a7bcd3ef624dd5e3091fd" + [[package]] name = "windows_aarch64_msvc" -version = "0.39.0" +version = "0.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec7711666096bd4096ffa835238905bb33fb87267910e154b18b44eaabb340f2" +checksum = "ef005ff2bceb00d3b84166a359cc19084f9459754fd3fe5a504dee3dddcd0a0c" [[package]] name = "windows_i686_gnu" -version = "0.39.0" +version = "0.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "763fc57100a5f7042e3057e7e8d9bdd7860d330070251a73d003563a3bb49e1b" +checksum = "02b4df2d51e32f03f8b4b228e487828c03bcb36d97b216fc5463bcea5bb1440b" [[package]] name = "windows_i686_msvc" -version = "0.39.0" +version = "0.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bc7cbfe58828921e10a9f446fcaaf649204dcfe6c1ddd712c5eebae6bda1106" +checksum = "568a966834571f2f3267f07dd72b4d8507381f25e53d056808483b2637385ef7" [[package]] name = "windows_x86_64_gnu" -version = "0.39.0" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc395dac1adf444e276d096d933ae7961361c8cda3245cffef7a9b3a70a8f994" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6868c165637d653ae1e8dc4d82c25d4f97dd6605eaa8d784b5c6e0ab2a252b65" +checksum = "90e8ec22b715d5b436e1d59c8adad6c744dc20cd984710121d5836b4e8dbb5e0" [[package]] name = "windows_x86_64_msvc" -version = "0.39.0" +version = "0.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e4d40883ae9cae962787ca76ba76390ffa29214667a111db9e0a1ad8377e809" +checksum = "8b9761f0216b669019df1512f6e25e5ee779bf61c5cdc43c7293858e7efd7926" diff --git a/Cargo.toml b/Cargo.toml index b85bc68..69f8015 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ edition = "2021" rand = "0.8.5" [dependencies.windows] -version = "0.39.0" +version = "0.41.0" features = [ "Foundation_Collections", "Foundation_Numerics", diff --git a/src/window.rs b/src/window.rs index b58f38f..e952ba9 100644 --- a/src/window.rs +++ b/src/window.rs @@ -8,9 +8,9 @@ use windows::{ Foundation::{HINSTANCE, HWND, LPARAM, LRESULT, RECT, WPARAM}, System::{LibraryLoader::GetModuleHandleW, WinRT::Composition::ICompositorDesktopInterop}, UI::WindowsAndMessaging::{ - AdjustWindowRectEx, CreateWindowExW, DefWindowProcW, GetClientRect, LoadCursorW, - PostQuitMessage, RegisterClassW, ShowWindow, CREATESTRUCTW, CW_USEDEFAULT, - GWLP_USERDATA, HMENU, IDC_ARROW, SW_SHOW, WINDOW_LONG_PTR_INDEX, WM_DESTROY, + AdjustWindowRectEx, CreateWindowExW, DefWindowProcW, GetClientRect, GetWindowLongPtrW, + LoadCursorW, PostQuitMessage, RegisterClassW, SetWindowLongPtrW, ShowWindow, + CREATESTRUCTW, CW_USEDEFAULT, GWLP_USERDATA, HMENU, IDC_ARROW, SW_SHOW, WM_DESTROY, WM_LBUTTONDOWN, WM_MOUSEMOVE, WM_NCCREATE, WM_RBUTTONDOWN, WM_SIZE, WM_SIZING, WNDCLASSW, WS_EX_NOREDIRECTIONBITMAP, WS_OVERLAPPEDWINDOW, }, @@ -78,7 +78,7 @@ impl Window { HWND(0), HMENU(0), instance, - result.as_mut() as *mut _ as _, + Some(result.as_mut() as *mut _ as _), ) .ok()? }; @@ -148,9 +148,9 @@ impl Window { let this = (*cs).lpCreateParams as *mut Self; (*this).handle = window; - SetWindowLong(window, GWLP_USERDATA, this as _); + SetWindowLongPtrW(window, GWLP_USERDATA, this as _); } else { - let this = GetWindowLong(window, GWLP_USERDATA) as *mut Self; + let this = GetWindowLongPtrW(window, GWLP_USERDATA) as *mut Self; if let Some(this) = this.as_mut() { return this.message_handler(message, wparam, lparam); @@ -178,35 +178,3 @@ fn get_mouse_position(lparam: LPARAM) -> (isize, isize) { let y = (lparam.0 >> 16) & 0xffff; (x, y) } - -#[allow(non_snake_case)] -#[cfg(target_pointer_width = "32")] -unsafe fn SetWindowLong(window: HWND, index: WINDOW_LONG_PTR_INDEX, value: isize) -> isize { - use windows::Win32::UI::WindowsAndMessaging::SetWindowLongW; - - SetWindowLongW(window, index, value as _) as _ -} - -#[allow(non_snake_case)] -#[cfg(target_pointer_width = "64")] -unsafe fn SetWindowLong(window: HWND, index: WINDOW_LONG_PTR_INDEX, value: isize) -> isize { - use windows::Win32::UI::WindowsAndMessaging::SetWindowLongPtrW; - - SetWindowLongPtrW(window, index, value) -} - -#[allow(non_snake_case)] -#[cfg(target_pointer_width = "32")] -unsafe fn GetWindowLong(window: HWND, index: WINDOW_LONG_PTR_INDEX) -> isize { - use windows::Win32::UI::WindowsAndMessaging::SetWindowLongW; - - GetWindowLongW(window, index) as _ -} - -#[allow(non_snake_case)] -#[cfg(target_pointer_width = "64")] -unsafe fn GetWindowLong(window: HWND, index: WINDOW_LONG_PTR_INDEX) -> isize { - use windows::Win32::UI::WindowsAndMessaging::GetWindowLongPtrW; - - GetWindowLongPtrW(window, index) -}