|
|
|
@ -86,7 +86,7 @@ AppHost::AppHost() noexcept :
|
|
|
|
|
_window->SetAlwaysOnTop(_logic.GetInitialAlwaysOnTop());
|
|
|
|
|
_window->MakeWindow();
|
|
|
|
|
|
|
|
|
|
_windowManager.GetWindowLayoutRequested([this](auto&&, const winrt::Microsoft::Terminal::Remoting::GetWindowLayoutArgs& args) {
|
|
|
|
|
_GetWindowLayoutRequestedToken = _windowManager.GetWindowLayoutRequested([this](auto&&, const winrt::Microsoft::Terminal::Remoting::GetWindowLayoutArgs& args) {
|
|
|
|
|
// The peasants are running on separate threads, so they'll need to
|
|
|
|
|
// swap what context they are in to the ui thread to get the actual layout.
|
|
|
|
|
args.WindowLayoutJsonAsync(_GetWindowLayoutAsync());
|
|
|
|
@ -401,23 +401,38 @@ void AppHost::LastTabClosed(const winrt::Windows::Foundation::IInspectable& /*se
|
|
|
|
|
_HideNotificationIconRequested();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// We don't want to try to save layouts if we are about to close
|
|
|
|
|
_getWindowLayoutThrottler.reset();
|
|
|
|
|
_windowManager.GetWindowLayoutRequested(_GetWindowLayoutRequestedToken);
|
|
|
|
|
|
|
|
|
|
_window->Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LaunchPosition AppHost::_GetWindowLaunchPosition()
|
|
|
|
|
{
|
|
|
|
|
// Get the position of the current window. This includes the
|
|
|
|
|
// non-client already.
|
|
|
|
|
const auto window = _window->GetWindowRect();
|
|
|
|
|
|
|
|
|
|
const auto dpi = _window->GetCurrentDpi();
|
|
|
|
|
const auto nonClientArea = _window->GetNonClientFrame(dpi);
|
|
|
|
|
|
|
|
|
|
// The nonClientArea adjustment is negative, so subtract that out.
|
|
|
|
|
// This way we save the user-visible location of the terminal.
|
|
|
|
|
LaunchPosition pos{};
|
|
|
|
|
pos.X = window.left - nonClientArea.left;
|
|
|
|
|
pos.Y = window.top;
|
|
|
|
|
// If we started saving before closing, but didn't resume the event handler
|
|
|
|
|
// until after _window might be a nullptr.
|
|
|
|
|
if (!_window)
|
|
|
|
|
{
|
|
|
|
|
return pos;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// Get the position of the current window. This includes the
|
|
|
|
|
// non-client already.
|
|
|
|
|
const auto window = _window->GetWindowRect();
|
|
|
|
|
|
|
|
|
|
const auto dpi = _window->GetCurrentDpi();
|
|
|
|
|
const auto nonClientArea = _window->GetNonClientFrame(dpi);
|
|
|
|
|
|
|
|
|
|
// The nonClientArea adjustment is negative, so subtract that out.
|
|
|
|
|
// This way we save the user-visible location of the terminal.
|
|
|
|
|
pos.X = window.left - nonClientArea.left;
|
|
|
|
|
pos.Y = window.top;
|
|
|
|
|
}
|
|
|
|
|
CATCH_LOG();
|
|
|
|
|
|
|
|
|
|
return pos;
|
|
|
|
|
}
|
|
|
|
@ -723,10 +738,15 @@ winrt::Windows::Foundation::IAsyncOperation<winrt::hstring> AppHost::_GetWindowL
|
|
|
|
|
{
|
|
|
|
|
winrt::apartment_context peasant_thread;
|
|
|
|
|
|
|
|
|
|
winrt::hstring layoutJson = L"";
|
|
|
|
|
// Use the main thread since we are accessing controls.
|
|
|
|
|
co_await winrt::resume_foreground(_logic.GetRoot().Dispatcher());
|
|
|
|
|
const auto pos = _GetWindowLaunchPosition();
|
|
|
|
|
const auto layoutJson = _logic.GetWindowLayoutJson(pos);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
const auto pos = _GetWindowLaunchPosition();
|
|
|
|
|
layoutJson = _logic.GetWindowLayoutJson(pos);
|
|
|
|
|
}
|
|
|
|
|
CATCH_LOG()
|
|
|
|
|
|
|
|
|
|
// go back to give the result to the peasant.
|
|
|
|
|
co_await peasant_thread;
|
|
|
|
|