This commit is contained in:
Mike Griese 2021-11-03 12:47:57 -05:00
parent 0ef867319d
commit 1915a06f6e
2 changed files with 23 additions and 12 deletions

View file

@ -102,19 +102,30 @@ namespace winrt::TerminalApp::implementation
{
MinMaxCloseControl().PressButton(button);
}
void TitlebarControl::ClickButton(CaptionButton button)
winrt::fire_and_forget TitlebarControl::ClickButton(CaptionButton button)
{
switch (button)
// GH#8587: Handle this on the _next_ pass of the UI thread. If we
// handle this immediately, then we'll accidentally leave the button in
// the "Hovered" state when we minimize. This will leave the button
// visibly hovered in the taskbar preview for our window.
auto weakThis{ get_weak() };
co_await MinMaxCloseControl().Dispatcher();
if (auto self{ weakThis.get() })
{
case CaptionButton::Minimize:
Minimize_Click(nullptr, nullptr);
break;
case CaptionButton::Maximize:
Maximize_Click(nullptr, nullptr);
break;
case CaptionButton::Close:
Close_Click(nullptr, nullptr);
break;
// Just handle this in the same way we would if the button were
// clicked normally.
switch (button)
{
case CaptionButton::Minimize:
Minimize_Click(nullptr, nullptr);
break;
case CaptionButton::Maximize:
Maximize_Click(nullptr, nullptr);
break;
case CaptionButton::Close:
Close_Click(nullptr, nullptr);
break;
}
}
}
void TitlebarControl::ReleaseButtons()

View file

@ -16,7 +16,7 @@ namespace winrt::TerminalApp::implementation
void HoverButton(CaptionButton button);
void PressButton(CaptionButton button);
void ClickButton(CaptionButton button);
winrt::fire_and_forget ClickButton(CaptionButton button);
void ReleaseButtons();
IInspectable Content();