Skip to content

Commit

Permalink
THIS SHOULD GO TO THE PARENT BRANCH
Browse files Browse the repository at this point in the history
  • Loading branch information
zadjii-msft committed Mar 2, 2021
1 parent c09b5e9 commit aa51c07
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 11 additions & 3 deletions src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ namespace winrt::TerminalApp::implementation
CommandPalette().RegisterPropertyChangedCallback(UIElement::VisibilityProperty(), [this](auto&&, auto&&) {
if (CommandPalette().Visibility() == Visibility::Collapsed)
{
_CommandPaletteClosed(nullptr, nullptr);
_FocusActiveControl(nullptr, nullptr);
}
});
CommandPalette().DispatchCommandRequested({ this, &TerminalPage::_OnDispatchCommandRequested });
Expand All @@ -265,6 +265,14 @@ namespace winrt::TerminalApp::implementation

_isAlwaysOnTop = _settings.GlobalSettings().AlwaysOnTop();

auto safeRefocus = [weakThis{ get_weak() }](auto&&, auto&&) {
if (auto page{ weakThis.get() })
{
page->_FocusActiveControl(nullptr, nullptr);
}
};

WindowIdToast().Closed(safeRefocus);
// Setup mouse vanish attributes
SystemParametersInfoW(SPI_GETMOUSEVANISH, 0, &_shouldMouseVanish, false);

Expand Down Expand Up @@ -2962,8 +2970,8 @@ namespace winrt::TerminalApp::implementation
return {};
}

void TerminalPage::_CommandPaletteClosed(const IInspectable& /*sender*/,
const RoutedEventArgs& /*eventArgs*/)
void TerminalPage::_FocusActiveControl(const IInspectable& /*sender*/,
const RoutedEventArgs& /*eventArgs*/)
{
// We don't want to set focus on the tab if fly-out is open as it will be closed
// TODO GH#5400: consider checking we are not in the opening state, by hooking both Opening and Open events
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalApp/TerminalPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ namespace winrt::TerminalApp::implementation

void _CompleteInitialization();

void _CommandPaletteClosed(const IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& eventArgs);
void _FocusActiveControl(const IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& eventArgs);

void _UnZoomIfNeeded();

Expand Down

0 comments on commit aa51c07

Please sign in to comment.