Skip to content

Commit

Permalink
comments, format script
Browse files Browse the repository at this point in the history
  • Loading branch information
Evan Koschik committed Dec 20, 2024
1 parent 88e8d24 commit f6093ec
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/cascadia/ut_app/TerminalApp.Unit.Tests.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
UI Variable, GH #12452 -->
<maxversiontested Id="10.0.22000.0"/>
<maxversiontested Id="10.0.22621.0"/>
<maxversiontested Id="10.0.26100.0"/>
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>
Expand Down
6 changes: 3 additions & 3 deletions src/interactivity/win32/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
26 changes: 16 additions & 10 deletions src/interactivity/win32/windowproc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ static constexpr TsfDataProvider s_tsfDataProvider;
return FALSE;
}

// Format our final suggestion for consumption.
UnlockConsole();
return TRUE;
}
Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit f6093ec

Please sign in to comment.