Skip to content

Commit

Permalink
cleanup for review
Browse files Browse the repository at this point in the history
  • Loading branch information
zadjii-msft committed Jul 22, 2022
1 parent 7268e96 commit e333661
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 79 deletions.
2 changes: 1 addition & 1 deletion src/cascadia/CascadiaPackage/Package-Dev.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
<com:ComInterface>
<com:ProxyStub Id="DEC4804D-56D1-4F73-9FBE-6828E7C85C56" DisplayName="OpenConsoleHandoffProxy" Path="OpenConsoleProxy.dll"/>
<com:Interface Id="E686C757-9A35-4A1C-B3CE-0BCC8B5C69F4" ProxyStubClsid="DEC4804D-56D1-4F73-9FBE-6828E7C85C56"/>
<com:Interface Id="59D55CCE-FC8A-48B4-ACE8-0A9286C6557F" ProxyStubClsid="DEC4804D-56D1-4F73-9FBE-6828E7C85C56"/>
<com:Interface Id="AA6B364F-4A50-4176-9002-0AE755E7B5EF" ProxyStubClsid="DEC4804D-56D1-4F73-9FBE-6828E7C85C56"/>
<com:Interface Id="746E6BC0-AB05-4E38-AB14-71E86763141F" ProxyStubClsid="DEC4804D-56D1-4F73-9FBE-6828E7C85C56"/>
</com:ComInterface>
</com:Extension>
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/CascadiaPackage/Package-Pre.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
<com:ComInterface>
<com:ProxyStub Id="1833E661-CC81-4DD0-87C6-C2F74BD39EFA" DisplayName="OpenConsoleHandoffProxy" Path="OpenConsoleProxy.dll"/>
<com:Interface Id="E686C757-9A35-4A1C-B3CE-0BCC8B5C69F4" ProxyStubClsid="1833E661-CC81-4DD0-87C6-C2F74BD39EFA"/>
<com:Interface Id="59D55CCE-FC8A-48B4-ACE8-0A9286C6557F" ProxyStubClsid="1833E661-CC81-4DD0-87C6-C2F74BD39EFA"/>
<com:Interface Id="AA6B364F-4A50-4176-9002-0AE755E7B5EF" ProxyStubClsid="1833E661-CC81-4DD0-87C6-C2F74BD39EFA"/>
<com:Interface Id="746E6BC0-AB05-4E38-AB14-71E86763141F" ProxyStubClsid="1833E661-CC81-4DD0-87C6-C2F74BD39EFA"/>
</com:ComInterface>
</com:Extension>
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/CascadiaPackage/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
<com:ComInterface>
<com:ProxyStub Id="3171DE52-6EFA-4AEF-8A9F-D02BD67E7A4F" DisplayName="OpenConsoleHandoffProxy" Path="OpenConsoleProxy.dll"/>
<com:Interface Id="E686C757-9A35-4A1C-B3CE-0BCC8B5C69F4" ProxyStubClsid="3171DE52-6EFA-4AEF-8A9F-D02BD67E7A4F"/>
<com:Interface Id="59D55CCE-FC8A-48B4-ACE8-0A9286C6557F" ProxyStubClsid="3171DE52-6EFA-4AEF-8A9F-D02BD67E7A4F"/>
<com:Interface Id="AA6B364F-4A50-4176-9002-0AE755E7B5EF" ProxyStubClsid="3171DE52-6EFA-4AEF-8A9F-D02BD67E7A4F"/>
<com:Interface Id="746E6BC0-AB05-4E38-AB14-71E86763141F" ProxyStubClsid="3171DE52-6EFA-4AEF-8A9F-D02BD67E7A4F"/>
</com:ComInterface>
</com:Extension>
Expand Down
17 changes: 0 additions & 17 deletions src/cascadia/TerminalConnection/ConptyConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,27 +214,10 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
THROW_IF_FAILED(ConptyPackPseudoConsole(hServerProcess, hRef, hSig, &_hPC));
_piClient.hProcess = hClientProcess;

