Skip to content

Commit ed7ae42

Browse files
trop[bot]MarshallOfSound
authored andcommitted
fix: ensure that the "top" coordinate of the inner frame is correct (electron#20052)
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.
1 parent 828038d commit ed7ae42

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

atom/browser/native_window_views_win.cc

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,21 @@ bool NativeWindowViews::PreHandleMSG(UINT message,
389389
// https://blogs.msdn.microsoft.com/wpfsdk/2008/09/08/custom-window-chrome-in-wpf/
390390
DefWindowProcW(GetAcceleratedWidget(), WM_NCCALCSIZE, w_param, l_param);
391391

392+
// When fullscreen the window has no border
393+
int border = 0;
394+
if (!IsFullscreen()) {
395+
// When not fullscreen calculate the border size
396+
border = GetSystemMetrics(SM_CXFRAME) +
397+
GetSystemMetrics(SM_CXPADDEDBORDER);
398+
if (!thick_frame_) {
399+
border -= GetSystemMetrics(SM_CXBORDER);
400+
}
401+
}
402+
392403
if (last_window_state_ == ui::SHOW_STATE_MAXIMIZED) {
393-
params->rgrc[0].top = 0;
404+
// Position the top of the frame offset from where windows thinks by
405+
// exactly the border amount. When fullscreen this is 0.
406+
params->rgrc[0].top = PROPOSED.top + border;
394407
} else {
395408
params->rgrc[0] = PROPOSED;
396409
params->rgrc[1] = BEFORE;

0 commit comments

Comments
 (0)