windows: Fix crashing when minimizing a window on Windows 11 (#22414)
Closes #22366 This PR fixes the issue of crashing when minimizing a window on Windows 11. And this PR supersedes #22366. The main change in this PR is to stop rendering the window when it is minimized. Additionally, I’ve made some modifications to the code in #21756 to improve clarity (I think...). cc @mgsloan Release Notes: - N/A
This commit is contained in:
parent
1a9f0a647a
commit
95911aaa14
2 changed files with 6 additions and 7 deletions
|
@ -146,19 +146,18 @@ fn handle_size_msg(
|
|||
// Don't resize the renderer when the window is minimized, but record that it was minimized so
|
||||
// that on restore the swap chain can be recreated via `update_drawable_size_even_if_unchanged`.
|
||||
if wparam.0 == SIZE_MINIMIZED as usize {
|
||||
lock.is_minimized = Some(true);
|
||||
lock.restore_from_minimized = lock.callbacks.request_frame.take();
|
||||
return Some(0);
|
||||
}
|
||||
let may_have_been_minimized = lock.is_minimized.unwrap_or(true);
|
||||
lock.is_minimized = Some(false);
|
||||
|
||||
let width = lparam.loword().max(1) as i32;
|
||||
let height = lparam.hiword().max(1) as i32;
|
||||
let new_size = size(DevicePixels(width), DevicePixels(height));
|
||||
let scale_factor = lock.scale_factor;
|
||||
if may_have_been_minimized {
|
||||
if lock.restore_from_minimized.is_some() {
|
||||
lock.renderer
|
||||
.update_drawable_size_even_if_unchanged(new_size);
|
||||
lock.callbacks.request_frame = lock.restore_from_minimized.take();
|
||||
} else {
|
||||
lock.renderer.update_drawable_size(new_size);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue