Pane officially opened via the serialized actions, via across the process boundary

This commit is contained in:
Mike Griese
2022-07-14 15:38:37 -05:00
parent 5cb4ab1a9e
commit 1f2bb760eb
7 changed files with 41 additions and 5 deletions

View File

@@ -205,7 +205,8 @@ Pane::BuildStartupState Pane::BuildStartupActions(uint32_t currentId, uint32_t n
// When creating a pane the split size is the size of the new pane
// and not position.
const auto splitDirection = _splitState == SplitState::Horizontal ? SplitDirection::Down : SplitDirection::Right;
SplitPaneArgs args{ SplitType::Manual, splitDirection, 1. - _desiredSplitPosition, terminalArgs };
const auto splitSize = (asContent && _IsLeaf() ? .5 : 1. - _desiredSplitPosition);
SplitPaneArgs args{ SplitType::Manual, splitDirection, splitSize, terminalArgs };
actionAndArgs.Args(args);
return actionAndArgs;

View File

@@ -1937,6 +1937,15 @@ namespace winrt::TerminalApp::implementation
content;
tabIndex;
auto args = ActionAndArgs::Deserialize(content);
// TODO! if the first action is a split pane and tabIndex > tabs.size,
// then remove it and insert an equivalent newTab
for (const auto& action : args)
{
_actionDispatch->DoAction(action);
}
co_await wil::resume_foreground(Dispatcher());
}
// Method Description:
@@ -2038,6 +2047,8 @@ namespace winrt::TerminalApp::implementation
const float splitSize,
PreparedContent preppedContent)
{
// _GetFocusedTabImpl requires us to be on the UI thread
co_await wil::resume_foreground(Dispatcher(), CoreDispatcherPriority::Normal);
auto focusedTab{ _GetFocusedTabImpl() };
// Clever hack for a crash in startup, with multiple sub-commands. Say
@@ -2720,7 +2731,9 @@ namespace winrt::TerminalApp::implementation
{
PreparedContent preppedContent;
_evaluateSettings(newTerminalArgs, duplicate, preppedContent.controlSettings, preppedContent.profile);
preppedContent.initContentProc = _CreateNewContentProcess(preppedContent.profile, preppedContent.controlSettings);
preppedContent.initContentProc = (newTerminalArgs && newTerminalArgs.ContentGuid() != winrt::guid{}) ?
_AttachToContentProcess(newTerminalArgs.ContentGuid()) :
_CreateNewContentProcess(preppedContent.profile, preppedContent.controlSettings);
return preppedContent;
}
@@ -2765,7 +2778,7 @@ namespace winrt::TerminalApp::implementation
co_return content;
}
ContentProcess TerminalPage::_AttachToContentProcess(const winrt::guid contentGuid)
Windows::Foundation::IAsyncOperation<ContentProcess> TerminalPage::_AttachToContentProcess(const winrt::guid contentGuid)
{
ContentProcess content{ nullptr };
try
@@ -2775,7 +2788,7 @@ namespace winrt::TerminalApp::implementation
catch (winrt::hresult_error hr)
{
}
return content;
co_return content;
}
// INVARIANT: Must be called on UI thread!

View File

@@ -482,7 +482,7 @@ namespace winrt::TerminalApp::implementation
const bool duplicate);
Windows::Foundation::IAsyncOperation<winrt::Microsoft::Terminal::Control::ContentProcess> _CreateNewContentProcess(winrt::Microsoft::Terminal::Settings::Model::Profile profile,
winrt::Microsoft::Terminal::Settings::Model::TerminalSettingsCreateResult settings);
winrt::Microsoft::Terminal::Control::ContentProcess _AttachToContentProcess(const winrt::guid contentGuid);
Windows::Foundation::IAsyncOperation<winrt::Microsoft::Terminal::Control::ContentProcess> _AttachToContentProcess(const winrt::guid contentGuid);
winrt::fire_and_forget _createNewTabFromContent(PreparedContent preppedContent,
std::function<void(const winrt::com_ptr<TerminalTab>&)> postInitTab = nullptr);

View File

@@ -1343,6 +1343,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// - duration - How long the note should be sustained (in microseconds).
void ControlCore::_terminalPlayMidiNote(const int noteNumber, const int velocity, const std::chrono::microseconds duration)
{
// TODO! GH#1256 This is intentionally here to conflict with https://github.com/microsoft/terminal/pull/13471#pullrequestreview-1039353718
// When we do tearout, we'll need to also recreate the midi thing
// We create the audio instance on demand, and lock it for the duration
// of the note output so it can't be destroyed while in use.
auto& midiAudio = _getMidiAudio();
@@ -1989,6 +1992,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
{
if (owner != _owningHwnd && _connection)
{
// TODO GH#1256 change the midi HWND too
if (auto conpty{ _connection.try_as<TerminalConnection::ConptyConnection>() })
{
conpty.ReparentWindow(owner);

View File

@@ -426,5 +426,21 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
auto str = Json::writeString(wbuilder, json);
return winrt::to_hstring(str);
}
winrt::Windows::Foundation::Collections::IVector<Model::ActionAndArgs> ActionAndArgs::Deserialize(winrt::hstring content)
{
auto data = winrt::to_string(content);
std::string errs;
std::unique_ptr<Json::CharReader> reader{ Json::CharReaderBuilder::CharReaderBuilder().newCharReader() };
Json::Value root;
if (!reader->parse(data.data(), data.data() + data.size(), &root, &errs))
{
throw winrt::hresult_error(WEB_E_INVALID_JSON_STRING, winrt::to_hstring(errs));
}
winrt::Windows::Foundation::Collections::IVector<Model::ActionAndArgs> result{ nullptr };
JsonUtils::GetValueForKey(root, "actions", result);
return result;
}
}

View File

@@ -17,6 +17,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
static Json::Value ToJson(const Model::ActionAndArgs& val);
static winrt::hstring Serialize(winrt::Windows::Foundation::Collections::IVector<Model::ActionAndArgs> args);
static winrt::Windows::Foundation::Collections::IVector<Model::ActionAndArgs> Deserialize(winrt::hstring content);
ActionAndArgs() = default;
ActionAndArgs(ShortcutAction action);

View File

@@ -25,6 +25,7 @@ namespace Microsoft.Terminal.Settings.Model
ActionAndArgs(ShortcutAction action, IActionArgs args);
static String Serialize(IVector<ActionAndArgs> args);
static IVector<ActionAndArgs> Deserialize(String content);
IActionArgs Args;
ShortcutAction Action;