#pragma warning(suppress : 26477 26485 26494 26482 26446) // We don't control TraceLoggingWrite
TraceLoggingWrite(
g_hTerminalConnectionProvider,
"ConptyConnection_CreatedForDefTerm",
TraceLoggingDescription("Event emitted when ConPTY connection is started for a defterm connection"),
TraceLoggingGuid(_guid, "SessionGuid", "The new connection's GUID"),
TraceLoggingKeyword(TIL_KEYWORD_TRACE));

_startupInfo.title = winrt::hstring{ startupInfo.pszTitle };
_startupInfo.iconPath = winrt::hstring{ startupInfo.pszIconPath };
_startupInfo.iconIndex = startupInfo.iconIndex;

#pragma warning(suppress : 26477 26485 26494 26482 26446) // We don't control TraceLoggingWrite
TraceLoggingWrite(
g_hTerminalConnectionProvider,
"ConPty_GotStartupInfoConnected",
TraceLoggingDescription("TODO! debugging only"),
TraceLoggingWideString(_startupInfo.title.c_str(), "Title", "The title from the connection"),
TraceLoggingWideString(_startupInfo.iconPath.c_str(), "Icon", "The icon from the connection"),
TraceLoggingKeyword(TIL_KEYWORD_TRACE));
// DebugBreak();
try
{
_commandline = _commandlineFromProcess(hClientProcess);
Expand Down
6 changes: 3 additions & 3 deletions src/host/proxy/ITerminalHandoff.idl
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import "ocidl.idl";

typedef struct _TERMINAL_STARTUP_INFO
{
/*[in, string] */LPCWSTR pszTitle;
/*[in, string] */LPCWSTR pszIconPath;
LPCWSTR pszTitle;
LPCWSTR pszIconPath;
LONG iconIndex;
} TERMINAL_STARTUP_INFO;

[
object,
uuid(59D55CCE-FC8A-48B4-ACE8-0A9286C6557F)
uuid(AA6B364F-4A50-4176-9002-0AE755E7B5EF)
] interface ITerminalHandoff : IUnknown
{
HRESULT EstablishPtyHandoff([in, system_handle(sh_pipe)] HANDLE in,
Expand Down
102 changes: 46 additions & 56 deletions src/host/srvinit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,71 +526,61 @@ try
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE),
TraceLoggingKeyword(TIL_KEYWORD_TRACE));

// DebugBreak();
// As a part of defterm handoff, we're gonna try to pull a lot of
// information out of the link and startup info, so we can let the terminal
// know these things as well.
//
// To let the terminal know these things, we have to look them up now,
// before we normally would.
//
// Typically, we'll just go into `ConsoleCreateIoThread` below, which will
// pull out the CONSOLE_API_CONNECTINFO from this connect message, and then
// get the liink properties out of the title later. Below are elements of
// ConsoleAllocateConsole and SetUpConsole that get the bits of STARTUP_INFO
// we care about for defterm handoffs.

// A placeholder that we'll read icon information into, instead of setting
// the globals icon state.
Microsoft::Console::Interactivity::IconInfo icon;

// To be able to actually process this connect message into a
// CONSOLE_API_CONNECTINFO, we need to hook up the ConDrvDeviceComm to the
// message. Usually, we'd create the ConDrvDeviceComm later, in
// ConsoleServerInitialization, but we can set it up early here.
// ConsoleServerInitialization will safely no-op if it already finds one.
g.pDeviceComm = new ConDrvDeviceComm(Server);
// load bearing: if you don't set this, the ConsoleInitializeConnectInfo will fail.
connectMessage->_pDeviceComm = g.pDeviceComm;

// TODO! Here, add the additional info we pulled out of the StartupInfo
// {
// NEW:
Microsoft::Console::Interactivity::IconInfo icon;
// Old

TraceLoggingWrite(g_hConhostV2EventTraceProvider,
"SrvInit_BeforeConsoleInitializeConnectInfo",
TraceLoggingDescription("TODO! debugging only"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE),
TraceLoggingKeyword(TIL_KEYWORD_TRACE));

CONSOLE_API_CONNECTINFO Cac;
THROW_IF_NTSTATUS_FAILED(ConsoleInitializeConnectInfo(connectMessage, &Cac));
RETURN_IF_NTSTATUS_FAILED(ConsoleInitializeConnectInfo(connectMessage, &Cac));

TraceLoggingWrite(g_hConhostV2EventTraceProvider,
"SrvInit_GotCac",
TraceLoggingDescription("TODO! debugging only"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE),
TraceLoggingKeyword(TIL_KEYWORD_TRACE));
// BEGIN ConsoleAllocateConsole(PCONSOLE_API_CONNECTINFO p)
// CALL auto Status = SetUpConsole(&p->ConsoleInfo, p->TitleLength, p->Title, p->CurDir, p->AppName);
Settings* pStartupSettings = &Cac.ConsoleInfo;
DWORD TitleLength = Cac.TitleLength;
LPWSTR Title = Cac.Title;
LPCWSTR CurDir = Cac.CurDir;
LPCWSTR AppName = Cac.AppName;
// BEGIN SetUpConsole(_Inout_ Settings* pStartupSettings, _In_ DWORD TitleLength, _In_reads_bytes_(TitleLength) LPWSTR Title, _In_ LPCWSTR CurDir, _In_ LPCWSTR AppName)
// auto& settings = ServiceLocator::LocateGlobals().getConsoleInformation();
// BEGIN code from SetUpConsole
// Create a temporary Settings object to parse the settings into, rather
// than parsing them into the global settings object (gci).
Settings settings{};
// We need to see if we were spawned from a link. If we were, we need to
// call back into the shell to try to get all the console information from the link.
settings.SetStartupFlags(pStartupSettings->GetStartupFlags());
ServiceLocator::LocateSystemConfigurationProvider()->GetSettingsFromLink(&settings, Title, &TitleLength, CurDir, AppName, &icon);

TraceLoggingWrite(g_hConhostV2EventTraceProvider,
"SrvInit_LoadedFromLink",
TraceLoggingDescription("TODO! debugging only"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE),
TraceLoggingKeyword(TIL_KEYWORD_TRACE));
// call back into the OS shell to try to get all the console information from the link.
//
// load bearing: if you don't pass the StartupFlags, then
// GetSettingsFromLink might not even bother attempting to check the lnk.
settings.SetStartupFlags(Cac.ConsoleInfo.GetStartupFlags());
ServiceLocator::LocateSystemConfigurationProvider()->GetSettingsFromLink(&settings,
Cac.Title,
&Cac.TitleLength,
Cac.CurDir,
Cac.AppName,
&icon);

// 1. The settings we were passed contains STARTUPINFO structure settings to be applied last.
settings.ApplyStartupInfo(pStartupSettings);
// }

TraceLoggingWrite(g_hConhostV2EventTraceProvider,
"SrvInit_AppliedStartupInfo",
TraceLoggingDescription("TODO! debugging only"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE),
TraceLoggingKeyword(TIL_KEYWORD_TRACE));

TERMINAL_STARTUP_INFO myStartupInfo{ Title, icon.path.c_str(), icon.index };

TraceLoggingWrite(g_hConhostV2EventTraceProvider,
"SrvInit_CreatedStartupInfo",
TraceLoggingDescription("TODO! debugging only"),
TraceLoggingWideString(myStartupInfo.pszTitle, "Title", "The title for the connection"),
TraceLoggingWideString(myStartupInfo.pszIconPath, "Icon", "The icon for the connection"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE),
TraceLoggingKeyword(TIL_KEYWORD_TRACE));
settings.ApplyStartupInfo(&Cac.ConsoleInfo);
// END code from SetUpConsole

// Take what we've collected, and bundle it up for handoff.
TERMINAL_STARTUP_INFO myStartupInfo{
Cac.Title,
icon.path.c_str(),
icon.index
};

RETURN_IF_FAILED(handoff->EstablishPtyHandoff(inPipeTheirSide.get(),
outPipeTheirSide.get(),
Expand Down

1 comment on commit e333661

@github-actions

This comment was marked as outdated.

Please sign in to comment.