Skip to content

Commit 3c38a6e

Browse files
zadjii-msftcarlos-zamora
authored andcommitted
Update the dragbar when the titlebar content size changes (#4845)
## Summary of the Pull Request Add a `SizeChanged` handler to the titlebar content UI element. It's possible that this element's size will change after the dragbar's. When that happens, the drag bar won't send another `SizeChanged` event, because the dragbar's _size_ didn't change, only it's position. ## References We originally duped this issue to #4166, but after #4829 fixed that issue, this one persisted. They're all related, and _look_ like dupes, but they weren't. ## PR Checklist * [x] Closes #4288 * [x] I work here * [ ] Tests added/passed * [n/a] Requires documentation to be updated ## Detailed Description of the Pull Request / Additional comments ## Validation Steps Performed I had a solid 100% repro that doesn't repro anymore. I've maximized, restored, resized, and generally played with the window a bunch.
1 parent dfb7f97 commit 3c38a6e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/cascadia/WindowsTerminal/NonClientIslandWindow.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,16 @@ void NonClientIslandWindow::SetContent(winrt::Windows::UI::Xaml::UIElement conte
110110
void NonClientIslandWindow::SetTitlebarContent(winrt::Windows::UI::Xaml::UIElement content)
111111
{
112112
_titlebar.Content(content);
113+
114+
// GH#4288 - add a SizeChanged handler to this content. It's possible that
115+
// this element's size will change after the dragbar's. When that happens,
116+
// the drag bar won't send another SizeChanged event, because the dragbar's
117+
// _size_ didn't change, only it's position.
118+
const auto fwe = content.try_as<winrt::Windows::UI::Xaml::FrameworkElement>();
119+
if (fwe)
120+
{
121+
fwe.SizeChanged({ this, &NonClientIslandWindow::_OnDragBarSizeChanged });
122+
}
113123
}
114124

115125
// Method Description:

0 commit comments

Comments
 (0)