Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update windows crate to 0.41 #50

Merged
merged 1 commit into from Sep 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 26 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -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",
Expand Down
44 changes: 6 additions & 38 deletions src/window.rs
Expand Up @@ -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,
},
Expand Down Expand Up @@ -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()?
};
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
}