diff --git a/src/cascadia/ut_app/TerminalApp.Unit.Tests.manifest b/src/cascadia/ut_app/TerminalApp.Unit.Tests.manifest index 3be6f3c7bf9..f48f0e43cd5 100644 --- a/src/cascadia/ut_app/TerminalApp.Unit.Tests.manifest +++ b/src/cascadia/ut_app/TerminalApp.Unit.Tests.manifest @@ -20,6 +20,7 @@ UI Variable, GH #12452 --> + diff --git a/src/interactivity/win32/window.cpp b/src/interactivity/win32/window.cpp index 46d360f1955..973504ee703 100644 --- a/src/interactivity/win32/window.cpp +++ b/src/interactivity/win32/window.cpp @@ -966,9 +966,9 @@ void Window::s_CalculateWindowRect(const til::size coordWindowInChars, // Expands a rect by the size of the non-client area (caption bar, resize borders, // scroll bars, etc), which depends on the window styles and DPI -void Window:: s_ExpandRectByNonClientSize(HWND const hWnd, - UINT dpi, - _Inout_ til::rect* const prectWindow) +void Window::s_ExpandRectByNonClientSize(HWND const hWnd, + UINT dpi, + _Inout_ til::rect* const prectWindow) { DWORD dwStyle = GetWindowStyle(hWnd); DWORD dwExStyle = GetWindowExStyle(hWnd); diff --git a/src/interactivity/win32/windowproc.cpp b/src/interactivity/win32/windowproc.cpp index 71db72d348b..4af0492cdd8 100644 --- a/src/interactivity/win32/windowproc.cpp +++ b/src/interactivity/win32/windowproc.cpp @@ -251,6 +251,7 @@ static constexpr TsfDataProvider s_tsfDataProvider; return FALSE; } + // Format our final suggestion for consumption. UnlockConsole(); return TRUE; } @@ -875,26 +876,31 @@ bool Window::_HandleGetDpiScaledSize(UINT dpiNew, _Inout_ SIZE* pSizeNew) const til::size fontSizeNew = fontInfoNew.GetSize(); // The provided size is the window rect, which includes non-client area - // (caption bars, resize borders, scroll bars, etc). To scale the client - // area by the new/previous font sizes, the non-client area size is removed - // from the rect here and added back at the end. - - // Expand an empty rect by the size of the current non-client area (using - // the window's current DPI). This gives us the size of the non client area. - // Reduce the provided size by the non-client area size, which gives us the - // new client area size at the previous DPI. + // (caption bars, resize borders, scroll bars, etc). We want to scale the + // client area separately from the non-client area. The client area will be + // scaled using the new/old font sizes, so that the size of the grid (rows/ + // columns) does not change. + + // Subtract the size of the window's current non-client area from the + // provided size. This gives us the new client area size at the previous DPI. til::rect rc; s_ExpandRectByNonClientSize(hwnd, dpiCurrent, &rc); pSizeNew->cx -= rc.width(); pSizeNew->cy -= rc.height(); - // Scale the size of the client rect by the change in font size. + // Scale the size of the client rect by the new/old font sizes. pSizeNew->cx = MulDiv(pSizeNew->cx, fontSizeNew.width, fontSizeCurrent.width); pSizeNew->cy = MulDiv(pSizeNew->cy, fontSizeNew.height, fontSizeCurrent.height); - // Expand the scaled client size by the non-client area (using the new DPI). + // Add the size of the non-client area at the new DPI to the final size, + // getting the new window rect (the output of this function). rc = { 0, 0, pSizeNew->cx, pSizeNew->cy }; s_ExpandRectByNonClientSize(hwnd, dpiNew, &rc); + + // Write the final size to the out parameter. + // If not Maximized/Arranged (snapped), this will determine the size of the + // rect in the WM_DPICHANGED message. Otherwise, the provided size is the + // normal position (restored, last non-Maximized/Arranged). pSizeNew->cx = rc.width(); pSizeNew->cy = rc.height();