windows: Update crate Windows from 0.53 to 0.56 (#11662)

Version 0.56 has fixed many of the previous bugs, and one of the bugs
prevent me implementing some functions.

Release Notes:

- N/A
This commit is contained in:
张小白
2024-05-14 09:59:55 -07:00
committed by GitHub
parent d1ee2d0749
commit 5154910c64
8 changed files with 117 additions and 87 deletions
+16 -8
View File
@@ -303,7 +303,7 @@ impl WindowsWindow {
placement.rcNormalPosition.bottom = params.bounds.bottom().0;
SetWindowPlacement(raw_hwnd, &placement).log_err();
}
unsafe { ShowWindow(raw_hwnd, SW_SHOW) };
unsafe { ShowWindow(raw_hwnd, SW_SHOW).ok().log_err() };
wnd
}
@@ -384,7 +384,7 @@ impl PlatformWindow for WindowsWindow {
GetCursorPos(&mut point)
.context("unable to get cursor position")
.log_err();
ScreenToClient(self.0.hwnd, &mut point);
ScreenToClient(self.0.hwnd, &mut point).ok().log_err();
point
};
logical_point(point.x as f32, point.y as f32, scale_factor)
@@ -481,7 +481,9 @@ impl PlatformWindow for WindowsWindow {
let hwnd = self.0.hwnd;
unsafe { SetActiveWindow(hwnd) };
unsafe { SetFocus(hwnd) };
unsafe { SetForegroundWindow(hwnd) };
// todo(windows)
// crate `windows 0.56` reports true as Err
unsafe { SetForegroundWindow(hwnd).as_bool() };
}
fn is_active(&self) -> bool {
@@ -511,11 +513,11 @@ impl PlatformWindow for WindowsWindow {
fn show_character_palette(&self) {}
fn minimize(&self) {
unsafe { ShowWindowAsync(self.0.hwnd, SW_MINIMIZE) };
unsafe { ShowWindowAsync(self.0.hwnd, SW_MINIMIZE).ok().log_err() };
}
fn zoom(&self) {
unsafe { ShowWindowAsync(self.0.hwnd, SW_MAXIMIZE) };
unsafe { ShowWindowAsync(self.0.hwnd, SW_MAXIMIZE).ok().log_err() };
}
fn toggle_fullscreen(&self) {
@@ -702,7 +704,9 @@ impl IDropTarget_Impl for WindowsDragDropHandler {
}
ReleaseStgMedium(&mut idata);
let mut cursor_position = POINT { x: pt.x, y: pt.y };
ScreenToClient(self.0.hwnd, &mut cursor_position);
ScreenToClient(self.0.hwnd, &mut cursor_position)
.ok()
.log_err();
let scale_factor = self.0.state.borrow().scale_factor;
let input = PlatformInput::FileDrop(FileDropEvent::Entered {
position: logical_point(
@@ -728,7 +732,9 @@ impl IDropTarget_Impl for WindowsDragDropHandler {
) -> windows::core::Result<()> {
let mut cursor_position = POINT { x: pt.x, y: pt.y };
unsafe {
ScreenToClient(self.0.hwnd, &mut cursor_position);
ScreenToClient(self.0.hwnd, &mut cursor_position)
.ok()
.log_err();
}
let scale_factor = self.0.state.borrow().scale_factor;
let input = PlatformInput::FileDrop(FileDropEvent::Pending {
@@ -759,7 +765,9 @@ impl IDropTarget_Impl for WindowsDragDropHandler {
) -> windows::core::Result<()> {
let mut cursor_position = POINT { x: pt.x, y: pt.y };
unsafe {
ScreenToClient(self.0.hwnd, &mut cursor_position);
ScreenToClient(self.0.hwnd, &mut cursor_position)
.ok()
.log_err();
}
let scale_factor = self.0.state.borrow().scale_factor;
let input = PlatformInput::FileDrop(FileDropEvent::Submit {