chore: Bump windows crate version (#26455)

Closes #ISSUE

Release Notes:

- N/A
This commit is contained in:
张小白 2025-03-11 21:14:36 +08:00 committed by GitHub
parent 41ddd1cc97
commit 18259c0fd4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 162 additions and 61 deletions

View file

@ -170,7 +170,7 @@ fn set_data_to_clipboard<T>(data: &[T], format: u32) -> Result<()> {
let handle = GlobalLock(global);
std::ptr::copy_nonoverlapping(data.as_ptr(), handle as _, data.len());
let _ = GlobalUnlock(global);
SetClipboardData(format, HANDLE(global.0))?;
SetClipboardData(format, Some(HANDLE(global.0)))?;
}
Ok(())
}

View file

@ -1049,7 +1049,7 @@ impl IDWriteTextRenderer_Impl for TextRenderer_Impl {
_measuringmode: DWRITE_MEASURING_MODE,
glyphrun: *const DWRITE_GLYPH_RUN,
glyphrundescription: *const DWRITE_GLYPH_RUN_DESCRIPTION,
_clientdrawingeffect: Option<&windows::core::IUnknown>,
_clientdrawingeffect: windows::core::Ref<windows::core::IUnknown>,
) -> windows::core::Result<()> {
unsafe {
let glyphrun = &*glyphrun;
@ -1113,7 +1113,7 @@ impl IDWriteTextRenderer_Impl for TextRenderer_Impl {
_baselineoriginx: f32,
_baselineoriginy: f32,
_underline: *const DWRITE_UNDERLINE,
_clientdrawingeffect: Option<&windows::core::IUnknown>,
_clientdrawingeffect: windows::core::Ref<windows::core::IUnknown>,
) -> windows::core::Result<()> {
Err(windows::core::Error::new(
E_NOTIMPL,
@ -1127,7 +1127,7 @@ impl IDWriteTextRenderer_Impl for TextRenderer_Impl {
_baselineoriginx: f32,
_baselineoriginy: f32,
_strikethrough: *const DWRITE_STRIKETHROUGH,
_clientdrawingeffect: Option<&windows::core::IUnknown>,
_clientdrawingeffect: windows::core::Ref<windows::core::IUnknown>,
) -> windows::core::Result<()> {
Err(windows::core::Error::new(
E_NOTIMPL,
@ -1140,10 +1140,10 @@ impl IDWriteTextRenderer_Impl for TextRenderer_Impl {
_clientdrawingcontext: *const ::core::ffi::c_void,
_originx: f32,
_originy: f32,
_inlineobject: Option<&IDWriteInlineObject>,
_inlineobject: windows::core::Ref<IDWriteInlineObject>,
_issideways: BOOL,
_isrighttoleft: BOOL,
_clientdrawingeffect: Option<&windows::core::IUnknown>,
_clientdrawingeffect: windows::core::Ref<windows::core::IUnknown>,
) -> windows::core::Result<()> {
Err(windows::core::Error::new(
E_NOTIMPL,

View file

@ -215,7 +215,7 @@ fn available_monitors() -> SmallVec<[HMONITOR; 4]> {
let mut monitors: SmallVec<[HMONITOR; 4]> = SmallVec::new();
unsafe {
EnumDisplayMonitors(
HDC::default(),
None,
None,
Some(monitor_enum_proc),
LPARAM(&mut monitors as *mut _ as _),

View file

@ -177,7 +177,12 @@ fn handle_size_msg(
fn handle_size_move_loop(handle: HWND) -> Option<isize> {
unsafe {
let ret = SetTimer(handle, SIZE_MOVE_LOOP_TIMER_ID, USER_TIMER_MINIMUM, None);
let ret = SetTimer(
Some(handle),
SIZE_MOVE_LOOP_TIMER_ID,
USER_TIMER_MINIMUM,
None,
);
if ret == 0 {
log::error!(
"unable to create timer: {}",
@ -190,7 +195,7 @@ fn handle_size_move_loop(handle: HWND) -> Option<isize> {
fn handle_size_move_loop_exit(handle: HWND) -> Option<isize> {
unsafe {
KillTimer(handle, SIZE_MOVE_LOOP_TIMER_ID).log_err();
KillTimer(Some(handle), SIZE_MOVE_LOOP_TIMER_ID).log_err();
}
None
}
@ -217,7 +222,7 @@ fn handle_paint_msg(handle: HWND, state_ptr: Rc<WindowsWindowStatePtr>) -> Optio
request_frame(Default::default());
state_ptr.state.borrow_mut().callbacks.request_frame = Some(request_frame);
}
unsafe { ValidateRect(handle, None).ok().log_err() };
unsafe { ValidateRect(Some(handle), None).ok().log_err() };
Some(0)
}
@ -776,7 +781,7 @@ fn handle_activate_msg(
if state_ptr.hide_title_bar {
if let Some(titlebar_rect) = state_ptr.state.borrow().get_titlebar_rect().log_err() {
unsafe {
InvalidateRect(handle, Some(&titlebar_rect), FALSE)
InvalidateRect(Some(handle), Some(&titlebar_rect), false)
.ok()
.log_err()
};
@ -1105,7 +1110,7 @@ fn handle_nc_mouse_up_msg(
HTCLOSE => {
if last_button == HTCLOSE {
unsafe {
PostMessageW(handle, WM_CLOSE, WPARAM::default(), LPARAM::default())
PostMessageW(Some(handle), WM_CLOSE, WPARAM::default(), LPARAM::default())
.log_err()
};
handled = true;
@ -1133,7 +1138,7 @@ fn handle_set_cursor(lparam: LPARAM, state_ptr: Rc<WindowsWindowStatePtr>) -> Op
) {
return None;
}
unsafe { SetCursor(state_ptr.state.borrow().current_cursor) };
unsafe { SetCursor(Some(state_ptr.state.borrow().current_cursor)) };
Some(1)
}

View file

@ -130,14 +130,9 @@ impl WindowsPlatform {
fn redraw_all(&self) {
for handle in self.raw_window_handles.read().iter() {
unsafe {
RedrawWindow(
*handle,
None,
HRGN::default(),
RDW_INVALIDATE | RDW_UPDATENOW,
)
.ok()
.log_err();
RedrawWindow(Some(*handle), None, None, RDW_INVALIDATE | RDW_UPDATENOW)
.ok()
.log_err();
}
}
}
@ -156,7 +151,7 @@ impl WindowsPlatform {
.read()
.iter()
.for_each(|handle| unsafe {
PostMessageW(*handle, message, wparam, lparam).log_err();
PostMessageW(Some(*handle), message, wparam, lparam).log_err();
});
}
@ -620,7 +615,7 @@ impl Platform for WindowsPlatform {
CredReadW(
PCWSTR::from_raw(target_name.as_ptr()),
CRED_TYPE_GENERIC,
0,
None,
&mut credentials,
)?
};
@ -648,7 +643,13 @@ impl Platform for WindowsPlatform {
.chain(Some(0))
.collect_vec();
self.foreground_executor().spawn(async move {
unsafe { CredDeleteW(PCWSTR::from_raw(target_name.as_ptr()), CRED_TYPE_GENERIC, 0)? };
unsafe {
CredDeleteW(
PCWSTR::from_raw(target_name.as_ptr()),
CRED_TYPE_GENERIC,
None,
)?
};
Ok(())
})
}
@ -805,7 +806,7 @@ fn load_icon() -> Result<HICON> {
let module = unsafe { GetModuleHandleW(None).context("unable to get module handle")? };
let handle = unsafe {
LoadImageW(
module,
Some(module.into()),
windows::core::PCWSTR(1 as _),
IMAGE_ICON,
0,

View file

@ -2,6 +2,7 @@ use std::sync::OnceLock;
use ::util::ResultExt;
use windows::{
core::BOOL,
Wdk::System::SystemServices::RtlGetVersion,
Win32::{Foundation::*, Graphics::Dwm::*, UI::WindowsAndMessaging::*},
UI::{

View file

@ -296,7 +296,7 @@ impl WindowsWindowStatePtr {
unsafe {
SetWindowPos(
state_ptr.hwnd,
HWND::default(),
None,
x,
y,
cx,
@ -433,7 +433,7 @@ impl WindowsWindow {
CW_USEDEFAULT,
None,
None,
hinstance,
Some(hinstance.into()),
lpparam,
)
};
@ -650,7 +650,7 @@ impl PlatformWindow for WindowsWindow {
.spawn(async move {
this.set_window_placement().log_err();
unsafe { SetActiveWindow(hwnd).log_err() };
unsafe { SetFocus(hwnd).log_err() };
unsafe { SetFocus(Some(hwnd)).log_err() };
// todo(windows)
// crate `windows 0.56` reports true as Err
unsafe { SetForegroundWindow(hwnd).as_bool() };
@ -817,16 +817,13 @@ impl WindowsDragDropHandler {
impl IDropTarget_Impl for WindowsDragDropHandler_Impl {
fn DragEnter(
&self,
pdataobj: Option<&IDataObject>,
pdataobj: windows::core::Ref<IDataObject>,
_grfkeystate: MODIFIERKEYS_FLAGS,
pt: &POINTL,
pdweffect: *mut DROPEFFECT,
) -> windows::core::Result<()> {
unsafe {
let Some(idata_obj) = pdataobj else {
log::info!("no dragging file or directory detected");
return Ok(());
};
let idata_obj = pdataobj.ok()?;
let config = FORMATETC {
cfFormat: CF_HDROP.0,
ptd: std::ptr::null_mut() as _,
@ -905,7 +902,7 @@ impl IDropTarget_Impl for WindowsDragDropHandler_Impl {
fn Drop(
&self,
_pdataobj: Option<&IDataObject>,
_pdataobj: windows::core::Ref<IDataObject>,
_grfkeystate: MODIFIERKEYS_FLAGS,
pt: &POINTL,
_pdweffect: *mut DROPEFFECT,