From 95a9319f24cb62add69d468ec0f60530b608fe6b Mon Sep 17 00:00:00 2001 From: Tony <68118705+Legend-Master@users.noreply.github.com> Date: Tue, 14 Jan 2025 11:54:13 +0800 Subject: [PATCH] chore(deps): update webview2 and windows (#1454) --- .changes/webview2-0.35-windows-0.59.md | 5 +++++ Cargo.toml | 7 +++---- src/lib.rs | 2 +- src/webview2/drag_drop.rs | 11 ++++++---- src/webview2/mod.rs | 29 +++++++++++--------------- src/webview2/util.rs | 4 ++-- 6 files changed, 30 insertions(+), 28 deletions(-) create mode 100644 .changes/webview2-0.35-windows-0.59.md diff --git a/.changes/webview2-0.35-windows-0.59.md b/.changes/webview2-0.35-windows-0.59.md new file mode 100644 index 000000000..8fb5f76db --- /dev/null +++ b/.changes/webview2-0.35-windows-0.59.md @@ -0,0 +1,5 @@ +--- +wry: minor +--- + +Updated `webview2-com` to `0.35`, `windows` to `0.59`. diff --git a/Cargo.toml b/Cargo.toml index eff01b361..1d545df7c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -68,15 +68,14 @@ gdkx11 = { version = "0.18", optional = true } percent-encoding = "2.3" [target."cfg(target_os = \"windows\")".dependencies] -webview2-com = "0.34" +webview2-com = "0.35" windows-version = "0.1" -windows-core = "0.58" +windows-core = "0.59" dunce = "1" [target."cfg(target_os = \"windows\")".dependencies.windows] -version = "0.58" +version = "0.59" features = [ - "implement", "Win32_Foundation", "Win32_Graphics_Gdi", "Win32_System_Com", diff --git a/src/lib.rs b/src/lib.rs index ca9f436af..037f4a6db 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -591,7 +591,7 @@ pub struct WebViewAttributes<'a> { pub background_throttling: Option, } -impl<'a> Default for WebViewAttributes<'a> { +impl Default for WebViewAttributes<'_> { fn default() -> Self { Self { id: Default::default(), diff --git a/src/webview2/drag_drop.rs b/src/webview2/drag_drop.rs index cf3efe8c0..67111c985 100644 --- a/src/webview2/drag_drop.rs +++ b/src/webview2/drag_drop.rs @@ -57,7 +57,7 @@ impl DragDropController { let closure = &mut *(lparam.0 as *mut c_void as *mut &mut dyn FnMut(HWND) -> bool); closure(hwnd).into() } - let _ = unsafe { EnumChildWindows(hwnd, Some(enumerate_callback), lparam) }; + let _ = unsafe { EnumChildWindows(Some(hwnd), Some(enumerate_callback), lparam) }; } controller @@ -94,7 +94,10 @@ impl DragDropTarget { } } - unsafe fn iterate_filenames(data_obj: Option<&IDataObject>, mut callback: F) -> Option + unsafe fn iterate_filenames( + data_obj: windows_core::Ref<'_, IDataObject>, + mut callback: F, + ) -> Option where F: FnMut(PathBuf), { @@ -157,7 +160,7 @@ impl DragDropTarget { impl IDropTarget_Impl for DragDropTarget_Impl { fn DragEnter( &self, - pDataObj: Option<&IDataObject>, + pDataObj: windows_core::Ref<'_, IDataObject>, _grfKeyState: MODIFIERKEYS_FLAGS, pt: &POINTL, pdwEffect: *mut DROPEFFECT, @@ -224,7 +227,7 @@ impl IDropTarget_Impl for DragDropTarget_Impl { fn Drop( &self, - pDataObj: Option<&IDataObject>, + pDataObj: windows_core::Ref<'_, IDataObject>, _grfKeyState: MODIFIERKEYS_FLAGS, pt: &POINTL, _pdwEffect: *mut DROPEFFECT, diff --git a/src/webview2/mod.rs b/src/webview2/mod.rs index ca4bb96c7..564ca2e11 100644 --- a/src/webview2/mod.rs +++ b/src/webview2/mod.rs @@ -237,9 +237,9 @@ impl InnerWebView { y, width, height, - parent, - HMENU::default(), - GetModuleHandleW(PCWSTR::null()).unwrap_or_default(), + Some(parent), + None, + GetModuleHandleW(PCWSTR::null()).map(Into::into).ok(), None, )? }; @@ -247,7 +247,7 @@ impl InnerWebView { unsafe { SetWindowPos( hwnd, - HWND_TOP, + Some(HWND_TOP), 0, 0, 0, @@ -1040,7 +1040,7 @@ impl InnerWebView { let raw = Box::into_raw(boxed2); - let _res = PostMessageW(hwnd, *EXEC_MSG_ID, WPARAM(raw as _), LPARAM(0)); + let _res = PostMessageW(Some(hwnd), *EXEC_MSG_ID, WPARAM(raw as _), LPARAM(0)); #[cfg(any(debug_assertions, feature = "tracing"))] if let Err(err) = _res { @@ -1067,7 +1067,7 @@ impl InnerWebView { if msg == *EXEC_MSG_ID { let mut function: Box> = Box::from_raw(wparam.0 as *mut _); function(); - let _ = RedrawWindow(hwnd, None, HRGN::default(), RDW_INTERNALPAINT); + let _ = RedrawWindow(Some(hwnd), None, None, RDW_INTERNALPAINT); return LRESULT(0); } @@ -1139,7 +1139,7 @@ impl InnerWebView { if (*controller).ParentWindow(&mut hwnd).is_ok() { let _ = SetWindowPos( hwnd, - HWND::default(), + None, 0, 0, width, @@ -1193,12 +1193,7 @@ impl InnerWebView { #[inline] unsafe fn dettach_parent_subclass(parent: HWND) { - SendMessageW( - parent, - PARENT_DESTROY_MESSAGE, - WPARAM::default(), - LPARAM::default(), - ); + SendMessageW(parent, PARENT_DESTROY_MESSAGE, None, None); let _ = RemoveWindowSubclass( parent, Some(Self::parent_subclass_proc), @@ -1321,7 +1316,7 @@ impl InnerWebView { x: rect.left, y: rect.top, }]; - unsafe { MapWindowPoints(self.hwnd, *self.parent.borrow(), position_point) }; + unsafe { MapWindowPoints(Some(self.hwnd), Some(*self.parent.borrow()), position_point) }; bounds.position = PhysicalPosition::new(position_point[0].x, position_point[0].y).into(); } else { @@ -1348,7 +1343,7 @@ impl InnerWebView { SetWindowPos( self.hwnd, - HWND::default(), + None, position.x, position.y, size.width, @@ -1436,7 +1431,7 @@ impl InnerWebView { unsafe { let parent = *self.parent.borrow(); if parent != HWND::default() { - SetFocus(parent)?; + SetFocus(Some(parent))?; } } @@ -1553,7 +1548,7 @@ impl InnerWebView { let parent = HWND(parent as _); unsafe { - SetParent(self.hwnd, parent)?; + SetParent(self.hwnd, Some(parent))?; if !self.is_child { Self::dettach_parent_subclass(*self.parent.borrow()); diff --git a/src/webview2/util.rs b/src/webview2/util.rs index 8f822e42c..f227e15dc 100644 --- a/src/webview2/util.rs +++ b/src/webview2/util.rs @@ -81,7 +81,7 @@ pub unsafe fn hwnd_dpi(hwnd: HWND) -> u32 { BASE_DPI } } else { - let hdc = GetDC(hwnd); + let hdc = GetDC(Some(hwnd)); if hdc.is_invalid() { return BASE_DPI; } @@ -90,7 +90,7 @@ pub unsafe fn hwnd_dpi(hwnd: HWND) -> u32 { if IsProcessDPIAware().as_bool() { // If the process is DPI aware, then scaling must be handled by the application using // this DPI value. - GetDeviceCaps(hdc, LOGPIXELSX) as u32 + GetDeviceCaps(Some(hdc), LOGPIXELSX) as u32 } else { // If the process is DPI unaware, then scaling is performed by the OS; we thus return // 96 (scale factor 1.0) to prevent the window from being re-scaled by both the