Skip to content

Commit

Permalink
fix(windows): get correct monitor in WM_NCCALCSIZE, closes #471 (#472)
Browse files Browse the repository at this point in the history
* fix(windows): get correct monitor in `WM_NCCALCSIZE`, closes #471

`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).

* changefile
  • Loading branch information
amrbashir committed Jul 12, 2022
1 parent 01fb1d6 commit 9d97e4a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changes/correct-monitor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tao": patch
---

On Windows, fix assigning the wrong mintor rect to undecorated maximized window. This caused a blank window downstream in wry and tauri.
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 9d97e4a

Please sign in to comment.