Fix fullscreen window messaging race on Windows (#2225)

This commit is contained in:
Johan Andersson 2022-03-26 16:43:13 +01:00 committed by GitHub
parent 7369551c02
commit 6e28ba8927
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 25 deletions

View file

@ -62,8 +62,7 @@ use crate::{
monitor::MonitorHandle as RootMonitorHandle,
platform_impl::platform::{
dark_mode::try_theme,
definitions::ITaskbarList2,
definitions::{CLSID_TaskbarList, IID_ITaskbarList2},
definitions::{CLSID_TaskbarList, IID_ITaskbarList2, ITaskbarList2},
dpi::{dpi_to_scale_factor, enable_non_client_dpi_scaling, hwnd_dpi},
drop_handler::FileDropHandler,
event_loop::{self, EventLoopWindowTarget, DESTROY_MSG_ID},
@ -486,6 +485,14 @@ impl Window {
);
});
// Mark as fullscreen window wrt to z-order
//
// this needs to be called before the below fullscreen SetWindowPos as this itself
// will generate WM_SIZE messages of the old window size that can race with what we set below
unsafe {
taskbar_mark_fullscreen(window.0, fullscreen.is_some());
}
// Update window bounds
match &fullscreen {
Some(fullscreen) => {
@ -533,10 +540,6 @@ impl Window {
}
}
}
unsafe {
taskbar_mark_fullscreen(window.0, fullscreen.is_some());
}
});
}
@ -842,19 +845,20 @@ impl<'a, T: 'static> InitData<'a, T> {
// attribute is correctly applied.
win.set_visible(attributes.visible);
let dimensions = attributes
.inner_size
.unwrap_or_else(|| PhysicalSize::new(800, 600).into());
win.set_inner_size(dimensions);
if attributes.maximized {
// Need to set MAXIMIZED after setting `inner_size` as
// `Window::set_inner_size` changes MAXIMIZED to false.
win.set_maximized(true);
}
if attributes.fullscreen.is_some() {
win.set_fullscreen(attributes.fullscreen);
force_window_active(win.window.0);
} else {
let dimensions = attributes
.inner_size
.unwrap_or_else(|| PhysicalSize::new(800, 600).into());
win.set_inner_size(dimensions);
if attributes.maximized {
// Need to set MAXIMIZED after setting `inner_size` as
// `Window::set_inner_size` changes MAXIMIZED to false.
win.set_maximized(true);
}
}
if let Some(position) = attributes.position {