This commit is contained in:
Leonard Hecker 2025-09-08 20:39:39 +02:00
parent 54aaa4a98a
commit 08daa13dbf
3 changed files with 12 additions and 1 deletions

View File

@ -1140,7 +1140,7 @@ void AppHost::_WindowMoved()
void AppHost::_CloseRequested(const winrt::Windows::Foundation::IInspectable& /*sender*/,
const winrt::Windows::Foundation::IInspectable& /*args*/)
{
PostMessageW(_windowManager->GetMainWindow(), WindowEmperor::WM_CLOSE_TERMINAL_WINDOW, 0, reinterpret_cast<LPARAM>(this));
_windowManager->CloseWindow(this);
}
void AppHost::_PropertyChangedHandler(const winrt::Windows::Foundation::IInspectable& /*sender*/,

View File

@ -278,6 +278,16 @@ void WindowEmperor::CreateNewWindow(winrt::TerminalApp::WindowRequestedArgs args
}
}
void WindowEmperor::CloseWindow(AppHost* host) const
{
using namespace winrt::Windows::System;
const auto dispatcherQueue = DispatcherQueue::GetForCurrentThread();
dispatcherQueue.TryEnqueue(DispatcherQueuePriority::Low, [hwnd = _window.get(), host]() {
PostMessageW(hwnd, WM_CLOSE_TERMINAL_WINDOW, 0, reinterpret_cast<LPARAM>(host));
});
}
AppHost* WindowEmperor::_mostRecentWindow() const noexcept
{
int64_t max = INT64_MIN;

View File

@ -34,6 +34,7 @@ public:
AppHost* GetWindowById(uint64_t id) const noexcept;
AppHost* GetWindowByName(std::wstring_view name) const noexcept;
void CreateNewWindow(winrt::TerminalApp::WindowRequestedArgs args);
void CloseWindow(AppHost* host) const;
void HandleCommandlineArgs(int nCmdShow);
private: