From 95f12aa4d2f9b5806af0d29d34c09384bc26ffd7 Mon Sep 17 00:00:00 2001 From: amrbashir Date: Tue, 17 Oct 2023 18:27:29 +0300 Subject: [PATCH] chore(deps): update windows-rs to 0.51.1 --- .changes/windows-0.51.md | 5 +++++ Cargo.toml | 6 +++--- src/webview/mod.rs | 2 +- src/webview/webview2/file_drop.rs | 2 +- src/webview/webview2/mod.rs | 19 +++++++------------ src/webview/webview2/resize.rs | 14 ++++++++++---- 6 files changed, 27 insertions(+), 21 deletions(-) create mode 100644 .changes/windows-0.51.md diff --git a/.changes/windows-0.51.md b/.changes/windows-0.51.md new file mode 100644 index 000000000..b392e6b14 --- /dev/null +++ b/.changes/windows-0.51.md @@ -0,0 +1,5 @@ +--- +"wry": "minor" +--- + +Update `windows` and `windows-implement` crate to `0.51.1` diff --git a/Cargo.toml b/Cargo.toml index 7f11cbe89..dafb3ea3d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -60,13 +60,13 @@ soup3 = "0.3" winit = { package = "winit-gtk", version = "0.28.1", features = [ "serde" ], optional = true } [target."cfg(target_os = \"windows\")".dependencies] -webview2-com = "0.25" -windows-implement = "0.48" +webview2-com = "0.27" +windows-implement = "0.51" dunce = "1" winit = { version = "0.28", features = [ "serde" ], optional = true } [target."cfg(target_os = \"windows\")".dependencies.windows] - version = "0.48" + version = "0.51" features = [ "implement", "Win32_Foundation", diff --git a/src/webview/mod.rs b/src/webview/mod.rs index ab0bac48b..7fdd1438d 100644 --- a/src/webview/mod.rs +++ b/src/webview/mod.rs @@ -938,7 +938,7 @@ impl Drop for WebView { impl Drop for WebView { fn drop(&mut self) { unsafe { - DestroyWindow(HWND(self.window.hwnd() as _)); + let _ = DestroyWindow(HWND(self.window.hwnd() as _)); } } } diff --git a/src/webview/webview2/file_drop.rs b/src/webview/webview2/file_drop.rs index acb535737..967f4b942 100644 --- a/src/webview/webview2/file_drop.rs +++ b/src/webview/webview2/file_drop.rs @@ -145,7 +145,7 @@ impl FileDropHandler { .GetData(&drop_format) { Ok(medium) => { - let hdrop = HDROP(medium.Anonymous.hGlobal.0); + let hdrop = HDROP(medium.u.hGlobal.0 as _); // The second parameter (0xFFFFFFFF) instructs the function to return the item count let item_count = DragQueryFileW(hdrop, 0xFFFFFFFF, None); diff --git a/src/webview/webview2/mod.rs b/src/webview/webview2/mod.rs index bd644de9c..a141b29bb 100644 --- a/src/webview/webview2/mod.rs +++ b/src/webview/webview2/mod.rs @@ -29,8 +29,7 @@ use std::{ use once_cell::{sync::Lazy, unsync::OnceCell}; use windows::{ - core::{ComInterface, PCSTR, PCWSTR, PWSTR}, - s, + core::{s, ComInterface, PCSTR, PCWSTR, PWSTR}, Win32::{ Foundation::*, Globalization::{self, MAX_LOCALE_NAME}, @@ -264,11 +263,7 @@ impl InnerWebView { unsafe { let handler: ICoreWebView2WindowCloseRequestedEventHandler = WindowCloseRequestedEventHandler::create(Box::new(move |_, _| { - if win32wm::DestroyWindow(hwnd).as_bool() { - Ok(()) - } else { - Err(E_FAIL.into()) - } + win32wm::DestroyWindow(hwnd) })); webview .add_WindowCloseRequested(&handler, &mut token) @@ -308,7 +303,7 @@ impl InnerWebView { .map_err(webview2_com::Error::WindowsError)?; let mut rect = RECT::default(); - win32wm::GetClientRect(hwnd, &mut rect); + win32wm::GetClientRect(hwnd, &mut rect)?; controller .SetBounds(rect) .map_err(webview2_com::Error::WindowsError)?; @@ -402,7 +397,7 @@ window.addEventListener('mousemove', (e) => window.chrome.webview.postMessage('_ use crate::application::window::CursorIcon; let mut point = POINT::default(); - win32wm::GetCursorPos(&mut point); + win32wm::GetCursorPos(&mut point)?; let result = resize::hit_test(window_.hwnd(), point.x, point.y); let cursor = match result.0 as u32 { win32wm::HTLEFT => CursorIcon::WResize, @@ -430,7 +425,7 @@ window.addEventListener('mousemove', (e) => window.chrome.webview.postMessage('_ win32wm::WM_NCLBUTTONDOWN, point.x, point.y, - ); + )?; } } } @@ -809,7 +804,7 @@ window.addEventListener('mousemove', (e) => window.chrome.webview.postMessage('_ if wparam.0 != win32wm::SIZE_MINIMIZED as usize { let controller = dwrefdata as *mut ICoreWebView2Controller; let mut client_rect = RECT::default(); - win32wm::GetClientRect(hwnd, &mut client_rect); + let _ = win32wm::GetClientRect(hwnd, &mut client_rect); let _ = (*controller).SetBounds(RECT { left: 0, top: 0, @@ -1174,7 +1169,7 @@ where let res = PostMessageW(HWND(hwnd), *EXEC_MSG_ID, WPARAM(raw as _), LPARAM(0)); assert!( - res.as_bool(), + res.is_ok(), "PostMessage failed ; is the messages queue full?" ); } diff --git a/src/webview/webview2/resize.rs b/src/webview/webview2/resize.rs index b132854d5..65ddcac86 100644 --- a/src/webview/webview2/resize.rs +++ b/src/webview/webview2/resize.rs @@ -27,13 +27,19 @@ pub fn MAKELPARAM(x: i16, y: i16) -> LPARAM { } #[inline] -pub fn begin_resize_drag(hwnd: isize, edge: isize, button: u32, x: i32, y: i32) { +pub fn begin_resize_drag( + hwnd: isize, + edge: isize, + button: u32, + x: i32, + y: i32, +) -> windows::core::Result<()> { unsafe { let w_param = WPARAM(edge as _); let l_param = MAKELPARAM(x as i16, y as i16); - ReleaseCapture(); - PostMessageW(HWND(hwnd), button, w_param, l_param); + ReleaseCapture()?; + PostMessageW(HWND(hwnd), button, w_param, l_param) } } @@ -101,7 +107,7 @@ pub fn hit_test(hwnd: isize, cx: i32, cy: i32) -> LRESULT { let hwnd = HWND(hwnd); let mut window_rect = RECT::default(); unsafe { - if GetWindowRect(hwnd, <*mut _>::cast(&mut window_rect)).as_bool() { + if GetWindowRect(hwnd, &mut window_rect).is_ok() { const CLIENT: isize = 0b0000; const LEFT: isize = 0b0001; const RIGHT: isize = 0b0010;