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 2c5dc4f commit 95f12aa
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 21 deletions.
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 @@
---
"wry": "minor"
---

Update `windows` and `windows-implement` crate to `0.51.1`
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/webview/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 _));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/webview/webview2/file_drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
19 changes: 7 additions & 12 deletions src/webview/webview2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)?;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -430,7 +425,7 @@ window.addEventListener('mousemove', (e) => window.chrome.webview.postMessage('_
win32wm::WM_NCLBUTTONDOWN,
point.x,
point.y,
);
)?;
}
}
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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?"
);
}
14 changes: 10 additions & 4 deletions src/webview/webview2/resize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 95f12aa

Please sign in to comment.