Skip to content

Commit

Permalink
chore(deps): update windows-rs to 0.51.1
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir committed Oct 17, 2023
1 parent f569bba commit 7119341
Show file tree
Hide file tree
Showing 16 changed files with 144 additions and 144 deletions.
5 changes: 5 additions & 0 deletions .changes/mouse-wheel-detla.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tao": "patch"
---

On Windows, fix incorrect delta reported for `DeviceEvent::MouseWheel` event.
5 changes: 5 additions & 0 deletions .changes/progress-state.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tao": "patch"
---

On Windows, fix `Window::set_progress_bar` incorrect states.
5 changes: 5 additions & 0 deletions .changes/windows-0.51.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tao": "patch"
---

Update `windows` and `windows-implement` crate to `0.51.1`
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ png = "0.17"
parking_lot = "0.12"
unicode-segmentation = "1.10"
image = { version = "0.24", default-features = false }
windows-implement = "0.48.0"
windows-implement = "0.51.1"

[target."cfg(target_os = \"windows\")".dependencies.windows]
version = "0.48.0"
version = "0.51.1"
features = [
"implement",
"Win32_Devices_HumanInterfaceDevice",
Expand Down
2 changes: 1 addition & 1 deletion src/platform/android.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright 2021-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0

#![cfg(any(target_os = "android"))]
#![cfg(target_os = "android")]

#[doc(hidden)]
pub use crate::platform_impl::ndk_glue;
Expand Down
11 changes: 5 additions & 6 deletions src/platform_impl/windows/dark_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ use once_cell::sync::Lazy;
/// This is a simple implementation of support for Windows Dark Mode,
/// which is inspired by the solution in https://github.com/ysc3839/win32-darkmode
use windows::{
core::{s, PCSTR, PSTR},
w,
core::{s, w, PCSTR, PSTR},
Win32::{
Foundation::{BOOL, HANDLE, HMODULE, HWND},
System::{LibraryLoader::*, SystemInformation::OSVERSIONINFOW},
Expand Down Expand Up @@ -242,12 +241,12 @@ fn refresh_titlebar_theme_color(hwnd: HWND) {
if let Some(ver) = *WIN10_BUILD_VERSION {
if ver < 18362 {
unsafe {
SetPropW(
let _ = SetPropW(
hwnd,
w!("UseImmersiveDarkModeColors"),
HANDLE(&mut is_dark_mode_bigbool as *mut _ as _),
)
};
);
}
} else if let Some(set_window_composition_attribute) = *SET_WINDOW_COMPOSITION_ATTRIBUTE {
let mut data = WINDOWCOMPOSITIONATTRIBDATA {
Attrib: WCA_USEDARKMODECOLORS,
Expand Down Expand Up @@ -301,5 +300,5 @@ fn is_high_contrast() -> bool {
)
};

ok.as_bool() && (HCF_HIGHCONTRASTON & hc.dwFlags.0) != 0
ok.is_ok() && (HCF_HIGHCONTRASTON & hc.dwFlags.0) != 0
}
4 changes: 2 additions & 2 deletions src/platform_impl/windows/drop_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ impl FileDropHandler {
.GetData(&drop_format)
{
Ok(medium) => {
let hglobal = medium.Anonymous.hGlobal;
let hdrop = HDROP(hglobal.0);
let hglobal = medium.u.hGlobal;
let hdrop = HDROP(hglobal.0 as _);

// The second parameter (0xFFFFFFFF) instructs the function to return the item count
let mut lpsz_file = [];
Expand Down
58 changes: 30 additions & 28 deletions src/platform_impl/windows/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ use windows::{
core::{s, PCWSTR},
Win32::{
Devices::HumanInterfaceDevice::*,
Foundation::{BOOL, HANDLE, HMODULE, HWND, LPARAM, LRESULT, POINT, RECT, WAIT_TIMEOUT, WPARAM},
Foundation::{
BOOL, HANDLE, HINSTANCE, HMODULE, HWND, LPARAM, LRESULT, POINT, RECT, WAIT_TIMEOUT, WPARAM,
},
Graphics::Gdi::*,
System::{
LibraryLoader::GetModuleHandleW,
Expand Down Expand Up @@ -319,7 +321,7 @@ impl<T> EventLoopWindowTarget<T> {

#[inline]
pub fn cursor_position(&self) -> Result<PhysicalPosition<f64>, ExternalError> {
util::cursor_position()
util::cursor_position().map_err(Into::into)
}
}

Expand Down Expand Up @@ -361,7 +363,7 @@ fn wait_thread(parent_thread_id: u32, msg_window_id: HWND) {
let mut msg: MSG;

let cur_thread_id = GetCurrentThreadId();
PostThreadMessageW(
let _ = PostThreadMessageW(
parent_thread_id,
*SEND_WAIT_THREAD_ID_MSG_ID,
WPARAM(0),
Expand Down Expand Up @@ -405,8 +407,8 @@ fn wait_thread(parent_thread_id: u32, msg_window_id: HWND) {
QS_ALLEVENTS,
MWMO_INPUTAVAILABLE,
);
if resume_reason == WAIT_TIMEOUT.0 {
PostMessageW(
if resume_reason == WAIT_TIMEOUT {
let _ = PostMessageW(
msg_window_id,
*PROCESS_NEW_EVENTS_MSG_ID,
WPARAM(0),
Expand All @@ -415,7 +417,7 @@ fn wait_thread(parent_thread_id: u32, msg_window_id: HWND) {
wait_until_opt = None;
}
} else {
PostMessageW(
let _ = PostMessageW(
msg_window_id,
*PROCESS_NEW_EVENTS_MSG_ID,
WPARAM(0),
Expand Down Expand Up @@ -461,7 +463,7 @@ fn dur2timeout(dur: Duration) -> u32 {
impl<T> Drop for EventLoop<T> {
fn drop(&mut self) {
unsafe {
DestroyWindow(self.window_target.p.thread_msg_target);
let _ = DestroyWindow(self.window_target.p.thread_msg_target);
}
}
}
Expand Down Expand Up @@ -515,7 +517,7 @@ impl EventLoopThreadExecutor {
LPARAM(0),
);
assert!(
res.as_bool(),
res.is_ok(),
"PostMessage failed ; is the messages queue full?"
);
}
Expand Down Expand Up @@ -544,7 +546,7 @@ impl<T: 'static> Clone for EventLoopProxy<T> {
impl<T: 'static> EventLoopProxy<T> {
pub fn send_event(&self, event: T) -> Result<(), EventLoopClosed<T>> {
unsafe {
if PostMessageW(self.target_window, *USER_EVENT_MSG_ID, WPARAM(0), LPARAM(0)).as_bool() {
if PostMessageW(self.target_window, *USER_EVENT_MSG_ID, WPARAM(0), LPARAM(0)).is_ok() {
self.event_send.send(event).ok();
Ok(())
} else {
Expand Down Expand Up @@ -621,7 +623,7 @@ lazy_static! {
lpfnWndProc: Some(util::call_default_window_proc),
cbClsExtra: 0,
cbWndExtra: 0,
hInstance: GetModuleHandleW(PCWSTR::null()).unwrap_or_default(),
hInstance:HINSTANCE(GetModuleHandleW(PCWSTR::null()).unwrap_or_default().0),
hIcon: HICON::default(),
hCursor: HCURSOR::default(), // must be null in order for cursor state to work properly
hbrBackground: HBRUSH::default(),
Expand Down Expand Up @@ -721,7 +723,7 @@ unsafe fn release_mouse(mut window_state: parking_lot::MutexGuard<'_, WindowStat
if window_state.mouse.capture_count == 0 {
// ReleaseCapture() causes a WM_CAPTURECHANGED where we lock the window_state.
drop(window_state);
ReleaseCapture();
let _ = ReleaseCapture();
}
}

Expand Down Expand Up @@ -808,7 +810,7 @@ unsafe fn flush_paint_messages<T: 'static>(
unsafe fn process_control_flow<T: 'static>(runner: &EventLoopRunner<T>) {
match runner.control_flow() {
ControlFlow::Poll => {
PostMessageW(
let _ = PostMessageW(
runner.thread_msg_target(),
*PROCESS_NEW_EVENTS_MSG_ID,
WPARAM(0),
Expand All @@ -817,7 +819,7 @@ unsafe fn process_control_flow<T: 'static>(runner: &EventLoopRunner<T>) {
}
ControlFlow::Wait => (),
ControlFlow::WaitUntil(until) => {
PostThreadMessageW(
let _ = PostThreadMessageW(
runner.wait_thread_id(),
*WAIT_UNTIL_MSG_ID,
WPARAM(0),
Expand Down Expand Up @@ -1030,7 +1032,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
}
win32wm::WM_NCLBUTTONDOWN => {
if wparam.0 == HTCAPTION as _ {
PostMessageW(window, WM_MOUSEMOVE, WPARAM(0), lparam);
let _ = PostMessageW(window, WM_MOUSEMOVE, WPARAM(0), lparam);
}

use crate::event::WindowEvent::DecorationsClick;
Expand Down Expand Up @@ -1256,7 +1258,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
});

// Calling TrackMouseEvent in order to receive mouse leave events.
TrackMouseEvent(&mut TRACKMOUSEEVENT {
let _ = TrackMouseEvent(&mut TRACKMOUSEEVENT {
cbSize: mem::size_of::<TRACKMOUSEEVENT>() as u32,
dwFlags: TME_LEAVE,
hwndTrack: window,
Expand Down Expand Up @@ -1361,7 +1363,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
win32wm::WM_LBUTTONDOWN => {
use crate::event::{ElementState::Pressed, MouseButton::Left, WindowEvent::MouseInput};

capture_mouse(window, &mut *subclass_input.window_state.lock());
capture_mouse(window, &mut subclass_input.window_state.lock());

let modifiers = update_modifiers(window, subclass_input);

Expand Down Expand Up @@ -1437,7 +1439,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
win32wm::WM_MBUTTONDOWN => {
use crate::event::{ElementState::Pressed, MouseButton::Middle, WindowEvent::MouseInput};

capture_mouse(window, &mut *subclass_input.window_state.lock());
capture_mouse(window, &mut subclass_input.window_state.lock());

let modifiers = update_modifiers(window, subclass_input);

Expand Down Expand Up @@ -1476,7 +1478,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
use crate::event::{ElementState::Pressed, MouseButton::Other, WindowEvent::MouseInput};
let xbutton = util::GET_XBUTTON_WPARAM(wparam);

capture_mouse(window, &mut *subclass_input.window_state.lock());
capture_mouse(window, &mut subclass_input.window_state.lock());

let modifiers = update_modifiers(window, subclass_input);

Expand Down Expand Up @@ -1533,7 +1535,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
mem::transmute(uninit_inputs),
mem::size_of::<TOUCHINPUT>() as i32,
)
.as_bool()
.is_ok()
{
inputs.set_len(pcount);
for input in &inputs {
Expand Down Expand Up @@ -1569,7 +1571,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
});
}
}
CloseTouchInputHandle(htouch);
let _ = CloseTouchInputHandle(htouch);
result = ProcResult::Value(LRESULT(0));
}

Expand Down Expand Up @@ -1880,7 +1882,7 @@ unsafe fn public_window_callback_inner<T: 'static>(

let old_physical_inner_rect = {
let mut old_physical_inner_rect = RECT::default();
GetClientRect(window, &mut old_physical_inner_rect);
let _ = GetClientRect(window, &mut old_physical_inner_rect);
let mut origin = POINT::default();
ClientToScreen(window, &mut origin);

Expand Down Expand Up @@ -1954,7 +1956,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
let bias = {
let cursor_pos = {
let mut pos = POINT::default();
GetCursorPos(&mut pos);
let _ = GetCursorPos(&mut pos);
pos
};
let suggested_cursor_horizontal_ratio = (cursor_pos.x - suggested_rect.left) as f64
Expand Down Expand Up @@ -2026,7 +2028,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
};
}

SetWindowPos(
let _ = SetWindowPos(
window,
HWND::default(),
new_outer_rect.left,
Expand Down Expand Up @@ -2066,7 +2068,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
result = ProcResult::DefSubclassProc;
} else {
// adjust the maximized borderless window so it doesn't cover the taskbar
if util::is_maximized(window) {
if util::is_maximized(window).unwrap_or(false) {
let params = &mut *(lparam.0 as *mut NCCALCSIZE_PARAMS);
if let Ok(monitor_info) =
monitor::get_monitor_info(MonitorFromRect(&params.rgrc[0], MONITOR_DEFAULTTONULL))
Expand Down Expand Up @@ -2112,7 +2114,7 @@ unsafe fn public_window_callback_inner<T: 'static>(

win32wm::WM_NCHITTEST => {
// Allow resizing unmaximized borderless window
if !util::is_maximized(window)
if !util::is_maximized(window).unwrap_or(false)
&& !subclass_input
.window_state
.lock()
Expand All @@ -2138,7 +2140,7 @@ unsafe fn public_window_callback_inner<T: 'static>(

_ => {
if msg == *DESTROY_MSG_ID {
DestroyWindow(window);
let _ = DestroyWindow(window);
result = ProcResult::Value(LRESULT(0));
} else if msg == *SET_RETAIN_STATE_ON_SIZE_MSG_ID {
let mut window_state = subclass_input.window_state.lock();
Expand Down Expand Up @@ -2254,7 +2256,7 @@ unsafe extern "system" fn thread_event_target_callback<T: 'static>(
LRESULT(0)
}
_ if msg == *PROCESS_NEW_EVENTS_MSG_ID => {
PostThreadMessageW(
let _ = PostThreadMessageW(
subclass_input.event_loop_runner.wait_thread_id(),
*CANCEL_WAIT_UNTIL_MSG_ID,
WPARAM(0),
Expand Down Expand Up @@ -2349,7 +2351,7 @@ unsafe fn handle_raw_input<T: 'static>(
RI_MOUSE_WHEEL as u16,
) {
// We must cast to SHORT first, becaues `usButtonData` must be interpreted as signed.
let delta = mouse.Anonymous.Anonymous.usButtonData as f32 / WHEEL_DELTA as f32;
let delta = mouse.Anonymous.Anonymous.usButtonData as i16 as f32 / WHEEL_DELTA as f32;
subclass_input.send_event(Event::DeviceEvent {
device_id,
event: MouseWheel {
Expand Down
6 changes: 3 additions & 3 deletions src/platform_impl/windows/icon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ impl RgbaIcon {
self.height as i32,
1,
(PIXEL_SIZE * 8) as u8,
and_mask.as_ptr() as *const u8,
rgba.as_ptr() as *const u8,
and_mask.as_ptr(),
rgba.as_ptr(),
)
};
Ok(WinIcon::from_handle(
Expand Down Expand Up @@ -148,7 +148,7 @@ impl WinIcon {

impl Drop for RaiiIcon {
fn drop(&mut self) {
unsafe { DestroyIcon(self.handle) };
let _ = unsafe { DestroyIcon(self.handle) };
}
}

Expand Down
8 changes: 2 additions & 6 deletions src/platform_impl/windows/keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,7 @@ impl KeyEventBuilder {
more_char_coming = false;
} else {
let next_msg = next_msg.assume_init().message;
if next_msg == WM_CHAR || next_msg == WM_SYSCHAR {
more_char_coming = true;
} else {
more_char_coming = false;
}
more_char_coming = next_msg == WM_CHAR || next_msg == WM_SYSCHAR;
}
}

Expand Down Expand Up @@ -708,7 +704,7 @@ fn ex_scancode_from_lparam(lparam: LPARAM) -> ExScancode {
fn get_kbd_state() -> [u8; 256] {
unsafe {
let mut kbd_state: MaybeUninit<[u8; 256]> = MaybeUninit::uninit();
GetKeyboardState(&mut *kbd_state.as_mut_ptr());
let _ = GetKeyboardState(&mut *kbd_state.as_mut_ptr());
kbd_state.assume_init()
}
}
Expand Down
6 changes: 1 addition & 5 deletions src/platform_impl/windows/minimal_ime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,7 @@ impl MinimalIme {
more_char_coming = false;
} else {
let next_msg = next_msg.assume_init().message;
if next_msg == WM_CHAR || next_msg == WM_SYSCHAR {
more_char_coming = true;
} else {
more_char_coming = false;
}
more_char_coming = next_msg == WM_CHAR || next_msg == WM_SYSCHAR;
}
}
if !more_char_coming {
Expand Down
Loading

0 comments on commit 7119341

Please sign in to comment.