From 7ccf1f02e570c4ef8fba5834424c94b110ea8fac Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Fri, 30 Aug 2019 14:29:34 -0700 Subject: [PATCH] fix: ensure that the "top" coordinate of the inner frame is correct On multi-monitor setups where the monitors are not all origined at 0 on the Y coordinate (E.g. vertical stacked monitors) the maximize calculation was incorrect as it assumed top was "0". This instead adjusts the math to calculate the correct top value. --- shell/browser/native_window_views_win.cc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/shell/browser/native_window_views_win.cc b/shell/browser/native_window_views_win.cc index 9e2ad0280639d..3575cbd2b303a 100644 --- a/shell/browser/native_window_views_win.cc +++ b/shell/browser/native_window_views_win.cc @@ -389,8 +389,21 @@ bool NativeWindowViews::PreHandleMSG(UINT message, // https://blogs.msdn.microsoft.com/wpfsdk/2008/09/08/custom-window-chrome-in-wpf/ DefWindowProcW(GetAcceleratedWidget(), WM_NCCALCSIZE, w_param, l_param); + // When fullscreen the window has no border + int border = 0; + if (!IsFullscreen()) { + // When not fullscreen calculate the border size + border = GetSystemMetrics(SM_CXFRAME) + + GetSystemMetrics(SM_CXPADDEDBORDER); + if (!thick_frame_) { + border -= GetSystemMetrics(SM_CXBORDER); + } + } + if (last_window_state_ == ui::SHOW_STATE_MAXIMIZED) { - params->rgrc[0].top = 0; + // Position the top of the frame offset from where windows thinks by + // exactly the border amount. When fullscreen this is 0. + params->rgrc[0].top = PROPOSED.top + border; } else { params->rgrc[0] = PROPOSED; params->rgrc[1] = BEFORE;