From e5374f5d7dc70023f9b8b504f2cf001ac6f18d5e Mon Sep 17 00:00:00 2001 From: feeiyu <158308373+feeiyu@users.noreply.github.com> Date: Sat, 7 Dec 2024 06:15:04 +0800 Subject: [PATCH] windows: Ignore WM_SIZE event when minimizing window (#21533) Closes #21364 Release Notes: - Fixed minimize window and then reopen cause the layout changed ![layout1204](https://github.com/user-attachments/assets/e823da90-0cc6-4fc9-8b8e-82680357c6fe) --- crates/gpui/src/platform/windows/events.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/gpui/src/platform/windows/events.rs b/crates/gpui/src/platform/windows/events.rs index 025fbba4ac97ff3d53f0fea2b748d4b75f5e3a46..27235d5d406d802e616f22ce304c5111cf512f0d 100644 --- a/crates/gpui/src/platform/windows/events.rs +++ b/crates/gpui/src/platform/windows/events.rs @@ -33,7 +33,7 @@ pub(crate) fn handle_msg( WM_ACTIVATE => handle_activate_msg(handle, wparam, state_ptr), WM_CREATE => handle_create_msg(handle, state_ptr), WM_MOVE => handle_move_msg(handle, lparam, state_ptr), - WM_SIZE => handle_size_msg(lparam, state_ptr), + WM_SIZE => handle_size_msg(wparam, 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), @@ -136,7 +136,15 @@ fn handle_move_msg( Some(0) } -fn handle_size_msg(lparam: LPARAM, state_ptr: Rc) -> Option { +fn handle_size_msg( + wparam: WPARAM, + lparam: LPARAM, + state_ptr: Rc, +) -> Option { + if wparam.0 == SIZE_MINIMIZED as usize { + return Some(0); + } + let width = lparam.loword().max(1) as i32; let height = lparam.hiword().max(1) as i32; let mut lock = state_ptr.state.borrow_mut();