From 89ce9d26c3ac2483f93a386451b5a197cbfb684c Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Tue, 13 Feb 2024 08:30:30 +0200 Subject: [PATCH] fix(windows): apply `ScaleFactorChanged` if new size is different than OS (#874) 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 --- .changes/windows-scale-factor-maximized.md | 5 +++++ src/platform_impl/windows/event_loop/runner.rs | 17 +++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 .changes/windows-scale-factor-maximized.md 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, + ); + } } } }