diff --git a/src/cascadia/TerminalApp/AppLogic.cpp b/src/cascadia/TerminalApp/AppLogic.cpp index fe6636a4f93..c177e3e6163 100644 --- a/src/cascadia/TerminalApp/AppLogic.cpp +++ b/src/cascadia/TerminalApp/AppLogic.cpp @@ -348,11 +348,7 @@ namespace winrt::TerminalApp::implementation } _dialog = dialog; - // GH#12622: After the dialog is displayed, always clear it out. If we - // don't, we won't be able to display another! - const auto cleanup = wil::scope_exit([this]() { - _dialog = nullptr; - }); + // IMPORTANT: This is necessary as documented in the ContentDialog MSDN docs. // Since we're hosting the dialog in a Xaml island, we need to connect it to the // xaml tree somehow. @@ -400,14 +396,6 @@ namespace winrt::TerminalApp::implementation } } - // Method Description: - // - Returns true if there is no dialog currently being shown (meaning that we can show a dialog) - // - Returns false if there is a dialog currently being shown (meaning that we cannot show another dialog) - bool AppLogic::CanShowDialog() - { - return (_dialog == nullptr); - } - // Method Description: // - Displays a dialog for errors found while loading or validating the // settings. Uses the resources under the provided title and content keys diff --git a/src/cascadia/TerminalApp/AppLogic.h b/src/cascadia/TerminalApp/AppLogic.h index 582866704b4..1d43f113ba5 100644 --- a/src/cascadia/TerminalApp/AppLogic.h +++ b/src/cascadia/TerminalApp/AppLogic.h @@ -122,7 +122,6 @@ namespace winrt::TerminalApp::implementation bool GetShowTitleInTitlebar(); winrt::Windows::Foundation::IAsyncOperation ShowDialog(winrt::Windows::UI::Xaml::Controls::ContentDialog dialog); - bool CanShowDialog(); void DismissDialog(); Windows::Foundation::Collections::IMapView GlobalHotkeys(); diff --git a/src/cascadia/TerminalApp/AppLogic.idl b/src/cascadia/TerminalApp/AppLogic.idl index df0f7b3cd47..469bf27affd 100644 --- a/src/cascadia/TerminalApp/AppLogic.idl +++ b/src/cascadia/TerminalApp/AppLogic.idl @@ -108,6 +108,11 @@ namespace TerminalApp Windows.Foundation.Collections.IMapView GlobalHotkeys(); + // See IDialogPresenter and TerminalPage's DialogPresenter for more + // information. + Windows.Foundation.IAsyncOperation ShowDialog(Windows.UI.Xaml.Controls.ContentDialog dialog); + void DismissDialog(); + event Windows.Foundation.TypedEventHandler SetTitleBarContent; event Windows.Foundation.TypedEventHandler TitleChanged; event Windows.Foundation.TypedEventHandler LastTabClosed; diff --git a/src/cascadia/TerminalApp/TerminalPage.cpp b/src/cascadia/TerminalApp/TerminalPage.cpp index 851aa47a746..62c8885fffa 100644 --- a/src/cascadia/TerminalApp/TerminalPage.cpp +++ b/src/cascadia/TerminalApp/TerminalPage.cpp @@ -705,18 +705,6 @@ namespace winrt::TerminalApp::implementation ShellExecute(nullptr, nullptr, currentPath.c_str(), nullptr, nullptr, SW_SHOW); } - // Method description: - // - Called when the user closes a content dialog - // - Tells the presenter to update its knowledge of whether there is a content dialog open - void TerminalPage::_DialogCloseClick(const IInspectable&, - const ContentDialogButtonClickEventArgs&) - { - if (auto presenter{ _dialogPresenter.get() }) - { - presenter.DismissDialog(); - } - } - // Method Description: // - Helper to show a content dialog // - We only open a content dialog if there isn't one open already @@ -724,10 +712,7 @@ namespace winrt::TerminalApp::implementation { if (auto presenter{ _dialogPresenter.get() }) { - if (presenter.CanShowDialog()) - { - co_return co_await presenter.ShowDialog(FindName(name).try_as()); - } + co_return co_await presenter.ShowDialog(FindName(name).try_as()); } co_return ContentDialogResult::None; } diff --git a/src/cascadia/TerminalApp/TerminalPage.h b/src/cascadia/TerminalApp/TerminalPage.h index 1a72fe40c12..f1be2b6177d 100644 --- a/src/cascadia/TerminalApp/TerminalPage.h +++ b/src/cascadia/TerminalApp/TerminalPage.h @@ -227,7 +227,6 @@ namespace winrt::TerminalApp::implementation winrt::Windows::Foundation::IAsyncOperation _ShowCloseReadOnlyDialog(); winrt::Windows::Foundation::IAsyncOperation _ShowMultiLinePasteWarningDialog(); winrt::Windows::Foundation::IAsyncOperation _ShowLargePasteWarningDialog(); - void _DialogCloseClick(const IInspectable& sender, const Windows::UI::Xaml::Controls::ContentDialogButtonClickEventArgs& eventArgs); void _CreateNewTabFlyout(); void _OpenNewTabDropdown(); diff --git a/src/cascadia/TerminalApp/TerminalPage.idl b/src/cascadia/TerminalApp/TerminalPage.idl index b726fcf23ef..979483d0ad8 100644 --- a/src/cascadia/TerminalApp/TerminalPage.idl +++ b/src/cascadia/TerminalApp/TerminalPage.idl @@ -14,8 +14,6 @@ namespace TerminalApp interface IDialogPresenter { Windows.Foundation.IAsyncOperation ShowDialog(Windows.UI.Xaml.Controls.ContentDialog dialog); - Boolean CanShowDialog(); - void DismissDialog(); }; [default_interface] runtimeclass TerminalPage : Windows.UI.Xaml.Controls.Page, Windows.UI.Xaml.Data.INotifyPropertyChanged diff --git a/src/cascadia/TerminalApp/TerminalPage.xaml b/src/cascadia/TerminalApp/TerminalPage.xaml index 2f6e8f66960..9270e383d56 100644 --- a/src/cascadia/TerminalApp/TerminalPage.xaml +++ b/src/cascadia/TerminalApp/TerminalPage.xaml @@ -72,10 +72,27 @@ HorizontalAlignment="Stretch" VerticalAlignment="Stretch" /> + + @@ -96,26 +113,26 @@ @@ -151,8 +168,8 @@