windows: Fix window_min_size (#29118)

Closes #29117

This makes `window_min_size` work by using the `WM_GETMINMAXINFO` window
message.


Release Notes:

- N/A

---------

Co-authored-by: 张小白 <364772080@qq.com>
This commit is contained in:
angelrecovery 2025-04-21 01:38:36 -07:00 committed by GitHub
parent 4dcfe0cff9
commit a4f5c4fef2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 32 additions and 2 deletions

View file

@ -39,6 +39,7 @@ pub(crate) fn handle_msg(
WM_CREATE => handle_create_msg(handle, state_ptr),
WM_MOVE => handle_move_msg(handle, lparam, state_ptr),
WM_SIZE => handle_size_msg(wparam, lparam, state_ptr),
WM_GETMINMAXINFO => handle_get_min_max_info_msg(lparam, state_ptr),
WM_ENTERSIZEMOVE | WM_ENTERMENULOOP => handle_size_move_loop(handle),
WM_EXITSIZEMOVE | WM_EXITMENULOOP => handle_size_move_loop_exit(handle),
WM_TIMER => handle_timer_msg(handle, wparam, state_ptr),
@ -140,6 +141,29 @@ fn handle_move_msg(
Some(0)
}
fn handle_get_min_max_info_msg(
lparam: LPARAM,
state_ptr: Rc<WindowsWindowStatePtr>,
) -> Option<isize> {
let lock = state_ptr.state.borrow();
if let Some(min_size) = lock.min_size {
let scale_factor = lock.scale_factor;
let boarder_offset = lock.border_offset;
drop(lock);
unsafe {
let minmax_info = &mut *(lparam.0 as *mut MINMAXINFO);
minmax_info.ptMinTrackSize.x =
min_size.width.scale(scale_factor).0 as i32 + boarder_offset.width_offset;
minmax_info.ptMinTrackSize.y =
min_size.height.scale(scale_factor).0 as i32 + boarder_offset.height_offset;
}
Some(0)
} else {
None
}
}
fn handle_size_msg(
wparam: WPARAM,
lparam: LPARAM,