mirror of
https://github.com/microsoft/terminal.git
synced 2026-05-18 18:56:25 +00:00
I cannot believe it was that easy
This commit is contained in:
@@ -14,9 +14,11 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
|
||||
}
|
||||
|
||||
CommandlineArgs(const winrt::array_view<const winrt::hstring>& args,
|
||||
winrt::hstring currentDirectory) :
|
||||
winrt::hstring currentDirectory,
|
||||
const uint32_t showWindowCommand) :
|
||||
_args{ args.begin(), args.end() },
|
||||
_cwd{ currentDirectory }
|
||||
_cwd{ currentDirectory },
|
||||
_ShowWindowCommand{ showWindowCommand }
|
||||
{
|
||||
}
|
||||
|
||||
@@ -25,6 +27,8 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
|
||||
void Commandline(const winrt::array_view<const winrt::hstring>& value);
|
||||
winrt::com_array<winrt::hstring> Commandline();
|
||||
|
||||
WINRT_PROPERTY(uint32_t, ShowWindowCommand, SW_NORMAL); // SW_NORMAL is 1, 0 is SW_HIDE
|
||||
|
||||
private:
|
||||
winrt::com_array<winrt::hstring> _args;
|
||||
winrt::hstring _cwd;
|
||||
|
||||
@@ -46,7 +46,8 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
|
||||
_Id{ windowInfo.Id() ? windowInfo.Id().Value() : 0 }, // We'll use 0 as a sentinel, since no window will ever get to have that ID
|
||||
_WindowName{ windowInfo.WindowName() },
|
||||
_args{ command.Commandline() },
|
||||
_CurrentDirectory{ command.CurrentDirectory() } {};
|
||||
_CurrentDirectory{ command.CurrentDirectory() },
|
||||
_ShowWindowCommand{ command.ShowWindowCommand() } {};
|
||||
|
||||
WindowRequestedArgs(const winrt::hstring& window, const winrt::hstring& content, const Windows::Foundation::IReference<Windows::Foundation::Rect>& bounds) :
|
||||
_Id{ 0u },
|
||||
@@ -63,6 +64,7 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
|
||||
WINRT_PROPERTY(winrt::hstring, WindowName);
|
||||
WINRT_PROPERTY(winrt::hstring, CurrentDirectory);
|
||||
WINRT_PROPERTY(winrt::hstring, Content);
|
||||
WINRT_PROPERTY(uint32_t, ShowWindowCommand, SW_NORMAL);
|
||||
WINRT_PROPERTY(Windows::Foundation::IReference<Windows::Foundation::Rect>, InitialBounds);
|
||||
|
||||
private:
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace Microsoft.Terminal.Remoting
|
||||
|
||||
String[] Commandline { get; };
|
||||
String CurrentDirectory { get; };
|
||||
UInt32 ShowWindowCommand { get; };
|
||||
|
||||
String Content { get; };
|
||||
Windows.Foundation.IReference<Windows.Foundation.Rect> InitialBounds { get; };
|
||||
|
||||
@@ -7,10 +7,11 @@ namespace Microsoft.Terminal.Remoting
|
||||
runtimeclass CommandlineArgs
|
||||
{
|
||||
CommandlineArgs();
|
||||
CommandlineArgs(String[] args, String cwd);
|
||||
CommandlineArgs(String[] args, String cwd, UInt32 showWindowCommand);
|
||||
|
||||
String[] Commandline { get; set; };
|
||||
String CurrentDirectory();
|
||||
UInt32 ShowWindowCommand { get; };
|
||||
};
|
||||
|
||||
runtimeclass RenameRequestArgs
|
||||
|
||||
@@ -319,7 +319,7 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
|
||||
// If the name wasn't specified, this will be an empty string.
|
||||
p->WindowName(args.WindowName());
|
||||
|
||||
p->ExecuteCommandline(*winrt::make_self<CommandlineArgs>(args.Commandline(), args.CurrentDirectory()));
|
||||
p->ExecuteCommandline(*winrt::make_self<CommandlineArgs>(args.Commandline(), args.CurrentDirectory(), args.ShowWindowCommand()));
|
||||
|
||||
_monarch.AddPeasant(*p);
|
||||
|
||||
|
||||
@@ -195,6 +195,8 @@ void AppHost::_HandleCommandlineArgs(const Remoting::WindowRequestedArgs& window
|
||||
}
|
||||
}
|
||||
|
||||
_launchShowWindowCommand = windowArgs.ShowWindowCommand();
|
||||
|
||||
// This is a fix for GH#12190 and hopefully GH#12169.
|
||||
//
|
||||
// If the commandline we were provided is going to result in us only
|
||||
@@ -1237,7 +1239,11 @@ winrt::fire_and_forget AppHost::_WindowInitializedHandler(const winrt::Windows::
|
||||
// match the initial settings, and then call ShowWindow to finally make us
|
||||
// visible.
|
||||
|
||||
auto nCmdShow = SW_SHOWDEFAULT;
|
||||
// Use the visibility that we were originally requested with as a base. We
|
||||
// can't just use SW_SHOWDEFAULT, because that is set on a per-process
|
||||
// basis. That means that a second window needs to have its STARTUPINFO's
|
||||
// wShowCmd passed into the original process.
|
||||
auto nCmdShow = _launchShowWindowCommand;
|
||||
if (WI_IsFlagSet(_launchMode, LaunchMode::MaximizedMode))
|
||||
{
|
||||
nCmdShow = SW_MAXIMIZE;
|
||||
|
||||
@@ -43,6 +43,8 @@ private:
|
||||
|
||||
std::shared_ptr<ThrottledFuncTrailing<bool>> _showHideWindowThrottler;
|
||||
|
||||
uint32_t _launchShowWindowCommand{ SW_NORMAL };
|
||||
|
||||
void _preInit();
|
||||
|
||||
void _HandleCommandlineArgs(const winrt::Microsoft::Terminal::Remoting::WindowRequestedArgs& args);
|
||||
|
||||
@@ -73,7 +73,15 @@ bool WindowEmperor::HandleCommandlineArgs()
|
||||
_buildArgsFromCommandline(args);
|
||||
auto cwd{ wil::GetCurrentDirectoryW<std::wstring>() };
|
||||
|
||||
Remoting::CommandlineArgs eventArgs{ { args }, { cwd } };
|
||||
// Get the requested initial state of the window from our startup info. For
|
||||
// something like `start /min`, this will set the wShowWindow member to
|
||||
// SW_SHOWMINIMIZED. We'll need to make sure is bubbled all the way through,
|
||||
// so we can open a new window with the stame state.
|
||||
STARTUPINFOW si;
|
||||
GetStartupInfoW(&si);
|
||||
const auto showWindow = si.wShowWindow;
|
||||
|
||||
Remoting::CommandlineArgs eventArgs{ { args }, { cwd }, showWindow };
|
||||
|
||||
const auto isolatedMode{ _app.Logic().IsolatedMode() };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user