Skip to content

Commit c9a1f12

Browse files
carlos-zamoraDHowett
authored andcommitted
Fix 'closeWindow' ignoring confirmation (#18434)
Reroutes the `closeWindow` action to use the `CloseWindow()` method like the window's X button does. This includes logic to display the confirmation dialog. Also removes `CloseRequested` as it was only used by this action handler. We already have `CloseWindowRequested` so we're just using that instead. ## Validation Steps Performed ✅ `closeWindow` action while multiple tabs opened brings up the confirmation dialog Closes #17613 (cherry picked from commit fb7b0e1) Service-Card-Id: PVTI_lADOAF3p4s4AmhmszgWkUeM Service-Version: 1.21
1 parent 318fd6a commit c9a1f12

File tree

7 files changed

+1
-9
lines changed

7 files changed

+1
-9
lines changed

src/cascadia/TerminalApp/AppActionHandlers.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ namespace winrt::TerminalApp::implementation
118118
void TerminalPage::_HandleCloseWindow(const IInspectable& /*sender*/,
119119
const ActionEventArgs& args)
120120
{
121-
CloseRequested.raise(nullptr, nullptr);
121+
CloseWindow();
122122
args.Handled(true);
123123
}
124124

src/cascadia/TerminalApp/TerminalPage.h

-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ namespace winrt::TerminalApp::implementation
186186
til::typed_event<IInspectable, winrt::TerminalApp::RenameWindowRequestedArgs> RenameWindowRequested;
187187
til::typed_event<IInspectable, IInspectable> SummonWindowRequested;
188188

189-
til::typed_event<IInspectable, IInspectable> CloseRequested;
190189
til::typed_event<IInspectable, IInspectable> OpenSystemMenu;
191190
til::typed_event<IInspectable, IInspectable> QuitRequested;
192191
til::typed_event<IInspectable, winrt::Microsoft::Terminal::Control::ShowWindowArgs> ShowWindowChanged;

src/cascadia/TerminalApp/TerminalPage.idl

-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ namespace TerminalApp
9797
event Windows.Foundation.TypedEventHandler<Object, RenameWindowRequestedArgs> RenameWindowRequested;
9898
event Windows.Foundation.TypedEventHandler<Object, Object> SummonWindowRequested;
9999

100-
event Windows.Foundation.TypedEventHandler<Object, Object> CloseRequested;
101100
event Windows.Foundation.TypedEventHandler<Object, Object> OpenSystemMenu;
102101
event Windows.Foundation.TypedEventHandler<Object, Microsoft.Terminal.Control.ShowWindowArgs> ShowWindowChanged;
103102

src/cascadia/TerminalApp/TerminalWindow.h

-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ namespace winrt::TerminalApp::implementation
223223
FORWARDED_TYPED_EVENT(IdentifyWindowsRequested, Windows::Foundation::IInspectable, Windows::Foundation::IInspectable, _root, IdentifyWindowsRequested);
224224
FORWARDED_TYPED_EVENT(RenameWindowRequested, Windows::Foundation::IInspectable, winrt::TerminalApp::RenameWindowRequestedArgs, _root, RenameWindowRequested);
225225
FORWARDED_TYPED_EVENT(SummonWindowRequested, Windows::Foundation::IInspectable, Windows::Foundation::IInspectable, _root, SummonWindowRequested);
226-
FORWARDED_TYPED_EVENT(CloseRequested, Windows::Foundation::IInspectable, Windows::Foundation::IInspectable, _root, CloseRequested);
227226
FORWARDED_TYPED_EVENT(OpenSystemMenu, Windows::Foundation::IInspectable, Windows::Foundation::IInspectable, _root, OpenSystemMenu);
228227
FORWARDED_TYPED_EVENT(QuitRequested, Windows::Foundation::IInspectable, Windows::Foundation::IInspectable, _root, QuitRequested);
229228
FORWARDED_TYPED_EVENT(ShowWindowChanged, Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Control::ShowWindowArgs, _root, ShowWindowChanged);

src/cascadia/TerminalApp/TerminalWindow.idl

-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ namespace TerminalApp
127127
event Windows.Foundation.TypedEventHandler<Object, RenameWindowRequestedArgs> RenameWindowRequested;
128128
event Windows.Foundation.TypedEventHandler<Object, Object> IsQuakeWindowChanged;
129129
event Windows.Foundation.TypedEventHandler<Object, Object> SummonWindowRequested;
130-
event Windows.Foundation.TypedEventHandler<Object, Object> CloseRequested;
131130
event Windows.Foundation.TypedEventHandler<Object, Object> OpenSystemMenu;
132131
event Windows.Foundation.TypedEventHandler<Object, Object> QuitRequested;
133132
event Windows.Foundation.TypedEventHandler<Object, TerminalApp.SystemMenuChangeArgs> SystemMenuChangeRequested;

src/cascadia/WindowsTerminal/AppHost.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,6 @@ void AppHost::Initialize()
320320
_windowCallbacks.WindowCloseButtonClicked = _window->WindowCloseButtonClicked([this]() {
321321
_windowLogic.CloseWindow();
322322
});
323-
// If the user requests a close in another way handle the same as if the 'X'
324-
// was clicked.
325-
_revokers.CloseRequested = _windowLogic.CloseRequested(winrt::auto_revoke, { this, &AppHost::_CloseRequested });
326323

327324
// Add an event handler to plumb clicks in the titlebar area down to the
328325
// application layer.

src/cascadia/WindowsTerminal/AppHost.h

-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ class AppHost : public std::enable_shared_from_this<AppHost>
178178
winrt::Microsoft::Terminal::Remoting::Peasant::AttachRequested_revoker AttachRequested;
179179

180180
winrt::TerminalApp::TerminalWindow::Initialized_revoker Initialized;
181-
winrt::TerminalApp::TerminalWindow::CloseRequested_revoker CloseRequested;
182181
winrt::TerminalApp::TerminalWindow::RequestedThemeChanged_revoker RequestedThemeChanged;
183182
winrt::TerminalApp::TerminalWindow::FullscreenChanged_revoker FullscreenChanged;
184183
winrt::TerminalApp::TerminalWindow::FocusModeChanged_revoker FocusModeChanged;

0 commit comments

Comments
 (0)