Skip to content

Commit

Permalink
fix(windows): get correct monitor in WM_NCCALCSIZE, closes #471
Browse files Browse the repository at this point in the history
`MonitorFromWindow` is unreliable with maximized Window, it either can't
find a monitor for the window and will default to nearest monitor or it
will find a wrong monitor, see
MicrosoftEdge/WebView2Feedback#2549 (comment).
  • Loading branch information
amrbashir committed Jul 11, 2022
1 parent 74425e8 commit 4d58354
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/platform_impl/windows/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1982,9 +1982,10 @@ unsafe fn public_window_callback_inner<T: 'static>(
if !win_flags.contains(WindowFlags::DECORATIONS) {
// adjust the maximized borderless window so it doesn't cover the taskbar
if util::is_maximized(window) {
let monitor = monitor::current_monitor(window);
if let Ok(monitor_info) = monitor::get_monitor_info(monitor.hmonitor()) {
let params = &mut *(lparam.0 as *mut NCCALCSIZE_PARAMS);
let params = &mut *(lparam.0 as *mut NCCALCSIZE_PARAMS);
if let Ok(monitor_info) =
monitor::get_monitor_info(MonitorFromRect(&params.rgrc[0], MONITOR_DEFAULTTONULL))
{
params.rgrc[0] = monitor_info.monitorInfo.rcWork;
}
}
Expand Down

0 comments on commit 4d58354

Please sign in to comment.