Skip to content

Commit

Permalink
fix(windows): apply ScaleFactorChanged if new size is different tha…
Browse files Browse the repository at this point in the history
…n 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
  • Loading branch information
amrbashir authored Feb 13, 2024
1 parent a79d98f commit 89ce9d2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changes/windows-scale-factor-maximized.md
Original file line number Diff line number Diff line change
@@ -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.
17 changes: 11 additions & 6 deletions src/platform_impl/windows/event_loop/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,19 +428,24 @@ impl<T> BufferedEvent<T> {
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 {
scale_factor,
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,
);
}
}
}
}
Expand Down

0 comments on commit 89ce9d2

Please sign in to comment.