Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
`windows-sys` has some breaking changes that required fixing
  • Loading branch information
timokroeger committed Nov 18, 2024
1 parent 7316648 commit 24aa6e6
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 69 deletions.
112 changes: 56 additions & 56 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ repository = "https://github.com/timokroeger/kbremap"
anyhow = "1.0"
encode_unicode = "1.0"
serde = { version = "1.0", features = ["derive"] }
thiserror = "1.0.61"
thiserror = "2.0"
toml = "0.8.12"
windows-sys = { version = "0.52.0", features = [
windows-sys = { version = "0.59.0", features = [
"Win32_Foundation",
"Win32_Graphics_Gdi",
"Win32_Security",
Expand All @@ -27,7 +27,7 @@ windows-sys = { version = "0.52.0", features = [
"Win32_UI_TextServices",
"Win32_UI_WindowsAndMessaging",
] }
winmsg-executor = "0.1.0"
winmsg-executor = "0.1.1"

[build-dependencies]
winresource = { version = "0.1.15", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion src/winapi/icon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl Icon {
LR_DEFAULTSIZE,
)
};
assert_ne!(hicon, 0, "icon resource {} not found", id);
assert!(!hicon.is_null(), "icon resource {} not found", id);
Self(hicon)
}
}
Expand Down
16 changes: 10 additions & 6 deletions src/winapi/keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@ where
let mut callback = Box::new(callback);
HOOK.set(&mut *callback as *mut F as usize);

let handle = unsafe { SetWindowsHookExA(WH_KEYBOARD_LL, Some(hook_proc::<F>), 0, 0) };
assert_ne!(handle, 0, "Failed to install low-level keyboard hook.");
let handle =
unsafe { SetWindowsHookExA(WH_KEYBOARD_LL, Some(hook_proc::<F>), ptr::null_mut(), 0) };
assert!(
!handle.is_null(),
"Failed to install low-level keyboard hook."
);
KeyboardHook {
handle,
_hook_proc: callback,
Expand Down Expand Up @@ -133,7 +137,7 @@ where
F: FnMut(KeyEvent) -> bool + 'static,
{
if code != HC_ACTION as i32 {
return CallNextHookEx(0, code, wparam, lparam);
return CallNextHookEx(ptr::null_mut(), code, wparam, lparam);
}

let hook_lparam = &*(lparam as *const KBDLLHOOKSTRUCT);
Expand All @@ -144,7 +148,7 @@ where
// events to prevent recursion and potential stack overflows if our
// remapping logic has sent the injected event.
if injected {
return CallNextHookEx(0, code, wparam, lparam);
return CallNextHookEx(ptr::null_mut(), code, wparam, lparam);
}

// There are two conditions for which the hook can be re-entered:
Expand Down Expand Up @@ -174,7 +178,7 @@ where
if handled {
-1
} else {
CallNextHookEx(0, code, wparam, lparam)
CallNextHookEx(ptr::null_mut(), code, wparam, lparam)
}
}

Expand Down Expand Up @@ -257,7 +261,7 @@ pub fn get_virtual_key(c: char) -> Option<u8> {
// console applications: https://github.com/microsoft/terminal/issues/83
// Fall back to the layout used by our process which is hopefully the
// correct one for the console too.
if layout == 0 {
if layout.is_null() {
layout = GetKeyboardLayout(0);
}
let vk_state = VkKeyScanExW(c.to_utf16()[0], layout);
Expand Down
2 changes: 1 addition & 1 deletion src/winapi/popup_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub struct PopupMenu(HMENU);
impl PopupMenu {
pub fn new() -> Self {
let hmenu = unsafe { CreatePopupMenu() };
assert_ne!(hmenu, 0);
assert!(!hmenu.is_null());
Self(hmenu)
}

Expand Down
4 changes: 2 additions & 2 deletions src/winapi/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use windows_sys::Win32::UI::WindowsAndMessaging::*;
pub fn register_instance(name: &CStr) -> bool {
unsafe {
let handle = CreateMutexA(ptr::null(), 0, name.as_ptr().cast());
if handle == 0 && GetLastError() == ERROR_ALREADY_EXISTS {
if handle.is_null() && GetLastError() == ERROR_ALREADY_EXISTS {
CloseHandle(handle);
false
} else {
Expand Down Expand Up @@ -56,7 +56,7 @@ fn disable_quick_edit_mode() {
ptr::null(),
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
0,
ptr::null_mut(),
);
let mut mode: u32 = 0;
if GetConsoleMode(console as _, &mut mode) != 0 {
Expand Down

0 comments on commit 24aa6e6

Please sign in to comment.