diff --git a/.changes/windows-scale-factor-maximized.md b/.changes/windows-scale-factor-maximized.md new file mode 100644 index 000000000..e310ea926 --- /dev/null +++ b/.changes/windows-scale-factor-maximized.md @@ -0,0 +1,5 @@ +--- +"tao": "patch" +--- + +On Windows, apply `ScaleFactorChanged` if new size is different than what OS reported. This fixes an issue when moving the window to another monitor and immediately maximizing it, resulting in a maximized window (i.e have `WS_MAXIMIZE` window style) but doesn't cover the monitor work area. diff --git a/src/platform_impl/windows/event_loop/runner.rs b/src/platform_impl/windows/event_loop/runner.rs index 74fd2612d..7782ab59f 100644 --- a/src/platform_impl/windows/event_loop/runner.rs +++ b/src/platform_impl/windows/event_loop/runner.rs @@ -428,6 +428,8 @@ impl BufferedEvent { match self { Self::Event(event) => dispatch(event), Self::ScaleFactorChanged(window_id, scale_factor, mut new_inner_size) => { + let os_inner_size = new_inner_size.clone(); + dispatch(Event::WindowEvent { window_id, event: WindowEvent::ScaleFactorChanged { @@ -435,12 +437,15 @@ impl BufferedEvent { new_inner_size: &mut new_inner_size, }, }); - util::set_inner_size_physical( - HWND(window_id.0 .0), - new_inner_size.width as _, - new_inner_size.height as _, - true, - ); + + if new_inner_size != os_inner_size { + util::set_inner_size_physical( + HWND(window_id.0 .0), + new_inner_size.width as _, + new_inner_size.height as _, + true, + ); + } } } }