Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use standard 1px window borders on NC Island Window #3394

Merged
merged 36 commits into from
Nov 4, 2019
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
6744d21
test things
Oct 31, 2019
1d33e22
Fix DwmExtendFrameIntoClientArea values
Oct 31, 2019
1dd0ee6
Fix WM_NCHITTEST handling
Oct 31, 2019
cd73d35
Position the XAML island window correctly
Oct 31, 2019
02a5e18
Fix weird colors in drag bar and hide old title bar buttons
Oct 31, 2019
19d67a5
Fix the window's position when maximized
Oct 31, 2019
214f086
Add comment
Oct 31, 2019
e08d973
Add support for dark theme on the frame
Oct 31, 2019
e37ace4
Changes for PR
Oct 31, 2019
046633c
DRY shared code between conhost and new terminal
Oct 31, 2019
a7132a3
Add noexcept in ThemeUtils
Oct 31, 2019
43b364f
Fix drag bar and remove dead code
Nov 1, 2019
dcbc115
Remove dead code and use cached DPI
Nov 1, 2019
f95693c
Refactor code
Nov 1, 2019
f55f4df
Remove impossible TODO
Nov 1, 2019
d3ab79f
More refactoring
Nov 1, 2019
3b7b6b3
format
Nov 1, 2019
d16c141
little changes for PR
Nov 1, 2019
f58702e
Refactor and found better way to just have the border at the top
Nov 1, 2019
41938c9
Add comment
Nov 1, 2019
75c1954
Use system metrics instead of hardcoding resize border height
Nov 2, 2019
424bbc4
Fix code that worked but that wasn't right
Nov 2, 2019
4c8b8e5
Changes for review
Nov 2, 2019
9b1b5e1
Revert "Refactor and found better way to just have the border at the …
Nov 2, 2019
1c85587
More changes for review
Nov 2, 2019
e8db54c
Fix comments
Nov 2, 2019
5764926
Use theme from app settings instead of system theme. Improve comments…
Nov 3, 2019
e448cfe
Changes for review
Nov 3, 2019
ace60e7
Fix initial position DPI handling bug and apply review changes
Nov 4, 2019
e0d0619
nit
Nov 4, 2019
02ae511
Fix thick borders with DPI > 96
Nov 4, 2019
48cd380
Update TODO
Nov 4, 2019
89eb7b4
fix comment
Nov 4, 2019
792969a
sorry I push too fast before reviewing my own code
Nov 4, 2019
8ae87fc
format
Nov 4, 2019
dc46679
Revert TODO update
Nov 4, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 4 additions & 57 deletions src/cascadia/WindowsTerminal/NonClientIslandWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,14 +305,8 @@ void NonClientIslandWindow::_UpdateDragRegion()
// - the HRESULT returned by DwmExtendFrameIntoClientArea.
[[nodiscard]] HRESULT NonClientIslandWindow::_UpdateFrameMargins() const noexcept
{
const auto dpi = ::GetDpiForWindow(_window.get());
if (dpi == 0)
{
winrt::throw_last_error();
}

RECT frameRc = {};
::AdjustWindowRectExForDpi(&frameRc, GetWindowStyle(_window.get()), FALSE, 0, dpi);
::AdjustWindowRectExForDpi(&frameRc, GetWindowStyle(_window.get()), FALSE, 0, _currentDpi);

// We removed the titlebar from the non client area (see handling of
// WM_NCCALCSIZE) and now we add it back, but into the client area to paint
Expand Down Expand Up @@ -355,16 +349,10 @@ void NonClientIslandWindow::_UpdateDragRegion()
// Calculate new NCCALCSIZE_PARAMS based on custom NCA inset.
NCCALCSIZE_PARAMS* pncsp = reinterpret_cast<NCCALCSIZE_PARAMS*>(lParam);

const auto dpi = ::GetDpiForWindow(_window.get());
if (dpi == 0)
{
winrt::throw_last_error();
}

const auto windowStyle = GetWindowStyle(_window.get());

RECT frameRc = {};
if (::AdjustWindowRectExForDpi(&frameRc, windowStyle, FALSE, 0, dpi) == 0)
if (::AdjustWindowRectExForDpi(&frameRc, windowStyle, FALSE, 0, _currentDpi) == 0)
{
winrt::throw_last_error();
}
Expand All @@ -386,8 +374,8 @@ void NonClientIslandWindow::_UpdateDragRegion()
// only part of the frame that we change.
const auto resizeBorderHeight =
// there isn't a SM_CYPADDEDBORDER for the Y axis
GetSystemMetricsForDpi(SM_CXPADDEDBORDER, dpi) +
GetSystemMetricsForDpi(SM_CYFRAME, dpi);
GetSystemMetricsForDpi(SM_CXPADDEDBORDER, _currentDpi) +
GetSystemMetricsForDpi(SM_CYFRAME, _currentDpi);
clientTop += resizeBorderHeight;
}

Expand Down Expand Up @@ -457,47 +445,6 @@ void NonClientIslandWindow::_UpdateDragRegion()

return 0;
}

case WM_NCLBUTTONDOWN:
beviu marked this conversation as resolved.
Show resolved Hide resolved
case WM_NCLBUTTONUP:
case WM_NCMBUTTONDOWN:
case WM_NCMBUTTONUP:
case WM_NCRBUTTONDOWN:
case WM_NCRBUTTONUP:
case WM_NCXBUTTONDOWN:
case WM_NCXBUTTONUP:
{
// If we clicked in the titlebar, raise an event so the app host can
// dispatch an appropriate event.
_DragRegionClickedHandlers();
break;
}

case WM_WINDOWPOSCHANGING:
{
// Enforce maximum size here instead of WM_GETMINMAXINFO. If we return
// it in WM_GETMINMAXINFO, then it will be enforced when snapping across
// DPI boundaries (bad.)
LPWINDOWPOS lpwpos = reinterpret_cast<LPWINDOWPOS>(lParam);
if (lpwpos == nullptr)
{
break;
}
if (_HandleWindowPosChanging(lpwpos))
{
return 0;
}
else
{
break;
}
}
case WM_DPICHANGED:
beviu marked this conversation as resolved.
Show resolved Hide resolved
{
auto lprcNewScale = reinterpret_cast<RECT*>(lParam);
OnSize(RECT_WIDTH(lprcNewScale), RECT_HEIGHT(lprcNewScale));
break;
}
}

return IslandWindow::MessageHandler(message, wParam, lParam);
Expand Down